Example #1
0
 def interpret(context, methodName, cmdLineArgs):
     try:
         method = Interpreter.locateMethod(context, methodName, cmdLineArgs)
         arguments = Interpreter.buildArguments(method, cmdLineArgs)
         call = MethodCall(MethodSelector(methodName), arguments)
         call.interpret(context)
     finally:
         context.terminated()
Example #2
0
 def resolveMethodCall(self, context):
     if not self.dialect is Dialect.E:
         return None
     from prompto.statement.MethodCall import MethodCall
     from prompto.expression.MethodSelector import MethodSelector
     try:
         method = MethodCall(MethodSelector(self.name))
         method.check(context)
         return method
     except SyntaxError:
         return None
Example #3
0
 def resolveUnresolvedMethodReference(self, context, name):
     # it could be a reference to a local closure
     named = context.getRegisteredValue(INamed, name)
     if named is None:
         return None
     itype = named.getType(context)
     if itype is not None:
         itype = itype.resolve(context)
         if isinstance(itype, MethodType):
             call = MethodCall(MethodSelector(name), self.arguments)
             call.variableName = name
             return call
     return None
Example #4
0
 def resolveUnresolvedDeclaration(self, context, name):
     decl = context.getRegisteredDeclaration(IDeclaration, name)
     if decl is None:
         raise SyntaxError("Unknown name:" + name)
     if isinstance(decl, CategoryDeclaration):
         return ConstructorExpression(CategoryType(name), None, self.arguments)
     else:
         return MethodCall(MethodSelector(name), self.arguments)
Example #5
0
 def resolveUnresolvedMemberMethod(self, context, name):
     instance = context.getClosestInstanceContext()
     if instance is None:
         return None
     decl = self.resolveUnresolvedMember(instance, name)
     if decl is not None:
         return MethodCall(MethodSelector(name), self.arguments)
     else:
         return None
Example #6
0
 def globalMethodExists(self, context, name):
     from prompto.statement.MethodCall import MethodCall
     from prompto.runtime.MethodFinder import MethodFinder
     try:
         exp = ValueExpression(self, self.newInstance(context))
         arg = Argument(None, exp)
         args = ArgumentList(items=[arg])
         proto = MethodCall(MethodSelector(name), args)
         finder = MethodFinder(context, proto)
         return finder.findBest(True) is not None
     except PromptoError:
         return False
Example #7
0
    def getGlobalMethodSortKeyReader(self, context, name):
        from prompto.statement.MethodCall import MethodCall
        exp = ValueExpression(self, self.newInstance(context))
        arg = Argument(None, exp)
        args = ArgumentList(items=[arg])
        call = MethodCall(MethodSelector(name), args)

        def keyGetter(o):
            argument = call.arguments[0]
            argument.setExpression(ValueExpression(self, o))
            return call.interpret(context)

        return keyGetter
Example #8
0
 def resolveMember(self, context):
     parent = self.caller.getParent()
     name = self.caller.getName()
     return MethodCall(MethodSelector(name, parent), self.arguments)
Example #9
0
 def resolveMember(self, context: Context):
     parent = self.caller.parent
     name = self.caller.name
     return MethodCall(MethodSelector(name, parent), self.arguments)