Skip to content

Commit

Permalink
feat(arc): waittill undefined param (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
xensik committed Sep 24, 2023
1 parent 008d545 commit 4721aca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions src/arc/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,10 @@ auto compiler::emit_stmt_waittill(stmt_waittill const& stm) -> void

for (auto const& entry : stm.args->list)
{
emit_opcode(opcode::OP_SafeSetWaittillVariableFieldCached, fmt::format("{}", variable_access(entry->as<expr_identifier>())));
if (entry->is<expr_undefined>())
emit_opcode(opcode::OP_SafeDecTop);
else
emit_opcode(opcode::OP_SafeSetWaittillVariableFieldCached, fmt::format("{}", variable_access(entry->as<expr_identifier>())));
}

emit_opcode(opcode::OP_ClearParams);
Expand Down Expand Up @@ -2003,12 +2006,15 @@ 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");
}

variable_register(entry->as<expr_identifier>());
if (entry->is<expr_identifier>())
{
variable_register(entry->as<expr_identifier>());
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/arc/decompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 4721aca

Please sign in to comment.