feat(arc): waittill undefined param (#149)

This commit is contained in:
Xenxo Espasandín 2023-09-24 14:36:08 +02:00 committed by GitHub
parent 008d545bdb
commit 4721acaa4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 5 deletions

View File

@ -302,6 +302,9 @@ auto compiler::emit_stmt_waittill(stmt_waittill const& stm) -> void
for (auto const& entry : stm.args->list)
{
if (entry->is<expr_undefined>())
emit_opcode(opcode::OP_SafeDecTop);
else
emit_opcode(opcode::OP_SafeSetWaittillVariableFieldCached, fmt::format("{}", variable_access(entry->as<expr_identifier>())));
}
@ -2003,13 +2006,16 @@ auto compiler::process_stmt_waittill(stmt_waittill const& stm) -> void
{
for (auto const& entry : stm.args->list)
{
if (!entry->is<expr_identifier>())
if (!entry->is<expr_identifier>() && !entry->is<expr_undefined>())
{
throw comp_error(entry->loc(), "illegal waittill param, must be a local variable");
throw comp_error(entry->loc(), "illegal waittill param, must be a local variable or undefined");
}
if (entry->is<expr_identifier>())
{
variable_register(entry->as<expr_identifier>());
}
}
}
auto compiler::process_stmt_if(stmt_if const& stm) -> void

View File

@ -192,6 +192,7 @@ auto decompiler::decompile_instruction(instruction const& inst, bool last) -> vo
break;
}
case opcode::OP_GetUndefined:
case opcode::OP_SafeDecTop:
{
stack_.push(expr_undefined::make(loc));
break;
@ -1118,7 +1119,6 @@ auto decompiler::decompile_instruction(instruction const& inst, bool last) -> vo
case opcode::OP_CheckClearParams:
case opcode::OP_CastFieldObject:
case opcode::OP_CastBool:
case opcode::OP_SafeDecTop:
break;
case opcode::OP_CreateLocalVariable:
case opcode::OP_RemoveLocalVariables: