def define(self, c): self.c = c # Just define it - don't type check since we can't yet anyways args = tuple(f.name for f in self.node.formals.getType()) try: env.defineMethod(c, self.node.id.name, args + (self.node.type.name,)) except SymbolError, e: e.setToken(self.token) e.report()
def pass1(self): # Define the class self.node.type.checker.define(self.node.superclass) # Define each of the methods and parameters constructor_args = [] for formal in self.node.formals.children: formal.id.checker.attrDefine(self.node.type, formal.type) constructor_args.append(formal.type.name) constructor_args.append(self.node.type.name) env.defineMethod(self.node.type.name, "_constructor", constructor_args) for feature in self.node.body.children: if isinstance(feature, tree.Def): feature.checker.define(self.node.type.name) elif isinstance(feature, tree.VarInit): feature.id.checker.attrDefine(self.node.type, feature.type)