def VisitConstructorDecl(self, node): node.env.Update(self.PassVisit(node.env, node.params)) self.ForkVisit(node.env, node.body) env = Environment() env.AddMethod(node.name.lexeme, node) return env
def VisitLocalVarDecl(self, node): self.ForkVisit(node.env, node.var_decl) self.PassVisit(node.env, node.l_type) env = Environment() env.AddLocalVar(node.var_decl.var_id.lexeme, node) return env
def VisitMethodHeader(self, node): self.PassVisit(node.env, node.m_type) self.PassVisit(node.env, node.params) env = Environment() env.Update(self.PassVisit(node.env, node.params)) return env
def VisitInterfaceDecl(self, node): node.env.Update(self.ForkVisit(node.env, node.method_decls)) self.PassVisit(node.env, node.extends_interface) env = Environment() env.AddClassOrInterface(node.name.lexeme, node) return env
def VisitMethodDecl(self, node): node.env.Update(self.ForkVisit(node.env, node.header)) node.env.Update(self.ForkVisit(node.env, node.body_block)) env = Environment() env.AddMethod(node.header.m_id.lexeme, node) return env
def VisitFieldDecl(self, node): node.env.Update(self.ForkVisit(node.env, node.var_decl)) self.PassVisit(node.env, node.f_type) self.PassVisit(node.env, node.var_decl) env = Environment() env.AddField(node.var_decl.var_id.lexeme, node) return env
def VisitClassDecl(self, node): self.PassVisit(node.env, node.extends) self.PassVisit(node.env, node.interfaces) node.env.Update(self.ForkVisit(node.env, node.method_decls)) node.env.Update(self.ForkVisit(node.env, node.constructor_decls)) node.env.Update(self.ForkVisit(node.env, node.field_decls)) env = Environment() env.AddClassOrInterface(node.name.lexeme, node) return env
def VisitBlock(self, node): env = node.env.upstream.Fork() if node.stmts: for stmt in node.stmts: update = self.ForkVisit(env, stmt) env = env.Fork() env.Update(update) return Environment.Empty()
def VisitImportDecl(self, node): return Environment.Empty()
def VisitParameter(self, node): self.PassVisit(node.env, node.p_type) env = Environment() env.AddParameter(node.var_id.lexeme, node) return env
def VisitWhileStatement(self, node): self.PassVisit(node.env, node.test_expr) self.ForkVisit(node.env, node.body) return Environment.Empty()
def VisitReturnStatement(self, node): self.PassVisit(node.env, node.exp) return Environment.Empty()
def VisitArrayCreationExpression(self, node): self.PassVisit(node.env, node.a_type) self.PassVisit(node.env, node.exp) return Environment.Empty()
def VisitArrayAccess(self, node): self.PassVisit(node.env, node.name_or_primary) self.PassVisit(node.env, node.exp) return Environment.Empty()
def VisitParensExpression(self, node): self.PassVisit(node.env, node.exp) return Environment.Empty()
def VisitEmptyStatement(self, node): return Environment.Empty()
def VisitUnaryExpression(self, node): self.PassVisit(node.env, node.right) return Environment.Empty()
def VisitCastExpression(self, node): self.PassVisit(node.env, node.cast_type) self.PassVisit(node.env, node.exp) return Environment.Empty()
def VisitPackageDecl(self, node): env = Environment() env.AddPackage(node.name.AsString(), node) return env
def VisitFieldAccess(self, node): self.PassVisit(node.env, node.primary) return Environment.Empty()
def VisitNameExpression(self, node): self.PassVisit(node.env, node.name) return Environment.Empty()
def VisitThisExpression(self, node): return Environment.Empty()
def VisitClassInstanceCreationExpression(self, node): self.PassVisit(node.env, node.class_type) self.PassVisit(node.env, node.args) return Environment.Empty()
def VisitStatementExpression(self, node): self.PassVisit(node.env, node.stmt) return Environment.Empty()
def VisitForStatement(self, node): node.env.Update(self.PassVisit(node.env, node.init)) self.PassVisit(node.env, node.test_expr) self.PassVisit(node.env, node.update) self.ForkVisit(node.env, node.body) return Environment.Empty()
def VisitAssignmentExpression(self, node): self.PassVisit(node.env, node.lhs) self.PassVisit(node.env, node.exp) return Environment.Empty()
def VisitVariableDeclarator(self, node): self.PassVisit(node.env, node.exp) return Environment.Empty()
def VisitMethodInvocation(self, node): self.PassVisit(node.env, node.name) self.PassVisit(node.env, node.primary) self.PassVisit(node.env, node.args) return Environment.Empty()
def VisitIfThenElseStatement(self, node): self.PassVisit(node.env, node.test_expr) self.ForkVisit(node.env, node.stmt_true) self.ForkVisit(node.env, node.stmt_false) return Environment.Empty()