From a23e072d9051c7724b8a1b26ffcd5088c3957775 Mon Sep 17 00:00:00 2001 From: xensik Date: Thu, 11 Nov 2021 20:12:19 +0100 Subject: [PATCH] fix waittillmatch operation --- src/h1/xsk/assembler.cpp | 4 ++-- src/h1/xsk/compiler.cpp | 6 +----- src/h1/xsk/decompiler.cpp | 4 +++- src/h1/xsk/disassembler.cpp | 4 ++-- src/h1/xsk/h1.cpp | 1 - src/h2/xsk/assembler.cpp | 4 ++-- src/h2/xsk/compiler.cpp | 6 +----- src/h2/xsk/decompiler.cpp | 4 +++- src/h2/xsk/disassembler.cpp | 4 ++-- src/h2/xsk/h2.cpp | 1 - src/iw5/xsk/assembler.cpp | 4 ++-- src/iw5/xsk/compiler.cpp | 2 +- src/iw5/xsk/decompiler.cpp | 4 +++- src/iw5/xsk/disassembler.cpp | 4 ++-- src/iw5/xsk/iw5.cpp | 1 - src/iw6/xsk/assembler.cpp | 4 ++-- src/iw6/xsk/compiler.cpp | 6 +----- src/iw6/xsk/decompiler.cpp | 4 +++- src/iw6/xsk/disassembler.cpp | 4 ++-- src/iw6/xsk/iw6.cpp | 1 - src/iw7/xsk/assembler.cpp | 4 ++-- src/iw7/xsk/compiler.cpp | 6 +----- src/iw7/xsk/decompiler.cpp | 4 +++- src/iw7/xsk/disassembler.cpp | 4 ++-- src/iw7/xsk/iw7.cpp | 1 - src/iw8/xsk/assembler.cpp | 4 ++-- src/iw8/xsk/compiler.cpp | 6 +----- src/iw8/xsk/decompiler.cpp | 4 +++- src/iw8/xsk/disassembler.cpp | 4 ++-- src/iw8/xsk/iw8.cpp | 1 - src/s1/xsk/assembler.cpp | 4 ++-- src/s1/xsk/compiler.cpp | 6 +----- src/s1/xsk/decompiler.cpp | 4 +++- src/s1/xsk/disassembler.cpp | 4 ++-- src/s1/xsk/s1.cpp | 1 - src/s2/xsk/assembler.cpp | 4 ++-- src/s2/xsk/compiler.cpp | 6 +----- src/s2/xsk/decompiler.cpp | 4 +++- src/s2/xsk/disassembler.cpp | 4 ++-- src/s2/xsk/s2.cpp | 1 - src/s4/xsk/assembler.cpp | 4 ++-- src/s4/xsk/compiler.cpp | 6 +----- src/s4/xsk/decompiler.cpp | 4 +++- src/s4/xsk/disassembler.cpp | 4 ++-- src/s4/xsk/s4.cpp | 1 - 45 files changed, 72 insertions(+), 95 deletions(-) diff --git a/src/h1/xsk/assembler.cpp b/src/h1/xsk/assembler.cpp index 6f212ba6..e26fcd43 100644 --- a/src/h1/xsk/assembler.cpp +++ b/src/h1/xsk/assembler.cpp @@ -214,7 +214,6 @@ void assembler::assemble_instruction(const gsc::instruction_ptr& inst) case opcode::OP_vector: case opcode::OP_bit_or: case opcode::OP_AddArray: - case opcode::OP_waittillmatch2: case opcode::OP_shift_right: script_->write(static_cast(inst->opcode)); break; @@ -262,7 +261,8 @@ void assembler::assemble_instruction(const gsc::instruction_ptr& inst) break; case opcode::OP_waittillmatch: script_->write(static_cast(inst->opcode)); - script_->write(0); + script_->write(static_cast(std::stoi(inst->data[0]))); + script_->write(static_cast(opcode::OP_waittillmatch2)); break; case opcode::OP_SetNewLocalVariableFieldCached0: case opcode::OP_EvalNewLocalArrayRefCached0: diff --git a/src/h1/xsk/compiler.cpp b/src/h1/xsk/compiler.cpp index a557dde0..222c607d 100644 --- a/src/h1/xsk/compiler.cpp +++ b/src/h1/xsk/compiler.cpp @@ -93,10 +93,6 @@ void compiler::compile_program(const gsc::program_ptr& program) { emit_define(def); } - -#ifdef DEBUG_GSC_COMPILER - print_debug_info(); -#endif } void compiler::emit_include(const gsc::include_ptr& include) @@ -302,7 +298,7 @@ void compiler::emit_stmt_waittillmatch(const gsc::context_ptr& ctx, const gsc::s emit_expr_arguments(ctx, stmt->args); emit_expr(ctx, stmt->expr); emit_expr(ctx, stmt->obj); - emit_opcode(ctx, opcode::OP_waittillmatch); + emit_opcode(ctx, opcode::OP_waittillmatch, utils::string::va("%d", stmt->args->list.size())); emit_opcode(ctx, opcode::OP_clearparams); } diff --git a/src/h1/xsk/decompiler.cpp b/src/h1/xsk/decompiler.cpp index 5769f0ec..b5274d1c 100644 --- a/src/h1/xsk/decompiler.cpp +++ b/src/h1/xsk/decompiler.cpp @@ -1452,7 +1452,9 @@ void decompiler::decompile_statements(const gsc::function_ptr& func) gsc::expr_arguments_ptr args = std::make_unique(); args->loc = loc; - while(stack_.size() > 0) + auto argnum = std::stoul(inst->data[0]); + + for (auto i = 0u; i < argnum; i++) { auto node = std::move(stack_.top()); stack_.pop(); diff --git a/src/h1/xsk/disassembler.cpp b/src/h1/xsk/disassembler.cpp index a105c2f7..329880ef 100644 --- a/src/h1/xsk/disassembler.cpp +++ b/src/h1/xsk/disassembler.cpp @@ -154,7 +154,6 @@ void disassembler::dissasemble_instruction(const gsc::instruction_ptr& inst) case opcode::OP_vector: case opcode::OP_bit_or: case opcode::OP_AddArray: - case opcode::OP_waittillmatch2: case opcode::OP_shift_right: break; case opcode::OP_GetByte: @@ -194,7 +193,8 @@ void disassembler::dissasemble_instruction(const gsc::instruction_ptr& inst) inst->data.push_back(utils::string::quote(stack_->read_c_string().data(), false)); break; case opcode::OP_waittillmatch: - inst->data.push_back(utils::string::va("%i", script_->read())); + inst->data.push_back(utils::string::va("%i", script_->read())); + script_->seek(1); break; case opcode::OP_SetNewLocalVariableFieldCached0: case opcode::OP_EvalNewLocalArrayRefCached0: diff --git a/src/h1/xsk/h1.cpp b/src/h1/xsk/h1.cpp index 9a29073d..91523b98 100644 --- a/src/h1/xsk/h1.cpp +++ b/src/h1/xsk/h1.cpp @@ -81,7 +81,6 @@ auto opcode_size(std::uint8_t id) -> std::uint32_t case opcode::OP_vector: case opcode::OP_bit_or: case opcode::OP_AddArray: - case opcode::OP_waittillmatch2: case opcode::OP_shift_right: return 1; case opcode::OP_SetNewLocalVariableFieldCached0: diff --git a/src/h2/xsk/assembler.cpp b/src/h2/xsk/assembler.cpp index 5a1683e5..544d08e1 100644 --- a/src/h2/xsk/assembler.cpp +++ b/src/h2/xsk/assembler.cpp @@ -214,7 +214,6 @@ void assembler::assemble_instruction(const gsc::instruction_ptr& inst) case opcode::OP_vector: case opcode::OP_bit_or: case opcode::OP_AddArray: - case opcode::OP_waittillmatch2: case opcode::OP_shift_right: script_->write(static_cast(inst->opcode)); break; @@ -262,7 +261,8 @@ void assembler::assemble_instruction(const gsc::instruction_ptr& inst) break; case opcode::OP_waittillmatch: script_->write(static_cast(inst->opcode)); - script_->write(0); + script_->write(static_cast(std::stoi(inst->data[0]))); + script_->write(static_cast(opcode::OP_waittillmatch2)); break; case opcode::OP_SetNewLocalVariableFieldCached0: case opcode::OP_EvalNewLocalArrayRefCached0: diff --git a/src/h2/xsk/compiler.cpp b/src/h2/xsk/compiler.cpp index 4e37bfd7..c4360ecc 100644 --- a/src/h2/xsk/compiler.cpp +++ b/src/h2/xsk/compiler.cpp @@ -93,10 +93,6 @@ void compiler::compile_program(const gsc::program_ptr& program) { emit_define(def); } - -#ifdef DEBUG_GSC_COMPILER - print_debug_info(); -#endif } void compiler::emit_include(const gsc::include_ptr& include) @@ -302,7 +298,7 @@ void compiler::emit_stmt_waittillmatch(const gsc::context_ptr& ctx, const gsc::s emit_expr_arguments(ctx, stmt->args); emit_expr(ctx, stmt->expr); emit_expr(ctx, stmt->obj); - emit_opcode(ctx, opcode::OP_waittillmatch); + emit_opcode(ctx, opcode::OP_waittillmatch, utils::string::va("%d", stmt->args->list.size())); emit_opcode(ctx, opcode::OP_clearparams); } diff --git a/src/h2/xsk/decompiler.cpp b/src/h2/xsk/decompiler.cpp index 8f7e49f2..67c10808 100644 --- a/src/h2/xsk/decompiler.cpp +++ b/src/h2/xsk/decompiler.cpp @@ -1452,7 +1452,9 @@ void decompiler::decompile_statements(const gsc::function_ptr& func) gsc::expr_arguments_ptr args = std::make_unique(); args->loc = loc; - while(stack_.size() > 0) + auto argnum = std::stoul(inst->data[0]); + + for (auto i = 0u; i < argnum; i++) { auto node = std::move(stack_.top()); stack_.pop(); diff --git a/src/h2/xsk/disassembler.cpp b/src/h2/xsk/disassembler.cpp index c004d3f3..3755d55c 100644 --- a/src/h2/xsk/disassembler.cpp +++ b/src/h2/xsk/disassembler.cpp @@ -154,7 +154,6 @@ void disassembler::dissasemble_instruction(const gsc::instruction_ptr& inst) case opcode::OP_vector: case opcode::OP_bit_or: case opcode::OP_AddArray: - case opcode::OP_waittillmatch2: case opcode::OP_shift_right: break; case opcode::OP_GetByte: @@ -194,7 +193,8 @@ void disassembler::dissasemble_instruction(const gsc::instruction_ptr& inst) inst->data.push_back(utils::string::quote(stack_->read_c_string().data(), false)); break; case opcode::OP_waittillmatch: - inst->data.push_back(utils::string::va("%i", script_->read())); + inst->data.push_back(utils::string::va("%i", script_->read())); + script_->seek(1); break; case opcode::OP_SetNewLocalVariableFieldCached0: case opcode::OP_EvalNewLocalArrayRefCached0: diff --git a/src/h2/xsk/h2.cpp b/src/h2/xsk/h2.cpp index 17cd9f92..bb02ca31 100644 --- a/src/h2/xsk/h2.cpp +++ b/src/h2/xsk/h2.cpp @@ -81,7 +81,6 @@ auto opcode_size(std::uint8_t id) -> std::uint32_t case opcode::OP_vector: case opcode::OP_bit_or: case opcode::OP_AddArray: - case opcode::OP_waittillmatch2: case opcode::OP_shift_right: return 1; case opcode::OP_SetNewLocalVariableFieldCached0: diff --git a/src/iw5/xsk/assembler.cpp b/src/iw5/xsk/assembler.cpp index a8ec44e7..826c5d3b 100644 --- a/src/iw5/xsk/assembler.cpp +++ b/src/iw5/xsk/assembler.cpp @@ -185,7 +185,6 @@ void assembler::assemble_instruction(const gsc::instruction_ptr& inst) case opcode::OP_less: case opcode::OP_greater: case opcode::OP_less_equal: - case opcode::OP_waittillmatch2: case opcode::OP_waittill: case opcode::OP_notify: case opcode::OP_endon: @@ -261,7 +260,8 @@ void assembler::assemble_instruction(const gsc::instruction_ptr& inst) break; case opcode::OP_waittillmatch: script_->write(static_cast(inst->opcode)); - script_->write(0); + script_->write(static_cast(std::stoi(inst->data[0]))); + script_->write(static_cast(opcode::OP_waittillmatch2)); break; case opcode::OP_CreateLocalVariable: case opcode::OP_RemoveLocalVariables: diff --git a/src/iw5/xsk/compiler.cpp b/src/iw5/xsk/compiler.cpp index 5073b387..f3f14664 100644 --- a/src/iw5/xsk/compiler.cpp +++ b/src/iw5/xsk/compiler.cpp @@ -305,7 +305,7 @@ void compiler::emit_stmt_waittillmatch(const gsc::context_ptr& ctx, const gsc::s emit_expr_arguments(ctx, stmt->args); emit_expr(ctx, stmt->expr); emit_expr(ctx, stmt->obj); - emit_opcode(ctx, opcode::OP_waittillmatch); + emit_opcode(ctx, opcode::OP_waittillmatch, utils::string::va("%d", stmt->args->list.size())); emit_opcode(ctx, opcode::OP_clearparams); } diff --git a/src/iw5/xsk/decompiler.cpp b/src/iw5/xsk/decompiler.cpp index ecce2c7f..97fd3b47 100644 --- a/src/iw5/xsk/decompiler.cpp +++ b/src/iw5/xsk/decompiler.cpp @@ -1446,7 +1446,9 @@ void decompiler::decompile_statements(const gsc::function_ptr& func) gsc::expr_arguments_ptr args = std::make_unique(); args->loc = loc; - while(stack_.size() > 0) + auto argnum = std::stoul(inst->data[0]); + + for (auto i = 0u; i < argnum; i++) { auto node = std::move(stack_.top()); stack_.pop(); diff --git a/src/iw5/xsk/disassembler.cpp b/src/iw5/xsk/disassembler.cpp index a16454b3..8f0aa9a4 100644 --- a/src/iw5/xsk/disassembler.cpp +++ b/src/iw5/xsk/disassembler.cpp @@ -122,7 +122,6 @@ void disassembler::dissasemble_instruction(const gsc::instruction_ptr& inst) case opcode::OP_less: case opcode::OP_greater: case opcode::OP_less_equal: - case opcode::OP_waittillmatch2: case opcode::OP_waittill: case opcode::OP_notify: case opcode::OP_endon: @@ -191,7 +190,8 @@ void disassembler::dissasemble_instruction(const gsc::instruction_ptr& inst) inst->data.push_back(utils::string::quote(stack_->read_c_string().data(), false)); break; case opcode::OP_waittillmatch: - inst->data.push_back(utils::string::va("%i", script_->read())); + inst->data.push_back(utils::string::va("%i", script_->read())); + script_->seek(1); break; case opcode::OP_CreateLocalVariable: case opcode::OP_RemoveLocalVariables: diff --git a/src/iw5/xsk/iw5.cpp b/src/iw5/xsk/iw5.cpp index f67a4344..35971e90 100644 --- a/src/iw5/xsk/iw5.cpp +++ b/src/iw5/xsk/iw5.cpp @@ -51,7 +51,6 @@ auto opcode_size(std::uint8_t id) -> std::uint32_t case opcode::OP_less: case opcode::OP_greater: case opcode::OP_less_equal: - case opcode::OP_waittillmatch2: case opcode::OP_waittill: case opcode::OP_notify: case opcode::OP_endon: diff --git a/src/iw6/xsk/assembler.cpp b/src/iw6/xsk/assembler.cpp index 715e6b2e..52cedc6e 100644 --- a/src/iw6/xsk/assembler.cpp +++ b/src/iw6/xsk/assembler.cpp @@ -213,7 +213,6 @@ void assembler::assemble_instruction(const gsc::instruction_ptr& inst) case opcode::OP_vector: case opcode::OP_bit_or: case opcode::OP_AddArray: - case opcode::OP_waittillmatch2: case opcode::OP_shift_right: script_->write(static_cast(inst->opcode)); break; @@ -261,7 +260,8 @@ void assembler::assemble_instruction(const gsc::instruction_ptr& inst) break; case opcode::OP_waittillmatch: script_->write(static_cast(inst->opcode)); - script_->write(0); + script_->write(static_cast(std::stoi(inst->data[0]))); + script_->write(static_cast(opcode::OP_waittillmatch2)); break; case opcode::OP_SetNewLocalVariableFieldCached0: case opcode::OP_EvalNewLocalArrayRefCached0: diff --git a/src/iw6/xsk/compiler.cpp b/src/iw6/xsk/compiler.cpp index 60304d3b..4b7dc762 100644 --- a/src/iw6/xsk/compiler.cpp +++ b/src/iw6/xsk/compiler.cpp @@ -93,10 +93,6 @@ void compiler::compile_program(const gsc::program_ptr& program) { emit_define(def); } - -#ifdef DEBUG_GSC_COMPILER - print_debug_info(); -#endif } void compiler::emit_include(const gsc::include_ptr& include) @@ -301,7 +297,7 @@ void compiler::emit_stmt_waittillmatch(const gsc::context_ptr& ctx, const gsc::s emit_expr_arguments(ctx, stmt->args); emit_expr(ctx, stmt->expr); emit_expr(ctx, stmt->obj); - emit_opcode(ctx, opcode::OP_waittillmatch); + emit_opcode(ctx, opcode::OP_waittillmatch, utils::string::va("%d", stmt->args->list.size())); emit_opcode(ctx, opcode::OP_clearparams); } diff --git a/src/iw6/xsk/decompiler.cpp b/src/iw6/xsk/decompiler.cpp index fbfe0cbd..a27db380 100644 --- a/src/iw6/xsk/decompiler.cpp +++ b/src/iw6/xsk/decompiler.cpp @@ -1446,7 +1446,9 @@ void decompiler::decompile_statements(const gsc::function_ptr& func) gsc::expr_arguments_ptr args = std::make_unique(); args->loc = loc; - while(stack_.size() > 0) + auto argnum = std::stoul(inst->data[0]); + + for (auto i = 0u; i < argnum; i++) { auto node = std::move(stack_.top()); stack_.pop(); diff --git a/src/iw6/xsk/disassembler.cpp b/src/iw6/xsk/disassembler.cpp index 0c02892d..e67699e9 100644 --- a/src/iw6/xsk/disassembler.cpp +++ b/src/iw6/xsk/disassembler.cpp @@ -152,7 +152,6 @@ void disassembler::dissasemble_instruction(const gsc::instruction_ptr& inst) case opcode::OP_vector: case opcode::OP_bit_or: case opcode::OP_AddArray: - case opcode::OP_waittillmatch2: case opcode::OP_shift_right: break; case opcode::OP_GetByte: @@ -192,7 +191,8 @@ void disassembler::dissasemble_instruction(const gsc::instruction_ptr& inst) inst->data.push_back(utils::string::quote(stack_->read_c_string().data(), false)); break; case opcode::OP_waittillmatch: - inst->data.push_back(utils::string::va("%i", script_->read())); + inst->data.push_back(utils::string::va("%i", script_->read())); + script_->seek(1); break; case opcode::OP_SetNewLocalVariableFieldCached0: case opcode::OP_EvalNewLocalArrayRefCached0: diff --git a/src/iw6/xsk/iw6.cpp b/src/iw6/xsk/iw6.cpp index bbd7ea41..c89bda41 100644 --- a/src/iw6/xsk/iw6.cpp +++ b/src/iw6/xsk/iw6.cpp @@ -80,7 +80,6 @@ auto opcode_size(std::uint8_t id) -> std::uint32_t case opcode::OP_vector: case opcode::OP_bit_or: case opcode::OP_AddArray: - case opcode::OP_waittillmatch2: case opcode::OP_shift_right: return 1; case opcode::OP_SetNewLocalVariableFieldCached0: diff --git a/src/iw7/xsk/assembler.cpp b/src/iw7/xsk/assembler.cpp index b6e853fd..529a81be 100644 --- a/src/iw7/xsk/assembler.cpp +++ b/src/iw7/xsk/assembler.cpp @@ -213,7 +213,6 @@ void assembler::assemble_instruction(const gsc::instruction_ptr& inst) case opcode::OP_vector: case opcode::OP_bit_or: case opcode::OP_AddArray: - case opcode::OP_waittillmatch2: case opcode::OP_shift_right: script_->write(static_cast(inst->opcode)); break; @@ -266,7 +265,8 @@ void assembler::assemble_instruction(const gsc::instruction_ptr& inst) break; case opcode::OP_waittillmatch: script_->write(static_cast(inst->opcode)); - script_->write(0); + script_->write(static_cast(std::stoi(inst->data[0]))); + script_->write(static_cast(opcode::OP_waittillmatch2)); break; case opcode::OP_SetNewLocalVariableFieldCached0: case opcode::OP_EvalNewLocalArrayRefCached0: diff --git a/src/iw7/xsk/compiler.cpp b/src/iw7/xsk/compiler.cpp index 1df9628e..dc3c2ca2 100644 --- a/src/iw7/xsk/compiler.cpp +++ b/src/iw7/xsk/compiler.cpp @@ -93,10 +93,6 @@ void compiler::compile_program(const gsc::program_ptr& program) { emit_define(def); } - -#ifdef DEBUG_GSC_COMPILER - print_debug_info(); -#endif } void compiler::emit_include(const gsc::include_ptr& include) @@ -301,7 +297,7 @@ void compiler::emit_stmt_waittillmatch(const gsc::context_ptr& ctx, const gsc::s emit_expr_arguments(ctx, stmt->args); emit_expr(ctx, stmt->expr); emit_expr(ctx, stmt->obj); - emit_opcode(ctx, opcode::OP_waittillmatch); + emit_opcode(ctx, opcode::OP_waittillmatch, utils::string::va("%d", stmt->args->list.size())); emit_opcode(ctx, opcode::OP_clearparams); } diff --git a/src/iw7/xsk/decompiler.cpp b/src/iw7/xsk/decompiler.cpp index fb78ec00..cdb31519 100644 --- a/src/iw7/xsk/decompiler.cpp +++ b/src/iw7/xsk/decompiler.cpp @@ -1446,7 +1446,9 @@ void decompiler::decompile_statements(const gsc::function_ptr& func) gsc::expr_arguments_ptr args = std::make_unique(); args->loc = loc; - while(stack_.size() > 0) + auto argnum = std::stoul(inst->data[0]); + + for (auto i = 0u; i < argnum; i++) { auto node = std::move(stack_.top()); stack_.pop(); diff --git a/src/iw7/xsk/disassembler.cpp b/src/iw7/xsk/disassembler.cpp index 70541199..ade3e572 100644 --- a/src/iw7/xsk/disassembler.cpp +++ b/src/iw7/xsk/disassembler.cpp @@ -152,7 +152,6 @@ void disassembler::dissasemble_instruction(const gsc::instruction_ptr& inst) case opcode::OP_vector: case opcode::OP_bit_or: case opcode::OP_AddArray: - case opcode::OP_waittillmatch2: case opcode::OP_shift_right: break; case opcode::OP_GetByte: @@ -192,7 +191,8 @@ void disassembler::dissasemble_instruction(const gsc::instruction_ptr& inst) inst->data.push_back(utils::string::quote(stack_->read_c_string().data(), false)); break; case opcode::OP_waittillmatch: - inst->data.push_back(utils::string::va("%i", script_->read())); + inst->data.push_back(utils::string::va("%i", script_->read())); + script_->seek(1); break; case opcode::OP_SetNewLocalVariableFieldCached0: case opcode::OP_EvalNewLocalArrayRefCached0: diff --git a/src/iw7/xsk/iw7.cpp b/src/iw7/xsk/iw7.cpp index ae5f4a77..d4aaec04 100644 --- a/src/iw7/xsk/iw7.cpp +++ b/src/iw7/xsk/iw7.cpp @@ -80,7 +80,6 @@ auto opcode_size(std::uint8_t id) -> std::uint32_t case opcode::OP_vector: case opcode::OP_bit_or: case opcode::OP_AddArray: - case opcode::OP_waittillmatch2: case opcode::OP_shift_right: return 1; case opcode::OP_SetNewLocalVariableFieldCached0: diff --git a/src/iw8/xsk/assembler.cpp b/src/iw8/xsk/assembler.cpp index b75f4da4..d0ad7772 100644 --- a/src/iw8/xsk/assembler.cpp +++ b/src/iw8/xsk/assembler.cpp @@ -182,7 +182,6 @@ void assembler::assemble_instruction(const gsc::instruction_ptr& inst) case opcode::OP_EvalLocalVariableCached5: case opcode::OP_ScriptMethodCallPointer: case opcode::OP_checkclearparams: - case opcode::OP_waittillmatch2: case opcode::OP_minus: case opcode::OP_greater_equal: case opcode::OP_vector: @@ -281,7 +280,8 @@ void assembler::assemble_instruction(const gsc::instruction_ptr& inst) break; case opcode::OP_waittillmatch: script_->write(static_cast(inst->opcode)); - script_->write(0); + script_->write(static_cast(std::stoi(inst->data[0]))); + script_->write(static_cast(opcode::OP_waittillmatch2)); break; case opcode::OP_SetNewLocalVariableFieldCached0: case opcode::OP_EvalNewLocalArrayRefCached0: diff --git a/src/iw8/xsk/compiler.cpp b/src/iw8/xsk/compiler.cpp index 712e5112..c6d168b8 100644 --- a/src/iw8/xsk/compiler.cpp +++ b/src/iw8/xsk/compiler.cpp @@ -93,10 +93,6 @@ void compiler::compile_program(const gsc::program_ptr& program) { emit_define(def); } - -#ifdef DEBUG_GSC_COMPILER - print_debug_info(); -#endif } void compiler::emit_include(const gsc::include_ptr& include) @@ -317,7 +313,7 @@ void compiler::emit_stmt_waittillmatch(const gsc::context_ptr& ctx, const gsc::s emit_expr_arguments(ctx, stmt->args); emit_expr(ctx, stmt->expr); emit_expr(ctx, stmt->obj); - emit_opcode(ctx, opcode::OP_waittillmatch); + emit_opcode(ctx, opcode::OP_waittillmatch, utils::string::va("%d", stmt->args->list.size())); emit_opcode(ctx, opcode::OP_clearparams); } diff --git a/src/iw8/xsk/decompiler.cpp b/src/iw8/xsk/decompiler.cpp index 728ffb18..65dd3dcf 100644 --- a/src/iw8/xsk/decompiler.cpp +++ b/src/iw8/xsk/decompiler.cpp @@ -1452,7 +1452,9 @@ void decompiler::decompile_statements(const gsc::function_ptr& func) gsc::expr_arguments_ptr args = std::make_unique(); args->loc = loc; - while(stack_.size() > 0) + auto argnum = std::stoul(inst->data[0]); + + for (auto i = 0u; i < argnum; i++) { auto node = std::move(stack_.top()); stack_.pop(); diff --git a/src/iw8/xsk/disassembler.cpp b/src/iw8/xsk/disassembler.cpp index 14763649..4784be97 100644 --- a/src/iw8/xsk/disassembler.cpp +++ b/src/iw8/xsk/disassembler.cpp @@ -121,7 +121,6 @@ void disassembler::dissasemble_instruction(const gsc::instruction_ptr& inst) case opcode::OP_EvalLocalVariableCached5: case opcode::OP_ScriptMethodCallPointer: case opcode::OP_checkclearparams: - case opcode::OP_waittillmatch2: case opcode::OP_minus: case opcode::OP_greater_equal: case opcode::OP_vector: @@ -205,7 +204,8 @@ void disassembler::dissasemble_instruction(const gsc::instruction_ptr& inst) inst->data.push_back(utils::string::quote(stack_->read_c_string().data(), false)); break; case opcode::OP_waittillmatch: - inst->data.push_back(utils::string::va("%i", script_->read())); + inst->data.push_back(utils::string::va("%i", script_->read())); + script_->seek(1); break; case opcode::OP_SetNewLocalVariableFieldCached0: case opcode::OP_EvalNewLocalArrayRefCached0: diff --git a/src/iw8/xsk/iw8.cpp b/src/iw8/xsk/iw8.cpp index f9141e91..be8d5429 100644 --- a/src/iw8/xsk/iw8.cpp +++ b/src/iw8/xsk/iw8.cpp @@ -49,7 +49,6 @@ auto opcode_size(std::uint8_t id) -> std::uint32_t case opcode::OP_EvalLocalVariableCached5: case opcode::OP_ScriptMethodCallPointer: case opcode::OP_checkclearparams: - case opcode::OP_waittillmatch2: case opcode::OP_minus: case opcode::OP_greater_equal: case opcode::OP_vector: diff --git a/src/s1/xsk/assembler.cpp b/src/s1/xsk/assembler.cpp index aae3dae0..3d22e75f 100644 --- a/src/s1/xsk/assembler.cpp +++ b/src/s1/xsk/assembler.cpp @@ -214,7 +214,6 @@ void assembler::assemble_instruction(const gsc::instruction_ptr& inst) case opcode::OP_vector: case opcode::OP_bit_or: case opcode::OP_AddArray: - case opcode::OP_waittillmatch2: case opcode::OP_shift_right: script_->write(static_cast(inst->opcode)); break; @@ -262,7 +261,8 @@ void assembler::assemble_instruction(const gsc::instruction_ptr& inst) break; case opcode::OP_waittillmatch: script_->write(static_cast(inst->opcode)); - script_->write(0); + script_->write(static_cast(std::stoi(inst->data[0]))); + script_->write(static_cast(opcode::OP_waittillmatch2)); break; case opcode::OP_SetNewLocalVariableFieldCached0: case opcode::OP_EvalNewLocalArrayRefCached0: diff --git a/src/s1/xsk/compiler.cpp b/src/s1/xsk/compiler.cpp index 1aa4d19e..5feab137 100644 --- a/src/s1/xsk/compiler.cpp +++ b/src/s1/xsk/compiler.cpp @@ -93,10 +93,6 @@ void compiler::compile_program(const gsc::program_ptr& program) { emit_define(def); } - -#ifdef DEBUG_GSC_COMPILER - print_debug_info(); -#endif } void compiler::emit_include(const gsc::include_ptr& include) @@ -302,7 +298,7 @@ void compiler::emit_stmt_waittillmatch(const gsc::context_ptr& ctx, const gsc::s emit_expr_arguments(ctx, stmt->args); emit_expr(ctx, stmt->expr); emit_expr(ctx, stmt->obj); - emit_opcode(ctx, opcode::OP_waittillmatch); + emit_opcode(ctx, opcode::OP_waittillmatch, utils::string::va("%d", stmt->args->list.size())); emit_opcode(ctx, opcode::OP_clearparams); } diff --git a/src/s1/xsk/decompiler.cpp b/src/s1/xsk/decompiler.cpp index f7c332fb..88529179 100644 --- a/src/s1/xsk/decompiler.cpp +++ b/src/s1/xsk/decompiler.cpp @@ -1452,7 +1452,9 @@ void decompiler::decompile_statements(const gsc::function_ptr& func) gsc::expr_arguments_ptr args = std::make_unique(); args->loc = loc; - while(stack_.size() > 0) + auto argnum = std::stoul(inst->data[0]); + + for (auto i = 0u; i < argnum; i++) { auto node = std::move(stack_.top()); stack_.pop(); diff --git a/src/s1/xsk/disassembler.cpp b/src/s1/xsk/disassembler.cpp index 7ef215a9..332a9c52 100644 --- a/src/s1/xsk/disassembler.cpp +++ b/src/s1/xsk/disassembler.cpp @@ -153,7 +153,6 @@ void disassembler::dissasemble_instruction(const gsc::instruction_ptr& inst) case opcode::OP_vector: case opcode::OP_bit_or: case opcode::OP_AddArray: - case opcode::OP_waittillmatch2: case opcode::OP_shift_right: break; case opcode::OP_GetByte: @@ -193,7 +192,8 @@ void disassembler::dissasemble_instruction(const gsc::instruction_ptr& inst) inst->data.push_back(utils::string::quote(stack_->read_c_string().data(), false)); break; case opcode::OP_waittillmatch: - inst->data.push_back(utils::string::va("%i", script_->read())); + inst->data.push_back(utils::string::va("%i", script_->read())); + script_->seek(1); break; case opcode::OP_SetNewLocalVariableFieldCached0: case opcode::OP_EvalNewLocalArrayRefCached0: diff --git a/src/s1/xsk/s1.cpp b/src/s1/xsk/s1.cpp index e423d7c6..d2f679ba 100644 --- a/src/s1/xsk/s1.cpp +++ b/src/s1/xsk/s1.cpp @@ -81,7 +81,6 @@ auto opcode_size(std::uint8_t id) -> std::uint32_t case opcode::OP_vector: case opcode::OP_bit_or: case opcode::OP_AddArray: - case opcode::OP_waittillmatch2: case opcode::OP_shift_right: return 1; case opcode::OP_SetNewLocalVariableFieldCached0: diff --git a/src/s2/xsk/assembler.cpp b/src/s2/xsk/assembler.cpp index ac4a540e..d7e56ee0 100644 --- a/src/s2/xsk/assembler.cpp +++ b/src/s2/xsk/assembler.cpp @@ -214,7 +214,6 @@ void assembler::assemble_instruction(const gsc::instruction_ptr& inst) case opcode::OP_vector: case opcode::OP_bit_or: case opcode::OP_AddArray: - case opcode::OP_waittillmatch2: case opcode::OP_shift_right: case opcode::OP_BoolNotAfterAnd: script_->write(static_cast(inst->opcode)); @@ -263,7 +262,8 @@ void assembler::assemble_instruction(const gsc::instruction_ptr& inst) break; case opcode::OP_waittillmatch: script_->write(static_cast(inst->opcode)); - script_->write(0); + script_->write(static_cast(std::stoi(inst->data[0]))); + script_->write(static_cast(opcode::OP_waittillmatch2)); break; case opcode::OP_SetNewLocalVariableFieldCached0: case opcode::OP_EvalNewLocalArrayRefCached0: diff --git a/src/s2/xsk/compiler.cpp b/src/s2/xsk/compiler.cpp index bb848707..118d6a2f 100644 --- a/src/s2/xsk/compiler.cpp +++ b/src/s2/xsk/compiler.cpp @@ -93,10 +93,6 @@ void compiler::compile_program(const gsc::program_ptr& program) { emit_define(def); } - -#ifdef DEBUG_GSC_COMPILER - print_debug_info(); -#endif } void compiler::emit_include(const gsc::include_ptr& include) @@ -302,7 +298,7 @@ void compiler::emit_stmt_waittillmatch(const gsc::context_ptr& ctx, const gsc::s emit_expr_arguments(ctx, stmt->args); emit_expr(ctx, stmt->expr); emit_expr(ctx, stmt->obj); - emit_opcode(ctx, opcode::OP_waittillmatch); + emit_opcode(ctx, opcode::OP_waittillmatch, utils::string::va("%d", stmt->args->list.size())); emit_opcode(ctx, opcode::OP_clearparams); } diff --git a/src/s2/xsk/decompiler.cpp b/src/s2/xsk/decompiler.cpp index c75e400c..5a4c6997 100644 --- a/src/s2/xsk/decompiler.cpp +++ b/src/s2/xsk/decompiler.cpp @@ -1452,7 +1452,9 @@ void decompiler::decompile_statements(const gsc::function_ptr& func) gsc::expr_arguments_ptr args = std::make_unique(); args->loc = loc; - while(stack_.size() > 0) + auto argnum = std::stoul(inst->data[0]); + + for (auto i = 0u; i < argnum; i++) { auto node = std::move(stack_.top()); stack_.pop(); diff --git a/src/s2/xsk/disassembler.cpp b/src/s2/xsk/disassembler.cpp index a785d064..b7569080 100644 --- a/src/s2/xsk/disassembler.cpp +++ b/src/s2/xsk/disassembler.cpp @@ -153,7 +153,6 @@ void disassembler::dissasemble_instruction(const gsc::instruction_ptr& inst) case opcode::OP_vector: case opcode::OP_bit_or: case opcode::OP_AddArray: - case opcode::OP_waittillmatch2: case opcode::OP_shift_right: case opcode::OP_BoolNotAfterAnd: break; @@ -194,7 +193,8 @@ void disassembler::dissasemble_instruction(const gsc::instruction_ptr& inst) inst->data.push_back(utils::string::quote(stack_->read_c_string().data(), false)); break; case opcode::OP_waittillmatch: - inst->data.push_back(utils::string::va("%i", script_->read())); + inst->data.push_back(utils::string::va("%i", script_->read())); + script_->seek(1); break; case opcode::OP_SetNewLocalVariableFieldCached0: case opcode::OP_EvalNewLocalArrayRefCached0: diff --git a/src/s2/xsk/s2.cpp b/src/s2/xsk/s2.cpp index c21306b9..188a141c 100644 --- a/src/s2/xsk/s2.cpp +++ b/src/s2/xsk/s2.cpp @@ -81,7 +81,6 @@ auto opcode_size(std::uint8_t id) -> std::uint32_t case opcode::OP_vector: case opcode::OP_bit_or: case opcode::OP_AddArray: - case opcode::OP_waittillmatch2: case opcode::OP_shift_right: case opcode::OP_BoolNotAfterAnd: return 1; diff --git a/src/s4/xsk/assembler.cpp b/src/s4/xsk/assembler.cpp index a2ad0eb1..6f1c8365 100644 --- a/src/s4/xsk/assembler.cpp +++ b/src/s4/xsk/assembler.cpp @@ -182,7 +182,6 @@ void assembler::assemble_instruction(const gsc::instruction_ptr& inst) case opcode::OP_EvalLocalVariableCached5: case opcode::OP_ScriptMethodCallPointer: case opcode::OP_checkclearparams: - case opcode::OP_waittillmatch2: case opcode::OP_minus: case opcode::OP_greater_equal: case opcode::OP_vector: @@ -281,7 +280,8 @@ void assembler::assemble_instruction(const gsc::instruction_ptr& inst) break; case opcode::OP_waittillmatch: script_->write(static_cast(inst->opcode)); - script_->write(0); + script_->write(static_cast(std::stoi(inst->data[0]))); + script_->write(static_cast(opcode::OP_waittillmatch2)); break; case opcode::OP_SetNewLocalVariableFieldCached0: case opcode::OP_EvalNewLocalArrayRefCached0: diff --git a/src/s4/xsk/compiler.cpp b/src/s4/xsk/compiler.cpp index 13c22deb..a668700f 100644 --- a/src/s4/xsk/compiler.cpp +++ b/src/s4/xsk/compiler.cpp @@ -93,10 +93,6 @@ void compiler::compile_program(const gsc::program_ptr& program) { emit_define(def); } - -#ifdef DEBUG_GSC_COMPILER - print_debug_info(); -#endif } void compiler::emit_include(const gsc::include_ptr& include) @@ -317,7 +313,7 @@ void compiler::emit_stmt_waittillmatch(const gsc::context_ptr& ctx, const gsc::s emit_expr_arguments(ctx, stmt->args); emit_expr(ctx, stmt->expr); emit_expr(ctx, stmt->obj); - emit_opcode(ctx, opcode::OP_waittillmatch); + emit_opcode(ctx, opcode::OP_waittillmatch, utils::string::va("%d", stmt->args->list.size())); emit_opcode(ctx, opcode::OP_clearparams); } diff --git a/src/s4/xsk/decompiler.cpp b/src/s4/xsk/decompiler.cpp index 5a041529..7de79000 100644 --- a/src/s4/xsk/decompiler.cpp +++ b/src/s4/xsk/decompiler.cpp @@ -1452,7 +1452,9 @@ void decompiler::decompile_statements(const gsc::function_ptr& func) gsc::expr_arguments_ptr args = std::make_unique(); args->loc = loc; - while(stack_.size() > 0) + auto argnum = std::stoul(inst->data[0]); + + for (auto i = 0u; i < argnum; i++) { auto node = std::move(stack_.top()); stack_.pop(); diff --git a/src/s4/xsk/disassembler.cpp b/src/s4/xsk/disassembler.cpp index a3ba6c62..6da5863e 100644 --- a/src/s4/xsk/disassembler.cpp +++ b/src/s4/xsk/disassembler.cpp @@ -121,7 +121,6 @@ void disassembler::dissasemble_instruction(const gsc::instruction_ptr& inst) case opcode::OP_EvalLocalVariableCached5: case opcode::OP_ScriptMethodCallPointer: case opcode::OP_checkclearparams: - case opcode::OP_waittillmatch2: case opcode::OP_minus: case opcode::OP_greater_equal: case opcode::OP_vector: @@ -205,7 +204,8 @@ void disassembler::dissasemble_instruction(const gsc::instruction_ptr& inst) inst->data.push_back(utils::string::quote(stack_->read_c_string().data(), false)); break; case opcode::OP_waittillmatch: - inst->data.push_back(utils::string::va("%i", script_->read())); + inst->data.push_back(utils::string::va("%i", script_->read())); + script_->seek(1); break; case opcode::OP_SetNewLocalVariableFieldCached0: case opcode::OP_EvalNewLocalArrayRefCached0: diff --git a/src/s4/xsk/s4.cpp b/src/s4/xsk/s4.cpp index 1467137d..c464ecd0 100644 --- a/src/s4/xsk/s4.cpp +++ b/src/s4/xsk/s4.cpp @@ -49,7 +49,6 @@ auto opcode_size(std::uint8_t id) -> std::uint32_t case opcode::OP_EvalLocalVariableCached5: case opcode::OP_ScriptMethodCallPointer: case opcode::OP_checkclearparams: - case opcode::OP_waittillmatch2: case opcode::OP_minus: case opcode::OP_greater_equal: case opcode::OP_vector: