def __init__(self, ast, parent):
    self.depth = ((parent.depth + 1) if (parent is not None) else 0)
    self._parent = parent
    self._children = set()
    src = [int(i) for i in ast['src'].split(':')]
    self.offset = (src[0], (src[0] + src[1]))
    self.contract_id = src[2]
    self.fields = sorted(ast.keys())
    for (key, value) in ast.items():
        if (isinstance(value, dict) and (value.get('nodeType') == 'Block')):
            value = value['statements']
        elif ((key == 'body') and (not value)):
            value = []
        if isinstance(value, dict):
            item = node_class_factory(value, self)
            if isinstance(item, NodeBase):
                self._children.add(item)
            setattr(self, key, item)
        elif isinstance(value, list):
            items = [node_class_factory(i, self) for i in value]
            setattr(self, key, items)
            self._children.update((i for i in items if isinstance(i, NodeBase)))
        else:
            setattr(self, key, value)
def __init__(self, ast, parent):
    self.depth = ((parent.depth + 1) if (parent is not None) else 0)
    self._parent = parent
    self._children = set()
    src = [int(i) for i in ast['src'].split(':')]
    self.offset = (src[0], (src[0] + src[1]))
    self.contract_id = src[2]
    self.fields = sorted(ast.keys())
    for (key, value) in ast.items():
        if (isinstance(value, dict) and (value.get('nodeType') == 'Block')):
            value = value['statements']
        elif ((key == 'body') and (not value)):
            value = []
        if isinstance(value, dict):
            item = node_class_factory(value, self)
            if isinstance(item, NodeBase):
                self._children.add(item)
            setattr(self, key, item)
        elif isinstance(value, list):
            items = [node_class_factory(i, self) for i in value]
            setattr(self, key, items)
            self._children.update((i for i in items if isinstance(i, NodeBase)))
        else:
            setattr(self, key, value)