Exemple #1
0
 def buildArguments(method, cmdLineArgs):
     arguments = ArgumentList()
     if len(method.parameters) == 1:
         name = method.parameters[0].getName()
         value = Interpreter.parseCmdLineArgs(cmdLineArgs)
         arguments.append(Argument(UnresolvedParameter(name), value))
     return arguments
Exemple #2
0
 def toODialect(self, writer):
     self.itype.toDialect(writer)
     arguments = ArgumentList()
     if self.copyFrom is not None:
         from prompto.param.AttributeParameter import AttributeParameter
         arguments.append(
             Argument(AttributeParameter("from"), self.copyFrom))
     if self.arguments is not None:
         arguments.extend(self.arguments)
     arguments.toDialect(writer)
Exemple #3
0
 def populateError(self, e, context):
     error = e.getExpression(context)
     if error == None:
         exp = ConstructorExpression(CategoryType("Error"), None, None)
         args = ArgumentList()
         args.append(Argument(UnresolvedParameter("name"), TextLiteral(type(e).__name__)))
         args.append(Argument(UnresolvedParameter("text"), TextLiteral(e.getMessage())))
         exp.setArguments(args)
         error = exp
     if context.getRegisteredValue(INamedInstance, self.errorName) == None:
         context.registerValue(ErrorVariable(self.errorName))
     if isinstance(error, IExpression):
         error = error.interpret(context)
     context.setValue(self.errorName, error)
     return error
Exemple #4
0
 def interpret(self, context, errorName):
     exp = self.getExpression(context)
     if exp is None:
         from prompto.grammar.Argument import Argument
         from prompto.grammar.ArgumentList import ArgumentList
         from prompto.expression.ConstructorExpression import ConstructorExpression
         from prompto.param.UnresolvedParameter import UnresolvedParameter
         from prompto.literal.TextLiteral import TextLiteral
         from prompto.type.CategoryType import CategoryType
         args = ArgumentList()
         args.append(
             Argument(UnresolvedParameter("name"),
                      TextLiteral(type(self).__name__)))
         args.append(
             Argument(UnresolvedParameter("text"),
                      TextLiteral(self.message)))
         exp = ConstructorExpression(CategoryType("Error"), args, None)
     if context.getRegisteredValue(object, errorName) is None:
         from prompto.runtime.ErrorVariable import ErrorVariable
         context.registerValue(ErrorVariable(errorName))
     error = exp.interpret(context)
     context.setValue(errorName, error)
     return error