def check(self, context): types = TypeMap() for element in self.elements: typ = element.check(context) if typ is not VoidType.instance: types.add(typ) return types.inferType(context)
def checkStatements(self, context, returnType, nativeOnly): if returnType == VoidType.instance: for statement in self: if nativeOnly and not isinstance(statement, Python2NativeCall): continue itype = statement.check(context) if itype != VoidType.instance: raise SyntaxError("Illegal return!") else: types = TypeMap() if returnType is not None: types[returnType.typeName] = returnType for statement in self: if nativeOnly and not isinstance(statement, Python2NativeCall): continue itype = statement.check(context) if not statement.canReturn(): itype = VoidType.instance if itype != VoidType.instance: # unless necessary, don't collect AnyType returned by native statement check if len( types ) == 0 or itype is not AnyType.instance or not nativeOnly: types[itype.typeName] = itype itype = types.inferType(context) if returnType is not None: return returnType else: return itype
def inferElementType(self, context): if len(self.entries) == 0: return MissingType.instance types = TypeMap() for e in self.entries: types.add(e.getValue().check(context)) return types.inferType(context)
def inferElementType(self, context): if len(self.expressions) == 0: return MissingType.instance else: types = TypeMap() for exp in self.expressions: types.add(exp.check(context)) return types.inferType(context)
def checkReturnType(self, context): types = TypeMap() self.collectReturnTypes(context, types) return types.inferType(context)