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
def visit_SetComp(self, node): elt = self.visit(node.elt) gens = sage.buildExprListExp(map(self.visit, node.generators)) return sage.buildSetComp(elt, gens)
def visit_Print(self, node): dest = node.dest and self.visit(node.dest) values = sage.buildExprListExp(map(self.visit, node.values)) return sage.buildPrintStmt(dest, values)
def visit_DictComp(self, node): key = self.visit(node.key) value = self.visit(node.value) elt = sage.buildKeyDatumPair(key, value) gens = sage.buildExprListExp(map(self.visit, node.generators)) return sage.buildDictComp(elt, gens)
def visit_Delete(self, node): target = sage.buildExprListExp(map(self.visit, node.targets)) return sage.buildDelete(target)
def visit_comprehension(self, node): ifs = node.ifs and sage.buildExprListExp(map(self.visit, node.ifs)) target = self.visit(node.target) iter = self.visit(node.iter) return sage.buildComprehension(target, iter, ifs)