Exemple #1
0
def _build_call(state, addr, instruction):
    call = nodes.FunctionCall()
    call.function = _build_slot(state, addr, instruction.A)
    call.arguments.contents = _build_call_arguments(state, addr, instruction)

    line_marked = [call]

    if instruction.opcode <= ins.CALL.opcode:
        if instruction.B == 0:
            node = nodes.Assignment()
            node.destinations.contents.append(nodes.MULTRES())
            node.expressions.contents.append(call)
        elif instruction.B == 1:
            node = call
        else:
            from_slot = instruction.A
            to_slot = instruction.A + instruction.B - 2
            node = _build_range_assignment(state, addr, from_slot, to_slot)
            node.expressions.contents.append(call)
    else:
        assert instruction.opcode <= ins.CALLT.opcode
        node = nodes.Return()
        node.returns.contents.append(call)
        line_marked.append(node)

    return node, line_marked
Exemple #2
0
def _build_call(state, addr, instruction):
    call = nodes.FunctionCall()
    call.function = _build_slot(state, addr, instruction.A)
    call.arguments.contents = _build_call_arguments(state, addr, instruction)
    call.name = _lookup_variable_name(state, addr, instruction.A)
    if gconfig.gVerbose:
        print("_build_call " + call.name)

    # CALLM Call: A, ..., A+B-2 = A(A+1, ..., A+C+MULTRES)
    # CALL Call: A, ..., A+B-2 = A(A+1, ..., A+C-1)
    if instruction.opcode <= ins.CALL.opcode:
        if instruction.B == 0:
            node = nodes.Assignment()
            node.destinations.contents.append(nodes.MULTRES())
            node.expressions.contents.append(call)
        elif instruction.B == 1:
            node = call
        # elif call.name and call.name == "class" and instruction.B == 2:
        #     class_name = _lookup_variable_name(state, addr, instruction.A+1)
        #     print("class " + class_name)
        #     assert class_name is not None
        #     node = _build_class_assignment(addr, instruction.A, class_name)
        #     node.expressions.contents.append(call)
        else:
            from_slot = instruction.A
            to_slot = instruction.A + instruction.B - 2
            node = _build_range_assignment(state, addr, from_slot, to_slot)
            node.expressions.contents.append(call)
    # CALLMT Tailcall: return A(A+1, ..., A+D+MULTRES)
    # CALLT Tailcall: return A(A+1, ..., A+D-1)
    else:
        assert instruction.opcode <= ins.CALLT.opcode
        node = nodes.Return()
        node.returns.contents.append(call)

    return node