This commit is contained in:
2025-10-02 12:51:15 +10:00
parent cd7f9a6a2a
commit d7123aff1e
5 changed files with 26 additions and 1 deletions

View File

@@ -89,10 +89,14 @@ Value execute(Instruction inst) {
Value return_val;
for (const auto& body_inst : func.body) {
return_val = execute(body_inst);
if (return_val.is_return) {
break;
}
}
data::popScope();
return_val.is_return = false;
return return_val;
}
}
@@ -104,6 +108,16 @@ Value execute(Instruction inst) {
}
break;
}
case InstructionType::Return: {
if (inst.args.empty()) {
Value val;
val.is_return = true;
return val;
}
Value return_val = inst.args[0];
return_val.is_return = true;
return return_val;
}
default:
// Note: 'If' and 'Let' are already handled.
error("Unknown instruction");