Your IP : 216.73.216.213
B
Z��Z�r � @ s� d dl mZmZ d dlZd dlZddlmZ ddlmZ ddlmZ ddlm Z ddlm
Z
dd lmZ dd
lmZ d dl
Z
e
jed� ejd dkr�eeeefZneeeeefZG d
d� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�Zdddddddd d!d"d#d$d%d&d'd(d)d*d+d,�jZ d-d.d/d0d1�jZ!G d2d3� d3e�Z"G d4d5� d5e�Z#d6d7� Z$G d8d9� d9e�Z%d:d;� Z&d<d=� Z'G d>d?� d?e�Z(e)d@k�r�d dl*Z*e*�+� dS )A� )�absolute_import�print_functionN� )� TypeSlots)�Builtin)�Nodes)� ExprNodes)�Errors)�
DebugFlags)�Future)�
_PRINTABLE� c s� e Zd ZdZ� fdd�Zddd�Zdd� Zd d
� Zej dd� �Z
d
d� Zej dd� �Zej dd� �Z
ddd�Zej ejed�dd� ��Z� ZS )�TreeVisitora�
Base class for writing visitors for a Cython tree, contains utilities for
recursing such trees using visitors. Each node is
expected to have a child_attrs iterable containing the names of attributes
containing child nodes or lists of child nodes. Lists are not considered
part of the tree structure (i.e. contained nodes are considered direct
children of the parent node).
visit_children visits each of the children of a given node (see the visit_children
documentation). When recursing the tree using visit_children, an attribute
access_path is maintained which gives information about the current location
in the tree as a stack of tuples: (parent_node, attrname, index), representing
the node, attribute and optional list index that was taken in each step in the path to
the current node.
Example:
>>> class SampleNode(object):
... child_attrs = ["head", "body"]
... def __init__(self, value, head=None, body=None):
... self.value = value
... self.head = head
... self.body = body
... def __repr__(self): return "SampleNode(%s)" % self.value
...
>>> tree = SampleNode(0, SampleNode(1), [SampleNode(2), SampleNode(3)])
>>> class MyVisitor(TreeVisitor):
... def visit_SampleNode(self, node):
... print("in %s %s" % (node.value, self.access_path))
... self.visitchildren(node)
... print("out %s" % node.value)
...
>>> MyVisitor().visit(tree)
in 0 []
in 1 [(SampleNode(0), 'head', None)]
out 1
in 2 [(SampleNode(0), 'body', 0)]
out 2
in 3 [(SampleNode(0), 'body', 1)]
out 3
out 0
c s t t| ��� i | _g | _d S )N)�superr �__init__�dispatch_table�access_path)�self)� __class__� �J/opt/alt/python37/lib64/python3.7/site-packages/Cython/Compiler/Visitor.pyr J s zTreeVisitor.__init__r c C s@ t |jp
g �dddddg }g }t|dd �}|rp|d }|rTdd l}|j�|�� �}|�d||d |d f � t|�}|� � x�|D ]�} | |kr�q�| �
d
�s�| �d
�r�q�yt|| �}
W n tk
r� w�Y nX |
d ks�|
dkr�q�n0t
|
t �r�dt|
� }
nt
|
t��sq�nt|
�}
|�d| |
f � q�W d
|jjd�|�f S )N�child_attrs�posZgil_messageZcpp_messageZsubexprsr z%s:%s:%sr � �_z[...]/%dz%s = %sz%s(%s)z,
)�listr �getattr�os.path�path�basename�get_description�append�dir�sort�
startswith�endswith�AttributeError�
isinstance�lenr �reprr �__name__�join)r �node�indentZignored�valuesr �source�osZattribute_names�attr�valuer r r � dump_nodeO s<