From dbde03cc24c5158832488a7b38f37c89fb8e87de Mon Sep 17 00:00:00 2001 From: xensik Date: Tue, 22 Feb 2022 01:21:00 +0100 Subject: [PATCH] t6 waittillmatch and animations fixes --- src/t6/xsk/decompiler.cpp | 37 +++++++++++++++++----------------- src/t6/xsk/disassembler.cpp | 4 ++-- src/utils/xsk/arc/nodetree.cpp | 18 ++++++++--------- 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/src/t6/xsk/decompiler.cpp b/src/t6/xsk/decompiler.cpp index b87488e1..a9c2a718 100644 --- a/src/t6/xsk/decompiler.cpp +++ b/src/t6/xsk/decompiler.cpp @@ -215,35 +215,36 @@ void decompiler::decompile_instruction(const instruction::ptr& inst, bool last) break; case opcode::OP_GetAnimation: { - auto value = utils::string::unquote(inst->data[0]); + bool found = false; - if (value != "") + for (const auto& entry : program_->declarations) + { + if (entry == ast::kind::decl_usingtree) + { + if (entry.as_usingtree->name->value == inst->data[0]) + found = true; + else + found = false; + } + } + + if (!found) { auto tree = std::make_unique(loc, inst->data[0]); auto decl = std::make_unique(loc, std::move(tree)); program_->declarations.push_back(ast::decl(std::move(decl))); } - auto node = std::make_unique(loc, utils::string::unquote(inst->data[1])); + auto node = std::make_unique(loc, inst->data[1]); stack_.push(std::move(node)); } break; case opcode::OP_GetFunction: { - if (inst->data.size() == 1) - { - auto path = std::make_unique(loc); - auto name = std::make_unique(loc, inst->data[0]); - auto node = std::make_unique(loc, std::move(path), std::move(name)); - stack_.push(std::move(node)); - } - else - { - auto path = std::make_unique(loc, inst->data[0]); - auto name = std::make_unique(loc, inst->data[1]); - auto node = std::make_unique(loc, std::move(path), std::move(name)); - stack_.push(std::move(node)); - } + auto path = std::make_unique(loc, inst->data[0]); + auto name = std::make_unique(loc, inst->data[1]); + auto node = std::make_unique(loc, std::move(path), std::move(name)); + stack_.push(std::move(node)); } break; case opcode::OP_CreateLocalVariable: @@ -892,7 +893,7 @@ void decompiler::decompile_instruction(const instruction::ptr& inst, bool last) auto expr = ast::expr(std::move(stack_.top())); stack_.pop(); loc = expr.as_node->loc(); - for (auto i = std::stoul(inst->data[0]); i > 0; i++) + for (auto i = std::stoul(inst->data[0]); i > 0; i--) { auto node = std::move(stack_.top()); stack_.pop(); loc = node->loc(); diff --git a/src/t6/xsk/disassembler.cpp b/src/t6/xsk/disassembler.cpp index 35598999..6cef012b 100644 --- a/src/t6/xsk/disassembler.cpp +++ b/src/t6/xsk/disassembler.cpp @@ -462,7 +462,7 @@ void disassembler::disassemble_string(const instruction::ptr& inst) const auto& entry = string_refs_.at(script_->pos()); - inst->data.push_back(entry->type ? entry->name : utils::string::to_literal(entry->name)); + inst->data.push_back(entry->name); script_->seek(2); } @@ -573,7 +573,7 @@ void disassembler::disassemble_end_switch(const instruction::ptr& inst) { inst->data.push_back("case"); const auto& entry = string_refs_.at(script_->pos() - 2); - inst->data.push_back(utils::string::quote(entry->name, false)); + inst->data.push_back(entry->name); } else if (value == 0) { diff --git a/src/utils/xsk/arc/nodetree.cpp b/src/utils/xsk/arc/nodetree.cpp index 2b366b52..4705bd20 100644 --- a/src/utils/xsk/arc/nodetree.cpp +++ b/src/utils/xsk/arc/nodetree.cpp @@ -565,12 +565,12 @@ auto expr_hash::print() const -> std::string auto expr_string::print() const -> std::string { - return value; + return utils::string::to_literal(value); } auto expr_istring::print() const -> std::string { - return "&"s += value; + return "&"s += utils::string::to_literal(value); } auto expr_path::print() const -> std::string @@ -1365,12 +1365,12 @@ auto decl_usingtree::print() const -> std::string auto decl_dev_begin::print() const -> std::string { - return "/#"; + return "/#\n"; } auto decl_dev_end::print() const -> std::string { - return "#/"; + return "#/\n"; } auto include::print() const -> std::string @@ -1387,14 +1387,14 @@ auto program::print() const -> std::string data += include->print(); } + data += "\n"; + for (const auto& entry : declarations) { - if (entry == kind::decl_thread) - { - data += "\n"; - } - data += entry.print(); + + if (&entry != &declarations.back()) + data += "\n"; } return data;