Exemplo n.º 1
0
    def __init__(self, func: Function, root: YulScope, ast: Dict):
        super().__init__(root.contract,
                         root.id + [ast["name"]],
                         parent_func=root.parent_func)

        assert ast["nodeType"] == "YulFunctionDefinition"

        self._function: Function = func
        self._root: YulScope = root
        self._ast: Dict = ast

        # start initializing the underlying function

        func.name = ast["name"]
        func.set_visibility("private")
        func.set_offset(ast["src"], root.slither)
        func.set_contract(root.contract)
        func.slither = root.slither
        func.set_contract_declarer(root.contract)
        func.scope = root.id
        func.is_implemented = True

        self._nodes: List[YulNode] = []
        self._entrypoint = self.new_node(NodeType.ASSEMBLY, ast["src"])
        func.entry_point = self._entrypoint.underlying_node

        self.add_yul_local_function(self)
Exemplo n.º 2
0
    def __init__(
        self, func: Function, root: YulScope, ast: Dict, node_scope: Union[Function, Scope]
    ):
        super().__init__(root.contract, root.id + [ast["name"]], parent_func=root.parent_func)

        assert ast["nodeType"] == "YulFunctionDefinition"

        self._function: Function = func
        self._root: YulScope = root
        self._ast: Dict = ast

        # start initializing the underlying function

        func.name = ast["name"]
        func.set_visibility("private")
        if isinstance(func, SourceMapping):
            func.set_offset(ast["src"], root.compilation_unit)
        if isinstance(func, FunctionContract):
            func.set_contract(root.contract)
            func.set_contract_declarer(root.contract)
        func.compilation_unit = root.compilation_unit
        func.internal_scope = root.id
        func.is_implemented = True
        self.node_scope = node_scope

        self._nodes: List[YulNode] = []
        self._entrypoint = self.new_node(NodeType.ASSEMBLY, ast["src"])
        func.entry_point = self._entrypoint.underlying_node

        self.add_yul_local_function(self)