403Webshell
Server IP : 217.160.0.212  /  Your IP : 216.73.216.141
Web Server : Apache
System : Linux www 6.18.51-i1-ampere #1196 SMP Fri Sep 11 20:43:55 CEST 2026 aarch64
User : sws1073854427 ( 1073854427)
PHP Version : 8.4.23
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/pythran/analyses/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/pythran/analyses/ancestors.py
"""
Ancestors computes the ancestors of each node
"""

from pythran.passmanager import ModuleAnalysis
from pythran.utils import pushpop


class Ancestors(ModuleAnalysis):
    '''
    Associate each node with the list of its ancestors

    Based on the tree view of the AST: each node has the Module as parent.
    The result of this analysis is a dictionary with nodes as key,
    and list of nodes as values.
    '''

    def __init__(self):
        self.result = dict()
        self.current = list()
        super(Ancestors, self).__init__()

    def generic_visit(self, node):
        self.result[node] = list(self.current)
        with pushpop(self.current, node):
            super(Ancestors, self).generic_visit(node)


class AncestorsWithBody(Ancestors):

    def visit_metadata(self, node):
        if hasattr(node, 'metadata'):
            self.generic_visit(node.metadata)

    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)

    def visit_If(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)

    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)

    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)

    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)

Youez - 2016 - github.com/yon3zu
LinuXploit