예제 #1
0
  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
예제 #2
0
    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
예제 #3
0
 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
예제 #4
0
 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
예제 #5
0
 def visit_SetComp(self, node):
     elt = self.visit(node.elt)
     gens = sage.buildExprListExp(map(self.visit, node.generators))
     return sage.buildSetComp(elt, gens)
예제 #6
0
 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)
예제 #7
0
 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)
예제 #8
0
 def visit_Delete(self, node):
     target = sage.buildExprListExp(map(self.visit, node.targets))
     return sage.buildDelete(target)
예제 #9
0
 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)
예제 #10
0
 def visit_SetComp(self, node):
   elt = self.visit(node.elt)
   gens = sage.buildExprListExp(map(self.visit, node.generators))
   return sage.buildSetComp(elt, gens)
예제 #11
0
 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)
예제 #12
0
 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)
예제 #13
0
 def visit_Delete(self, node):
   target = sage.buildExprListExp(map(self.visit, node.targets))
   return sage.buildDelete(target)
예제 #14
0
 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)