Пример #1
0
def parseCreator(s, ut):
    # print('parseCreator', s, ut)
    if not s:
        return None
    creator = parser.parseFuncProto(s)
    creator.spec.returnType = ut
    return creator
Пример #2
0
 def processScript(self, visitor, script):
     owner = script.owner
     assert isinstance(owner, ast.ClassDef)
     cls = owner
     cls.singleton = True
     if not cls.hasSymbol('instance'):
         proto = parseFuncProto('instance() => %s' % owner.name)
         func = ast.FuncDef([], proto.name, proto.spec, ast.StatementBody([]))
         func.spec.static = True
         cls.definitions.append(func)
         func.setOwner(cls)
         visitor.visitNewItem(func)
         visitor.logger.debug('SingletonScript.processScript func', cls.name, func.name, cls, func)
Пример #3
0
 def processScript(self, visitor, script):
     owner = script.owner
     assert isinstance(owner, ast.ClassDef), (script, script.owner)
     # visitor.logger.debug('NameScript.processScript', self, script, owner)
     cls = owner
     if not cls.hasSymbol('getClassName'):
         # visitor.logger.debug('NameScript.processScript add getClassName', self, script, owner)
         proto = parseFuncProto('getClassName() => string')
         stmts = [ast.Return(ast.makeLiteral(cls.name))]
         func = ast.FuncDef([], proto.name, proto.spec, ast.StatementBody(stmts))
         cls.definitions.append(func)
         func.setOwner(cls)
         visitor.visitNewItem(func)
Пример #4
0
 def processScript(self, visitor, script):
     owner = script.owner
     # visitor.logger.debug('MixinScript.processScript', script, owner.bases, script.args)
     assert isinstance(owner, ast.ClassDef)
     script.mixin_var_type = ast.UserType(getScriptQuialifiedName(script.args[0]))
     script.mixin_var = ast.SingleVarDef(script.mixin_var_name, script.mixin_var_type, ast.Call(script.args[0].clone(), script.args[3:], script.namedArgs))
     proto = parseFuncProto('%s() => %s' % (script.mixin_propget_name, script.mixin_var_type.fullpath))
     script.mixin_propget = ast.FuncDef([], script.mixin_propget_name, proto.spec, ast.StatementBody([ast.Return(ast.Identifier(script.mixin_var_name))]))
     script.mixin_class = owner.resolveSymbol(script.mixin_var_type.path)
     # visitor.logger.debug('MixinScript.processScript add var', owner, script.owner, script, owner.bases, script.args, script.mixin_var)
     owner.definitions.append(script.mixin_var)
     script.mixin_var.setOwner(script.owner)
     owner.definitions.append(script.mixin_propget)
     script.mixin_propget.setOwner(script.owner)
     # visitor.logger.debug('MixinScript.processScript add var', owner, script.owner, script, owner.bases, script.args, script.mixin_var, script.mixin_var.owner)
     visitor.visitNewItem(script.mixin_var)
     visitor.visitNewItem(script.mixin_propget)
     self.addMixinFuncs(visitor, script, script.mixin_class, owner)
Пример #5
0
 def __init__(self, cls, proto):
     # print('LibFunc.init', cls, proto)
     ast.LibFuncBase.__init__(self)
     self.cls = cls
     self.protostr = proto
     self.proto = parser.parseFuncProto(proto) if isinstance(proto,
                                                             str) else proto
     self.proto.setOwner(self)
     assert (isinstance(self.proto, ast.FuncProto))
     self.target_name = self.proto.name
     self.name = self.proto.name
     assert self.name, (self.name, self, proto)
     self.spec = self.proto.spec
     self.type = self.spec
     self.headers = []
     self.returnType = self.spec.returnType
     # self.setTarget(self)
     self.type_name_resolved = False
     self.resolved = False
     self.evaluator = None
     self.astFieldNames = ['spec']
     assert (self.name)
Пример #6
0
 def __init__(self):
     ast.ScriptFunction.__init__(self)
     self.proto = parseFuncProto('getFunction() => [(string,gml.FuncDef)]')
     self.name = self.proto.name
     self.spec = self.proto.spec
     self.type = self.spec.returnType
Пример #7
0
 def __init__(self):
     ast.ScriptFunction.__init__(self)
     self.name = 'callMethod'
     self.spec = parseFuncProto('callMethod()').spec
     self.returnType = self.spec.returnType
     self.target = self