|
|
|
@ -1453,21 +1453,10 @@ class FunctionSolc(CallerContextExpression): |
|
|
|
|
break |
|
|
|
|
return begin_loop_node |
|
|
|
|
|
|
|
|
|
def _rewrite_ternary_as_if_else(self) -> bool: |
|
|
|
|
ternary_found = True |
|
|
|
|
updated = False |
|
|
|
|
while ternary_found: |
|
|
|
|
ternary_found = False |
|
|
|
|
for node in self._node_to_nodesolc: |
|
|
|
|
has_cond = HasConditional(node.expression) |
|
|
|
|
if has_cond.result(): |
|
|
|
|
if node.is_conditional(): |
|
|
|
|
temp_var_node, temp_var = self.__make_temporary_variable_declaration_node_from_condition( |
|
|
|
|
node |
|
|
|
|
) |
|
|
|
|
def __inject_condition_expression_from_conditional_node(self, node: Node) -> Node: |
|
|
|
|
temp_var_node, temp_var = self.__make_temporary_variable_declaration_node_from_condition(node) |
|
|
|
|
if node.type == NodeType.IF: |
|
|
|
|
self.__link_node_immediately_before(temp_var_node, node) |
|
|
|
|
|
|
|
|
|
elif node.type == NodeType.IFLOOP: |
|
|
|
|
if_loop_node = node |
|
|
|
|
begin_loop_node: Optional[Node] = self.__find_start_loop_in_nodes_fathers(if_loop_node) |
|
|
|
@ -1481,12 +1470,21 @@ class FunctionSolc(CallerContextExpression): |
|
|
|
|
self.__link_node_immediately_before(temp_var_node_pre_loop, begin_loop_node) |
|
|
|
|
else: |
|
|
|
|
self.__link_node_immediately_before(temp_var_node, if_loop_node) |
|
|
|
|
node.add_expression(Identifier(temp_var), bypass_verif_empty=True) |
|
|
|
|
return temp_var_node |
|
|
|
|
|
|
|
|
|
else: |
|
|
|
|
raise TypeError(f'Unknown conditional type {node.type}') |
|
|
|
|
|
|
|
|
|
node.add_expression(Identifier(temp_var), bypass_verif_empty=True) |
|
|
|
|
node = temp_var_node # goes back by cfg |
|
|
|
|
def _rewrite_ternary_as_if_else(self) -> bool: |
|
|
|
|
ternary_found = True |
|
|
|
|
updated = False |
|
|
|
|
while ternary_found: |
|
|
|
|
ternary_found = False |
|
|
|
|
for node in self._node_to_nodesolc: |
|
|
|
|
has_cond = HasConditional(node.expression) |
|
|
|
|
if has_cond.result(): |
|
|
|
|
if node.is_conditional(): |
|
|
|
|
temp_var_node = self.__inject_condition_expression_from_conditional_node(node) |
|
|
|
|
node = temp_var_node # goes back by new cfg |
|
|
|
|
st = SplitTernaryExpression(node.expression) |
|
|
|
|
condition = st.condition |
|
|
|
|
if not condition: |
|
|
|
|