Exemplo n.º 1
0
 def createWith(self, obj, body, lineno):
     self.setRequiresActivation()
     result = Node(Token.BLOCK, lineno)
     result.addChildToBack(Node(Token.ENTERWITH, obj))
     bodyNode = Node(Token.WITH, body, lineno)
     result.addChildrenToBack(bodyNode)
     result.addChildToBack(Node(Token.LEAVEWITH))
     return result
Exemplo n.º 2
0
 def createIf(self, cond, ifTrue, ifFalse, lineno):
     condStatus = self.isAlwaysDefinedBoolean(cond)
     if (condStatus == self.ALWAYS_TRUE_BOOLEAN):
         return ifTrue
     else:
         if (condStatus == self.ALWAYS_FALSE_BOOLEAN):
             if ifFalse is not None:
                 return ifFalse
             return Node(Token.BLOCK, lineno)
     result = Node(Token.BLOCK, lineno)
     ifNotTarget = Node.newTarget()
     IFNE = Jump(Token.IFNE, cond)
     IFNE.target = ifNotTarget
     result.addChildToBack(IFNE)
     result.addChildrenToBack(ifTrue)
     if ifFalse is not None:
         endTarget = Node.newTarget()
         result.addChildToBack(self.makeJump(Token.GOTO, endTarget))
         result.addChildToBack(ifNotTarget)
         result.addChildrenToBack(ifFalse)
         result.addChildToBack(endTarget)
     else:
         result.addChildToBack(ifNotTarget)
     return result