How to use the pythran.metadata.visit function in pythran

To help you get started, we’ve selected a few pythran examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github serge-sans-paille / pythran / pythran / analyses / locals_analysis.py View on Github external
def visit_For(self, node):
        self.expr_parent = node
        self.result[node] = self.locals.copy()
        md.visit(self, node)
        self.visit(node.iter)
        self.locals.add(node.target.id)
        for stmt in node.body:
            self.visit(stmt)
        for stmt in node.orelse:
            self.visit(stmt)
github serge-sans-paille / pythran / pythran / backend.py View on Github external
def visit(self, node):
        metadata.visit(self, node)
        return super(CxxFunction, self).visit(node)
github serge-sans-paille / pythran / pythran / analyses / lazyness_analysis.py View on Github external
def visit_Assign(self, node):
        md.visit(self, node)
        self.visit(node.value)
        ids = self.gather(Identifiers, node.value)
        for target in node.targets:
            if isinstance(target, ast.Name):
                self.assign_to(target, ids)
                if node.value not in self.pure_expressions:
                    self.result[target.id] = LazynessAnalysis.INF
            elif isinstance(target, (ast.Subscript)) or isattr(target):
                # if we modify just a part of a variable, it can't be lazy
                var_name = get_variable(target)
                if isinstance(var_name, ast.Name):
                    # variable is modified so other variables that use it dies
                    self.modify(var_name.id)
                    # and this variable can't be lazy
                    self.result[var_name.id] = LazynessAnalysis.INF
            else:
github serge-sans-paille / pythran / pythran / analyses / lazyness_analysis.py View on Github external
def visit_While(self, node):
        md.visit(self, node)
        self.visit(node.test)

        self.visit_loop(node.body)

        for stmt in node.orelse:
            self.visit(stmt)
github serge-sans-paille / pythran / pythran / analyses / lazyness_analysis.py View on Github external
def visit_AugAssign(self, node):
        md.visit(self, node)
        # augassigned variable can't be lazy
        self.visit(node.value)
        if isinstance(node.target, ast.Name):
            # variable is modified so other variables that use it dies
            self.modify(node.target.id)
            # and this variable can't be lazy
            self.result[node.target.id] = LazynessAnalysis.INF
        elif isinstance(node.target, ast.Subscript) or isattr(node.target):
            var_name = get_variable(node.target)
            # variable is modified so other variables that use it dies
            self.modify(var_name.id)
            # and this variable can't be lazy
            self.result[var_name.id] = LazynessAnalysis.INF
        else:
            raise PythranSyntaxError("AugAssign to unknown node", node)
github serge-sans-paille / pythran / pythran / analyses / lazyness_analysis.py View on Github external
def visit_For(self, node):
        md.visit(self, node)
        ids = self.gather(Identifiers, node.iter)
        if isinstance(node.target, ast.Name):
            self.assign_to(node.target, ids)
            self.result[node.target.id] = LazynessAnalysis.INF
        else:
            err = "Assignation in for loop not to a Name"
            raise PythranSyntaxError(err, node)

        self.visit_loop(node.body)

        for stmt in node.orelse:
            self.visit(stmt)
github serge-sans-paille / pythran / pythran / analyses / locals_analysis.py View on Github external
def visit_Assign(self, node):
        self.expr_parent = node
        self.result[node] = self.locals.copy()
        md.visit(self, node)
        self.visit(node.value)
        self.locals.update(t.id for t in node.targets
                           if isinstance(t, ast.Name))
        for target in node.targets:
            self.visit(target)