refactor: remove ReturnValue instruction
This commit is contained in:
@@ -143,11 +143,7 @@ void furvm_generator::generate_instruction(furvm::mod& mod,
|
|||||||
generate_jump(mod, ctx, branch.else_block(), false);
|
generate_jump(mod, ctx, branch.else_block(), false);
|
||||||
} break;
|
} break;
|
||||||
case furlang::ir::instruction_t::Return: {
|
case furlang::ir::instruction_t::Return: {
|
||||||
if (instr.sources().empty()) {
|
|
||||||
mod.bytecode().push_back(static_cast<furvm::byte>(furvm::instruction_t::Return));
|
mod.bytecode().push_back(static_cast<furvm::byte>(furvm::instruction_t::Return));
|
||||||
} else {
|
|
||||||
mod.bytecode().push_back(static_cast<furvm::byte>(furvm::instruction_t::ReturnValue));
|
|
||||||
}
|
|
||||||
} break;
|
} break;
|
||||||
case furlang::ir::instruction_t::Call: {
|
case furlang::ir::instruction_t::Call: {
|
||||||
const auto& call = dynamic_cast<const furlang::ir::call_instruction&>(instr);
|
const auto& call = dynamic_cast<const furlang::ir::call_instruction&>(instr);
|
||||||
|
|||||||
@@ -170,11 +170,6 @@ enum class instruction_t : byte {
|
|||||||
* @brief Pops the current call frame.
|
* @brief Pops the current call frame.
|
||||||
*/
|
*/
|
||||||
Return,
|
Return,
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Pops the current call frame and pushes the first element from the previous stack onto the new stack.
|
|
||||||
*/
|
|
||||||
ReturnValue,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct instruction {
|
struct instruction {
|
||||||
|
|||||||
@@ -297,11 +297,6 @@ void executor::step() {
|
|||||||
pop_frame();
|
pop_frame();
|
||||||
if (m_frames.empty()) m_flags = m_flags | executor_flags::Done;
|
if (m_frames.empty()) m_flags = m_flags | executor_flags::Done;
|
||||||
} break;
|
} break;
|
||||||
case instruction_t::ReturnValue: {
|
|
||||||
auto value = pop_thing();
|
|
||||||
pop_frame();
|
|
||||||
push_thing(std::move(value));
|
|
||||||
} break;
|
|
||||||
case instruction_t::PushConstant: throw std::runtime_error("unimplemented");
|
case instruction_t::PushConstant: throw std::runtime_error("unimplemented");
|
||||||
default: throw std::runtime_error("unknown instruction");
|
default: throw std::runtime_error("unknown instruction");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user