예제 #1
0
 def visit_While(self, node):
     self.result[node] = list(self.current)
     with pushpop(self.current, node):
         self.generic_visit(node.test)
         self.visit_metadata(node)
         self.visit_body(node.body)
         self.visit_body(node.orelse)
예제 #2
0
 def visit_For(self, node):
     self.result[node] = list(self.current)
     with pushpop(self.current, node):
         self.generic_visit(node.target)
         self.generic_visit(node.iter)
         self.visit_metadata(node)
         self.visit_body(node.body)
         self.visit_body(node.orelse)
예제 #3
0
 def visit_Try(self, node):
     self.result[node] = list(self.current)
     with pushpop(self.current, node):
         self.visit_metadata(node)
         self.visit_body(node.body)
         for handler in node.handlers:
             self.generic_visit(handler)
         self.visit_body(node.orelse)
         self.visit_body(node.finalbody)
예제 #4
0
파일: backend.py 프로젝트: hmaarrfk/pythran
    def loop_visitor(self, node):
        """
        New decorate function.

        It push the breaking flag, run the visitor and add "else" statements.
        """
        if not node.orelse:
            with pushpop(self.break_handlers, None):
                res = visit(self, node)
            return res

        break_handler = "__no_breaking{0}".format(id(node))
        with pushpop(self.break_handlers, break_handler):
            res = visit(self, node)

        # handle the body of the for loop
        orelse = [self.visit(stmt) for stmt in node.orelse]
        orelse_label = Label(break_handler)
        return Block([res] + orelse + [orelse_label])
예제 #5
0
    def loop_visitor(self, node):
        """
        New decorate function.

        It push the breaking flag, run the visitor and add "else" statements.
        """
        if not node.orelse:
            with pushpop(self.break_handlers, None):
                res = visit(self, node)
            return res

        break_handler = "__no_breaking{0}".format(id(node))
        with pushpop(self.break_handlers, break_handler):
            res = visit(self, node)

        # handle the body of the for loop
        orelse = [self.visit(stmt) for stmt in node.orelse]
        orelse_label = Label(break_handler)
        return Block([res] + orelse + [orelse_label])
예제 #6
0
 def visit_body(self, body):
     body_as_tuple = tuple(body)
     self.result[body_as_tuple] = list(self.current)
     with pushpop(self.current, body_as_tuple):
         for stmt in body:
             self.generic_visit(stmt)
예제 #7
0
 def generic_visit(self, node):
     self.result[node] = list(self.current)
     with pushpop(self.current, node):
         super(Ancestors, self).generic_visit(node)
예제 #8
0
 def generic_visit(self, node):
     self.result[node] = list(self.current)
     with pushpop(self.current, node):
         super(Ancestors, self).generic_visit(node)