Пример #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)