def visit_Module(self, node): scope = sage.buildGlobalScope(self.filename) self.scopeStack.push(scope) subforest = self.generic_visit(node) self.scopeStack.pop(scope) sage.appendStatements(scope, subforest) return scope
def visit_Lambda(self, node): scope = self.scopeStack.peek() params = self.visit(node.args) (lambda_capsule, lambda_scope) = sage.buildLambda(params, scope) self.scopeStack.push(scope) expr = self.visit(node.body) self.scopeStack.pop(scope) sage.appendStatements(lambda_capsule, [expr]) return lambda_capsule
def visit_ClassDef(self, node): scope = self.scopeStack.peek() bases = node.bases and map(self.visit, node.bases) decorators = node.decorator_list and sage.buildExprListExp(map(self.visit, node.decorator_list)) class_decl, scope = \ sage.buildClassDef(node.name, bases, decorators, scope) self.scopeStack.push(scope) body = map(self.visit, node.body) sage.appendStatements(scope, body) self.scopeStack.pop(scope) return class_decl
def visit_ClassDef(self, node): scope = self.scopeStack.peek() bases = node.bases and map(self.visit, node.bases) decorators = node.decorator_list and sage.buildExprListExp( map(self.visit, node.decorator_list)) class_decl, scope = \ sage.buildClassDef(node.name, bases, decorators, scope) self.scopeStack.push(scope) body = map(self.visit, node.body) sage.appendStatements(scope, body) self.scopeStack.pop(scope) return class_decl
def visit_FunctionDef(self, node): scope = self.scopeStack.peek() decorators = node.decorator_list and sage.buildExprListExp(map(self.visit, node.decorator_list)) stararg_id = node.args.vararg and sage.buildInitializedName(node.args.vararg, starred=True) dstararg_id = node.args.kwarg and sage.buildInitializedName(node.args.kwarg, dstarred=True) params = self.visit(node.args) (capsule, scope) = \ sage.buildFunctionDef(node.name, params, decorators, stararg_id, dstararg_id, scope) self.scopeStack.push(scope) body_forest = map(self.visit, node.body) sage.appendStatements(capsule, body_forest) self.scopeStack.pop(scope) return capsule
def visit_FunctionDef(self, node): scope = self.scopeStack.peek() decorators = node.decorator_list and sage.buildExprListExp( map(self.visit, node.decorator_list)) stararg_id = node.args.vararg and sage.buildInitializedName( node.args.vararg, starred=True) dstararg_id = node.args.kwarg and sage.buildInitializedName( node.args.kwarg, dstarred=True) params = self.visit(node.args) (capsule, scope) = \ sage.buildFunctionDef(node.name, params, decorators, stararg_id, dstararg_id, scope) self.scopeStack.push(scope) body_forest = map(self.visit, node.body) sage.appendStatements(capsule, body_forest) self.scopeStack.pop(scope) return capsule