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/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/pythran/metadata.py
"""
This module provides a way to pass information between passes as metadata.

* add attaches a metadata to a node
* get retrieves all metadata from a particular class attached to a node
"""

from gast import AST  # so that metadata are walkable as regular ast nodes


class Metadata(AST):

    """ Base class to add information on a node to improve code generation. """

    def __init__(self):
        """ Initialize content of these metadata. """
        self.data = list()
        self._fields = ('data',)
        super(Metadata, self).__init__()

    def __iter__(self):
        """ Enable iteration over every metadata informations. """
        return iter(self.data)

    def append(self, data):
        """ Add a metadata information. """
        self.data.append(data)


class Lazy(AST):

    """ Metadata to mark variable which doesn't need to be evaluated now. """


class Comprehension(AST):
    def __init__(self, *args):  # no positional argument to be deep copyable
        super(Comprehension, self).__init__()
        if args:
            self.target = args[0]


class StaticReturn(AST):

    """ Metadata to mark return with a constant value. """


class Local(AST):
    """ Metadata to mark function as non exported. """


def add(node, data):
    if not hasattr(node, 'metadata'):
        node.metadata = Metadata()
        node._fields += ('metadata',)
    node.metadata.append(data)


def get(node, class_):
    if hasattr(node, 'metadata'):
        return [s for s in node.metadata if isinstance(s, class_)]
    else:
        return []


def clear(node, class_):
    if hasattr(node, 'metadata'):
        node.metadata.data = [s for s in node.metadata
                              if not isinstance(s, class_)]
        if not node.metadata.data:
            del node.metadata
            assert node._fields[-1] == 'metadata'
            node._fields = node._fields[:-1]


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

Youez - 2016 - github.com/yon3zu
LinuXploit