t6 waittillmatch and animations fixes

This commit is contained in:
xensik 2022-02-22 01:21:00 +01:00
parent 5504bef189
commit dbde03cc24
3 changed files with 30 additions and 29 deletions

View File

@ -215,36 +215,37 @@ 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<ast::expr_string>(loc, inst->data[0]);
auto decl = std::make_unique<ast::decl_usingtree>(loc, std::move(tree));
program_->declarations.push_back(ast::decl(std::move(decl)));
}
auto node = std::make_unique<ast::expr_animation>(loc, utils::string::unquote(inst->data[1]));
auto node = std::make_unique<ast::expr_animation>(loc, inst->data[1]);
stack_.push(std::move(node));
}
break;
case opcode::OP_GetFunction:
{
if (inst->data.size() == 1)
{
auto path = std::make_unique<ast::expr_path>(loc);
auto name = std::make_unique<ast::expr_identifier>(loc, inst->data[0]);
auto node = std::make_unique<ast::expr_reference>(loc, std::move(path), std::move(name));
stack_.push(std::move(node));
}
else
{
auto path = std::make_unique<ast::expr_path>(loc, inst->data[0]);
auto name = std::make_unique<ast::expr_identifier>(loc, inst->data[1]);
auto node = std::make_unique<ast::expr_reference>(loc, std::move(path), std::move(name));
stack_.push(std::move(node));
}
}
break;
case opcode::OP_CreateLocalVariable:
throw decomp_error("unhandled opcode " + resolver::opcode_name(inst->opcode));
@ -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();

View File

@ -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)
{

View File

@ -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;