o
    í@Ëaò  ã                   @   s$   d Z ddlmZ G dd„ deƒZdS )z0
NodeCount counts the number of nodes in a node
é    )ÚNodeAnalysisc                       s,   e Zd ZdZ‡ fdd„Z‡ fdd„Z‡  ZS )Ú	NodeCounta–  
    Count the number of nodes included in a node

    This has nothing to do with execution time or whatever,
    its mainly use is to prevent the AST from growing too much when unrolling

    >>> import gast as ast
    >>> from pythran import passmanager, backend
    >>> node = ast.parse("if 1: return 3")
    >>> pm = passmanager.PassManager("test")
    >>> print(pm.gather(NodeCount, node))
    5
    c                    s   d| _ tt| ƒ ¡  d S )Nr   )ÚresultÚsuperr   Ú__init__)Úself©Ú	__class__© ú=/usr/lib/python3/dist-packages/pythran/analyses/node_count.pyr      s   zNodeCount.__init__c                    s"   |  j d7  _ tt| ƒ |¡ d S )Né   )r   r   r   Úgeneric_visit)r   Znoder   r
   r   r      s   zNodeCount.generic_visit)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ú__classcell__r
   r
   r   r   r      s    r   N)r   Zpythran.passmanagerr   r   r
   r
   r
   r   Ú<module>   s    