def check(self): env.enterScope() if not isinstance(self.node.id, tree.Null): self.node.id.checker.define(self.node.type, shadow=True) self.node.block.check() self.node.type = self.getType() env.exitScope()
def check(self): env.enterScope() for line in self.node.contents: line.check() self.node.value.check() self.type = self.node.value.getType() env.exitScope()
env.enterScope() for i, formal in enumerate(self.node.formals.children): formal.id.checker.define(formal.type.getType(), shadow=True, static="%%arg%d" % i) formal.id.check() self.node.type.check() self.node.value.check() t = self.node.value.getType() if t is None or not t.subsetOf(self.getType()): TypeCheckError("Method result '%s' does not match method return type '%s'" % (t, self.getType()), self.node.type.token).report() env.exitScope() class Identifier(NodeChecker): def getType(self): try: return Type(env.getVarType(self.node.name)) except SymbolError, e: e.setToken(self.token) e.report() def attrDefine(self, attrClass, attrType): try: env.defineAttr(attrClass.name, self.node.name, attrType.name) except SymbolError, e: if getattr(attrClass, 'suppress_errors', False): e.ignore()