예제 #1
0
파일: control.py 프로젝트: metazool/py-wasm
def if_op(config: Configuration) -> None:
    """
    Logic function for the IF opcode
    """
    instruction = cast(If, config.current_instruction)

    if config.enable_logic_fn_logging:
        logger.debug("%s()", instruction.opcode.text)

    value = config.pop_operand()
    arity = len(instruction.result_type)

    if value:
        label = Label(
            arity=arity,
            instructions=instruction.instructions,
            is_loop=False,
        )
    else:
        label = Label(
            arity=arity,
            instructions=instruction.else_instructions,
            is_loop=False,
        )

    config.push_label(label)
예제 #2
0
파일: control.py 프로젝트: metazool/py-wasm
def loop_op(config: Configuration) -> None:
    """
    Logic function for the LOOP opcode
    """
    instruction = cast(Loop, config.current_instruction)

    if config.enable_logic_fn_logging:
        logger.debug("%s()", instruction.opcode.text)

    label = Label(
        arity=0,
        instructions=instruction.instructions,
        is_loop=True,
    )
    config.push_label(label)
예제 #3
0
파일: control.py 프로젝트: metazool/py-wasm
def block_op(config: Configuration) -> None:
    """
    Logic function for the BLOCK opcode
    """
    block = cast(Block, config.current_instruction)

    if config.enable_logic_fn_logging:
        logger.debug("%s()", block.opcode.text)

    label = Label(
        arity=len(block.result_type),
        instructions=block.instructions,
        is_loop=False,
    )
    config.push_label(label)