← Back
Editing: local_declarations.cpython-311.pyc
� cR�a� � �V � d Z ddlmZ ddlZ G d� de� � Z G d� de� � ZdS )z� LocalNameDeclarations gathers name of declarations local to a node. LocalNodeDeclarations gathers node of declarations local to a node. � )�NodeAnalysisNc �( � � e Zd ZdZ� fd�Zd� Z� xZS )�LocalNodeDeclarationsa� Gathers all local symbols from a function. It should not be use from outside a function, but can be used on a function (but in that case, parameters are not taken into account) >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse(''' ... def foo(a): ... b = a + 1''') >>> pm = passmanager.PassManager("test") >>> [name.id for name in pm.gather(LocalNodeDeclarations, node)] ['b'] >>> node = ast.parse(''' ... for c in range(n): ... b = a + 1''') >>> pm = passmanager.PassManager("test") >>> sorted([name.id for name in pm.gather(LocalNodeDeclarations, node)]) ['b', 'c'] c �| �� t � � | _ t t | � � � � � dS �z% Initialize empty set as the result. N)�set�result�superr �__init__��self� __class__s ��E/usr/lib/python3/dist-packages/pythran/analyses/local_declarations.pyr zLocalNodeDeclarations.__init__# �1 �� ��e�e��� �#�T�*�*�3�3�5�5�5�5�5� c �| � t |j t j � � r| j � |� � dS dS )z3 Any node with Store context is a new declaration. N)� isinstance�ctx�ast�Storer �add�r �nodes r � visit_Namez LocalNodeDeclarations.visit_Name( s<