← Back
Editing: global_declarations.cpython-311.pyc
� cR�a� � �Z � d Z ddlmZ ddlmZ G d� de� � Z G d� de� � ZdS ) z4 GlobalDeclarations gathers top-level declarations. � )�ModuleAnalysis)�DefUseChainsc � � e Zd Zd� ZdS )�SilentDefUseChainsc � � d S )N� )�self�name�nodes �F/usr/lib/python3/dist-packages/pythran/analyses/global_declarations.py�unbound_identifierz%SilentDefUseChains.unbound_identifier s � ��� N)�__name__� __module__�__qualname__r r r r r r s# � � � � � � � � � � r r c �( � � e Zd ZdZ� fd�Zd� Z� xZS )�GlobalDeclarationsa� Gather all kind of identifier defined at global scope. >>> import gast as ast >>> from pythran import passmanager >>> from pythran.analyses import GlobalDeclarations >>> node = ast.parse(''' ... import math ... import math as maths ... from math import cos ... c = 12 ... def foo(a): ... b = a + 1''') >>> pm = passmanager.PassManager("test") >>> sorted(pm.gather(GlobalDeclarations, node).keys()) ['c', 'cos', 'foo', 'math', 'maths'] c �| �� t � � | _ t t | � � � � � dS )z3 Result is an identifier with matching definition. N)�dict�result�superr �__init__)r � __class__s �r r zGlobalDeclarations.__init__! s1 �� ��f�f��� � �$�'�'�0�0�2�2�2�2�2r c � � t � � }|� |� � d� |j | D � � | _ dS )z+ Import module define a new variable name. c �B � i | ]}|� � � |j ��S r )r r )�.0�ds r � <dictcomp>z3GlobalDeclarations.visit_Module.<locals>.<dictcomp>* s4 � � 2� 2� 2�� �v�v�x�x��� 2� 2� 2r N)r �visit�localsr )r r �ducs r �visit_ModulezGlobalDeclarations.visit_Module&