decompiler assign ops implementation
This commit is contained in:
parent
7ce2add85b
commit
302e8ab0b1
@ -546,7 +546,6 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
|
||||
break;
|
||||
case opcode::OP_ScriptLocalMethodChildThreadCall:
|
||||
{
|
||||
// TODO: child things...
|
||||
auto obj = gsc::expr_ptr(std::move(stack_.top()));
|
||||
stack_.pop();
|
||||
loc = obj.as_node->loc;
|
||||
@ -1395,7 +1394,6 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
|
||||
stack_.pop();
|
||||
args->loc = node->loc;
|
||||
args->list.push_back(std::move(node));
|
||||
|
||||
}
|
||||
loc = args->loc;
|
||||
|
||||
@ -1425,9 +1423,6 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
|
||||
}
|
||||
break;
|
||||
case opcode::OP_checkclearparams:
|
||||
{
|
||||
// no needed
|
||||
}
|
||||
break;
|
||||
case opcode::OP_notify:
|
||||
{
|
||||
@ -1736,9 +1731,6 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
|
||||
break;
|
||||
case opcode::OP_CastFieldObject:
|
||||
case opcode::OP_CastBool:
|
||||
{
|
||||
//continue;
|
||||
}
|
||||
break;
|
||||
case opcode::OP_BoolNot:
|
||||
{
|
||||
@ -1780,7 +1772,6 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
|
||||
{
|
||||
auto expr = std::make_unique<gsc::node_asm_jump>(loc, inst->data[0]);
|
||||
func_->block->stmts.push_back(gsc::stmt_ptr(std::move(expr)));
|
||||
|
||||
}
|
||||
break;
|
||||
case opcode::OP_jumpback:
|
||||
@ -1871,20 +1862,6 @@ void decompiler::decompile_block(const gsc::stmt_list_ptr& block)
|
||||
this->decompile_search_switch(block);
|
||||
this->decompile_search_ifelse(block);
|
||||
this->decompile_break_continue(block);
|
||||
this->decompile_nulls(block);
|
||||
}
|
||||
|
||||
void decompiler::decompile_nulls(const gsc::stmt_list_ptr& block)
|
||||
{
|
||||
auto index = 0;
|
||||
while(index < block->stmts.size())
|
||||
{
|
||||
if(block->stmts.at(index).as_node->type == gsc::node_t::null)
|
||||
{
|
||||
block->stmts.erase(block->stmts.begin() + index);
|
||||
}
|
||||
else index++;
|
||||
}
|
||||
}
|
||||
|
||||
void decompiler::decompile_search_infinite(const gsc::stmt_list_ptr& block)
|
||||
@ -2991,7 +2968,7 @@ void decompiler::process_expr(const gsc::context_ptr& ctx, gsc::expr_ptr& expr)
|
||||
}
|
||||
}
|
||||
|
||||
void decompiler::process_expr_assign(const gsc::context_ptr& ctx, const gsc::expr_assign_ptr& expr)
|
||||
void decompiler::process_expr_assign(const gsc::context_ptr& ctx, gsc::expr_assign_ptr& expr)
|
||||
{
|
||||
if(expr->type == gsc::node_t::expr_increment)
|
||||
{
|
||||
@ -3005,6 +2982,55 @@ void decompiler::process_expr_assign(const gsc::context_ptr& ctx, const gsc::exp
|
||||
{
|
||||
process_expr(ctx, expr->rvalue);
|
||||
process_expr(ctx, expr->lvalue);
|
||||
|
||||
if(expr->type == gsc::node_t::expr_assign_equal)
|
||||
{
|
||||
switch(expr->rvalue.as_node->type)
|
||||
{
|
||||
case gsc::node_t::expr_bitwise_or:
|
||||
if(expr->lvalue == expr->rvalue.as_bitwise_or->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_bitwise_or>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_bitwise_and:
|
||||
if(expr->lvalue == expr->rvalue.as_bitwise_and->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_bitwise_and>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_bitwise_exor:
|
||||
if(expr->lvalue == expr->rvalue.as_bitwise_exor->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_bitwise_exor>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_shift_left:
|
||||
if(expr->lvalue == expr->rvalue.as_shift_left->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_shift_left>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_shift_right:
|
||||
if(expr->lvalue == expr->rvalue.as_shift_right->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_shift_right>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_add:
|
||||
if(expr->lvalue == expr->rvalue.as_add->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_add>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_sub:
|
||||
if(expr->lvalue == expr->rvalue.as_sub->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_sub>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_mult:
|
||||
if(expr->lvalue == expr->rvalue.as_mult->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_mult>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_div:
|
||||
if(expr->lvalue == expr->rvalue.as_div->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_div>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_mod:
|
||||
if(expr->lvalue == expr->rvalue.as_mod->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_mod>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ private:
|
||||
void process_stmt_break(const gsc::context_ptr& ctx, const gsc::stmt_break_ptr& stmt);
|
||||
void process_stmt_return(const gsc::context_ptr& ctx, const gsc::stmt_return_ptr& stmt);
|
||||
void process_expr(const gsc::context_ptr& ctx, gsc::expr_ptr& expr);
|
||||
void process_expr_assign(const gsc::context_ptr& ctx, const gsc::expr_assign_ptr& expr);
|
||||
void process_expr_assign(const gsc::context_ptr& ctx, gsc::expr_assign_ptr& expr);
|
||||
void process_expr_binary(const gsc::context_ptr& ctx, const gsc::expr_binary_ptr& expr);
|
||||
void process_expr_and(const gsc::context_ptr& ctx, const gsc::expr_and_ptr& expr);
|
||||
void process_expr_or(const gsc::context_ptr& ctx, const gsc::expr_or_ptr& expr);
|
||||
|
@ -546,7 +546,6 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
|
||||
break;
|
||||
case opcode::OP_ScriptLocalMethodChildThreadCall:
|
||||
{
|
||||
// TODO: child things...
|
||||
auto obj = gsc::expr_ptr(std::move(stack_.top()));
|
||||
stack_.pop();
|
||||
loc = obj.as_node->loc;
|
||||
@ -1395,7 +1394,6 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
|
||||
stack_.pop();
|
||||
args->loc = node->loc;
|
||||
args->list.push_back(std::move(node));
|
||||
|
||||
}
|
||||
loc = args->loc;
|
||||
|
||||
@ -1425,9 +1423,6 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
|
||||
}
|
||||
break;
|
||||
case opcode::OP_checkclearparams:
|
||||
{
|
||||
// no needed
|
||||
}
|
||||
break;
|
||||
case opcode::OP_notify:
|
||||
{
|
||||
@ -1736,9 +1731,6 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
|
||||
break;
|
||||
case opcode::OP_CastFieldObject:
|
||||
case opcode::OP_CastBool:
|
||||
{
|
||||
//continue;
|
||||
}
|
||||
break;
|
||||
case opcode::OP_BoolNot:
|
||||
{
|
||||
@ -1780,7 +1772,6 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
|
||||
{
|
||||
auto expr = std::make_unique<gsc::node_asm_jump>(loc, inst->data[0]);
|
||||
func_->block->stmts.push_back(gsc::stmt_ptr(std::move(expr)));
|
||||
|
||||
}
|
||||
break;
|
||||
case opcode::OP_jumpback:
|
||||
@ -1871,20 +1862,6 @@ void decompiler::decompile_block(const gsc::stmt_list_ptr& block)
|
||||
this->decompile_search_switch(block);
|
||||
this->decompile_search_ifelse(block);
|
||||
this->decompile_break_continue(block);
|
||||
this->decompile_nulls(block);
|
||||
}
|
||||
|
||||
void decompiler::decompile_nulls(const gsc::stmt_list_ptr& block)
|
||||
{
|
||||
auto index = 0;
|
||||
while(index < block->stmts.size())
|
||||
{
|
||||
if(block->stmts.at(index).as_node->type == gsc::node_t::null)
|
||||
{
|
||||
block->stmts.erase(block->stmts.begin() + index);
|
||||
}
|
||||
else index++;
|
||||
}
|
||||
}
|
||||
|
||||
void decompiler::decompile_search_infinite(const gsc::stmt_list_ptr& block)
|
||||
@ -2991,7 +2968,7 @@ void decompiler::process_expr(const gsc::context_ptr& ctx, gsc::expr_ptr& expr)
|
||||
}
|
||||
}
|
||||
|
||||
void decompiler::process_expr_assign(const gsc::context_ptr& ctx, const gsc::expr_assign_ptr& expr)
|
||||
void decompiler::process_expr_assign(const gsc::context_ptr& ctx, gsc::expr_assign_ptr& expr)
|
||||
{
|
||||
if(expr->type == gsc::node_t::expr_increment)
|
||||
{
|
||||
@ -3005,6 +2982,55 @@ void decompiler::process_expr_assign(const gsc::context_ptr& ctx, const gsc::exp
|
||||
{
|
||||
process_expr(ctx, expr->rvalue);
|
||||
process_expr(ctx, expr->lvalue);
|
||||
|
||||
if(expr->type == gsc::node_t::expr_assign_equal)
|
||||
{
|
||||
switch(expr->rvalue.as_node->type)
|
||||
{
|
||||
case gsc::node_t::expr_bitwise_or:
|
||||
if(expr->lvalue == expr->rvalue.as_bitwise_or->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_bitwise_or>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_bitwise_and:
|
||||
if(expr->lvalue == expr->rvalue.as_bitwise_and->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_bitwise_and>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_bitwise_exor:
|
||||
if(expr->lvalue == expr->rvalue.as_bitwise_exor->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_bitwise_exor>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_shift_left:
|
||||
if(expr->lvalue == expr->rvalue.as_shift_left->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_shift_left>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_shift_right:
|
||||
if(expr->lvalue == expr->rvalue.as_shift_right->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_shift_right>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_add:
|
||||
if(expr->lvalue == expr->rvalue.as_add->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_add>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_sub:
|
||||
if(expr->lvalue == expr->rvalue.as_sub->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_sub>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_mult:
|
||||
if(expr->lvalue == expr->rvalue.as_mult->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_mult>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_div:
|
||||
if(expr->lvalue == expr->rvalue.as_div->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_div>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_mod:
|
||||
if(expr->lvalue == expr->rvalue.as_mod->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_mod>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ private:
|
||||
void process_stmt_break(const gsc::context_ptr& ctx, const gsc::stmt_break_ptr& stmt);
|
||||
void process_stmt_return(const gsc::context_ptr& ctx, const gsc::stmt_return_ptr& stmt);
|
||||
void process_expr(const gsc::context_ptr& ctx, gsc::expr_ptr& expr);
|
||||
void process_expr_assign(const gsc::context_ptr& ctx, const gsc::expr_assign_ptr& expr);
|
||||
void process_expr_assign(const gsc::context_ptr& ctx, gsc::expr_assign_ptr& expr);
|
||||
void process_expr_binary(const gsc::context_ptr& ctx, const gsc::expr_binary_ptr& expr);
|
||||
void process_expr_and(const gsc::context_ptr& ctx, const gsc::expr_and_ptr& expr);
|
||||
void process_expr_or(const gsc::context_ptr& ctx, const gsc::expr_or_ptr& expr);
|
||||
|
@ -546,7 +546,6 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
|
||||
break;
|
||||
case opcode::OP_ScriptLocalMethodChildThreadCall:
|
||||
{
|
||||
// TODO: child things...
|
||||
auto obj = gsc::expr_ptr(std::move(stack_.top()));
|
||||
stack_.pop();
|
||||
loc = obj.as_node->loc;
|
||||
@ -1389,7 +1388,6 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
|
||||
stack_.pop();
|
||||
args->loc = node->loc;
|
||||
args->list.push_back(std::move(node));
|
||||
|
||||
}
|
||||
loc = args->loc;
|
||||
|
||||
@ -1419,9 +1417,6 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
|
||||
}
|
||||
break;
|
||||
case opcode::OP_checkclearparams:
|
||||
{
|
||||
// no needed
|
||||
}
|
||||
break;
|
||||
case opcode::OP_notify:
|
||||
{
|
||||
@ -1730,9 +1725,6 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
|
||||
break;
|
||||
case opcode::OP_CastFieldObject:
|
||||
case opcode::OP_CastBool:
|
||||
{
|
||||
//continue;
|
||||
}
|
||||
break;
|
||||
case opcode::OP_BoolNot:
|
||||
{
|
||||
@ -1774,7 +1766,6 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
|
||||
{
|
||||
auto expr = std::make_unique<gsc::node_asm_jump>(loc, inst->data[0]);
|
||||
func_->block->stmts.push_back(gsc::stmt_ptr(std::move(expr)));
|
||||
|
||||
}
|
||||
break;
|
||||
case opcode::OP_jumpback:
|
||||
@ -1865,20 +1856,6 @@ void decompiler::decompile_block(const gsc::stmt_list_ptr& block)
|
||||
this->decompile_search_switch(block);
|
||||
this->decompile_search_ifelse(block);
|
||||
this->decompile_break_continue(block);
|
||||
this->decompile_nulls(block);
|
||||
}
|
||||
|
||||
void decompiler::decompile_nulls(const gsc::stmt_list_ptr& block)
|
||||
{
|
||||
auto index = 0;
|
||||
while(index < block->stmts.size())
|
||||
{
|
||||
if(block->stmts.at(index).as_node->type == gsc::node_t::null)
|
||||
{
|
||||
block->stmts.erase(block->stmts.begin() + index);
|
||||
}
|
||||
else index++;
|
||||
}
|
||||
}
|
||||
|
||||
void decompiler::decompile_search_infinite(const gsc::stmt_list_ptr& block)
|
||||
@ -2985,7 +2962,7 @@ void decompiler::process_expr(const gsc::context_ptr& ctx, gsc::expr_ptr& expr)
|
||||
}
|
||||
}
|
||||
|
||||
void decompiler::process_expr_assign(const gsc::context_ptr& ctx, const gsc::expr_assign_ptr& expr)
|
||||
void decompiler::process_expr_assign(const gsc::context_ptr& ctx, gsc::expr_assign_ptr& expr)
|
||||
{
|
||||
if(expr->type == gsc::node_t::expr_increment)
|
||||
{
|
||||
@ -2999,6 +2976,55 @@ void decompiler::process_expr_assign(const gsc::context_ptr& ctx, const gsc::exp
|
||||
{
|
||||
process_expr(ctx, expr->rvalue);
|
||||
process_expr(ctx, expr->lvalue);
|
||||
|
||||
if(expr->type == gsc::node_t::expr_assign_equal)
|
||||
{
|
||||
switch(expr->rvalue.as_node->type)
|
||||
{
|
||||
case gsc::node_t::expr_bitwise_or:
|
||||
if(expr->lvalue == expr->rvalue.as_bitwise_or->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_bitwise_or>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_bitwise_and:
|
||||
if(expr->lvalue == expr->rvalue.as_bitwise_and->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_bitwise_and>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_bitwise_exor:
|
||||
if(expr->lvalue == expr->rvalue.as_bitwise_exor->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_bitwise_exor>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_shift_left:
|
||||
if(expr->lvalue == expr->rvalue.as_shift_left->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_shift_left>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_shift_right:
|
||||
if(expr->lvalue == expr->rvalue.as_shift_right->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_shift_right>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_add:
|
||||
if(expr->lvalue == expr->rvalue.as_add->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_add>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_sub:
|
||||
if(expr->lvalue == expr->rvalue.as_sub->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_sub>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_mult:
|
||||
if(expr->lvalue == expr->rvalue.as_mult->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_mult>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_div:
|
||||
if(expr->lvalue == expr->rvalue.as_div->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_div>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_mod:
|
||||
if(expr->lvalue == expr->rvalue.as_mod->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_mod>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ private:
|
||||
void process_stmt_break(const gsc::context_ptr& ctx, const gsc::stmt_break_ptr& stmt);
|
||||
void process_stmt_return(const gsc::context_ptr& ctx, const gsc::stmt_return_ptr& stmt);
|
||||
void process_expr(const gsc::context_ptr& ctx, gsc::expr_ptr& expr);
|
||||
void process_expr_assign(const gsc::context_ptr& ctx, const gsc::expr_assign_ptr& expr);
|
||||
void process_expr_assign(const gsc::context_ptr& ctx, gsc::expr_assign_ptr& expr);
|
||||
void process_expr_binary(const gsc::context_ptr& ctx, const gsc::expr_binary_ptr& expr);
|
||||
void process_expr_and(const gsc::context_ptr& ctx, const gsc::expr_and_ptr& expr);
|
||||
void process_expr_or(const gsc::context_ptr& ctx, const gsc::expr_or_ptr& expr);
|
||||
|
@ -546,7 +546,6 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
|
||||
break;
|
||||
case opcode::OP_ScriptLocalMethodChildThreadCall:
|
||||
{
|
||||
// TODO: child things...
|
||||
auto obj = gsc::expr_ptr(std::move(stack_.top()));
|
||||
stack_.pop();
|
||||
loc = obj.as_node->loc;
|
||||
@ -1389,7 +1388,6 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
|
||||
stack_.pop();
|
||||
args->loc = node->loc;
|
||||
args->list.push_back(std::move(node));
|
||||
|
||||
}
|
||||
loc = args->loc;
|
||||
|
||||
@ -1419,9 +1417,6 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
|
||||
}
|
||||
break;
|
||||
case opcode::OP_checkclearparams:
|
||||
{
|
||||
// no needed
|
||||
}
|
||||
break;
|
||||
case opcode::OP_notify:
|
||||
{
|
||||
@ -1730,9 +1725,6 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
|
||||
break;
|
||||
case opcode::OP_CastFieldObject:
|
||||
case opcode::OP_CastBool:
|
||||
{
|
||||
//continue;
|
||||
}
|
||||
break;
|
||||
case opcode::OP_BoolNot:
|
||||
{
|
||||
@ -1774,7 +1766,6 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
|
||||
{
|
||||
auto expr = std::make_unique<gsc::node_asm_jump>(loc, inst->data[0]);
|
||||
func_->block->stmts.push_back(gsc::stmt_ptr(std::move(expr)));
|
||||
|
||||
}
|
||||
break;
|
||||
case opcode::OP_jumpback:
|
||||
@ -1865,20 +1856,6 @@ void decompiler::decompile_block(const gsc::stmt_list_ptr& block)
|
||||
this->decompile_search_switch(block);
|
||||
this->decompile_search_ifelse(block);
|
||||
this->decompile_break_continue(block);
|
||||
this->decompile_nulls(block);
|
||||
}
|
||||
|
||||
void decompiler::decompile_nulls(const gsc::stmt_list_ptr& block)
|
||||
{
|
||||
auto index = 0;
|
||||
while(index < block->stmts.size())
|
||||
{
|
||||
if(block->stmts.at(index).as_node->type == gsc::node_t::null)
|
||||
{
|
||||
block->stmts.erase(block->stmts.begin() + index);
|
||||
}
|
||||
else index++;
|
||||
}
|
||||
}
|
||||
|
||||
void decompiler::decompile_search_infinite(const gsc::stmt_list_ptr& block)
|
||||
@ -2985,7 +2962,7 @@ void decompiler::process_expr(const gsc::context_ptr& ctx, gsc::expr_ptr& expr)
|
||||
}
|
||||
}
|
||||
|
||||
void decompiler::process_expr_assign(const gsc::context_ptr& ctx, const gsc::expr_assign_ptr& expr)
|
||||
void decompiler::process_expr_assign(const gsc::context_ptr& ctx, gsc::expr_assign_ptr& expr)
|
||||
{
|
||||
if(expr->type == gsc::node_t::expr_increment)
|
||||
{
|
||||
@ -2999,6 +2976,55 @@ void decompiler::process_expr_assign(const gsc::context_ptr& ctx, const gsc::exp
|
||||
{
|
||||
process_expr(ctx, expr->rvalue);
|
||||
process_expr(ctx, expr->lvalue);
|
||||
|
||||
if(expr->type == gsc::node_t::expr_assign_equal)
|
||||
{
|
||||
switch(expr->rvalue.as_node->type)
|
||||
{
|
||||
case gsc::node_t::expr_bitwise_or:
|
||||
if(expr->lvalue == expr->rvalue.as_bitwise_or->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_bitwise_or>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_bitwise_and:
|
||||
if(expr->lvalue == expr->rvalue.as_bitwise_and->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_bitwise_and>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_bitwise_exor:
|
||||
if(expr->lvalue == expr->rvalue.as_bitwise_exor->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_bitwise_exor>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_shift_left:
|
||||
if(expr->lvalue == expr->rvalue.as_shift_left->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_shift_left>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_shift_right:
|
||||
if(expr->lvalue == expr->rvalue.as_shift_right->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_shift_right>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_add:
|
||||
if(expr->lvalue == expr->rvalue.as_add->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_add>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_sub:
|
||||
if(expr->lvalue == expr->rvalue.as_sub->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_sub>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_mult:
|
||||
if(expr->lvalue == expr->rvalue.as_mult->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_mult>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_div:
|
||||
if(expr->lvalue == expr->rvalue.as_div->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_div>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_mod:
|
||||
if(expr->lvalue == expr->rvalue.as_mod->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_mod>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ private:
|
||||
void process_stmt_break(const gsc::context_ptr& ctx, const gsc::stmt_break_ptr& stmt);
|
||||
void process_stmt_return(const gsc::context_ptr& ctx, const gsc::stmt_return_ptr& stmt);
|
||||
void process_expr(const gsc::context_ptr& ctx, gsc::expr_ptr& expr);
|
||||
void process_expr_assign(const gsc::context_ptr& ctx, const gsc::expr_assign_ptr& expr);
|
||||
void process_expr_assign(const gsc::context_ptr& ctx, gsc::expr_assign_ptr& expr);
|
||||
void process_expr_binary(const gsc::context_ptr& ctx, const gsc::expr_binary_ptr& expr);
|
||||
void process_expr_and(const gsc::context_ptr& ctx, const gsc::expr_and_ptr& expr);
|
||||
void process_expr_or(const gsc::context_ptr& ctx, const gsc::expr_or_ptr& expr);
|
||||
|
@ -546,7 +546,6 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
|
||||
break;
|
||||
case opcode::OP_ScriptLocalMethodChildThreadCall:
|
||||
{
|
||||
// TODO: child things...
|
||||
auto obj = gsc::expr_ptr(std::move(stack_.top()));
|
||||
stack_.pop();
|
||||
loc = obj.as_node->loc;
|
||||
@ -1389,7 +1388,6 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
|
||||
stack_.pop();
|
||||
args->loc = node->loc;
|
||||
args->list.push_back(std::move(node));
|
||||
|
||||
}
|
||||
loc = args->loc;
|
||||
|
||||
@ -1419,9 +1417,6 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
|
||||
}
|
||||
break;
|
||||
case opcode::OP_checkclearparams:
|
||||
{
|
||||
// no needed
|
||||
}
|
||||
break;
|
||||
case opcode::OP_notify:
|
||||
{
|
||||
@ -1730,9 +1725,6 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
|
||||
break;
|
||||
case opcode::OP_CastFieldObject:
|
||||
case opcode::OP_CastBool:
|
||||
{
|
||||
//continue;
|
||||
}
|
||||
break;
|
||||
case opcode::OP_BoolNot:
|
||||
{
|
||||
@ -1774,7 +1766,6 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
|
||||
{
|
||||
auto expr = std::make_unique<gsc::node_asm_jump>(loc, inst->data[0]);
|
||||
func_->block->stmts.push_back(gsc::stmt_ptr(std::move(expr)));
|
||||
|
||||
}
|
||||
break;
|
||||
case opcode::OP_jumpback:
|
||||
@ -1865,20 +1856,6 @@ void decompiler::decompile_block(const gsc::stmt_list_ptr& block)
|
||||
this->decompile_search_switch(block);
|
||||
this->decompile_search_ifelse(block);
|
||||
this->decompile_break_continue(block);
|
||||
this->decompile_nulls(block);
|
||||
}
|
||||
|
||||
void decompiler::decompile_nulls(const gsc::stmt_list_ptr& block)
|
||||
{
|
||||
auto index = 0;
|
||||
while(index < block->stmts.size())
|
||||
{
|
||||
if(block->stmts.at(index).as_node->type == gsc::node_t::null)
|
||||
{
|
||||
block->stmts.erase(block->stmts.begin() + index);
|
||||
}
|
||||
else index++;
|
||||
}
|
||||
}
|
||||
|
||||
void decompiler::decompile_search_infinite(const gsc::stmt_list_ptr& block)
|
||||
@ -2985,7 +2962,7 @@ void decompiler::process_expr(const gsc::context_ptr& ctx, gsc::expr_ptr& expr)
|
||||
}
|
||||
}
|
||||
|
||||
void decompiler::process_expr_assign(const gsc::context_ptr& ctx, const gsc::expr_assign_ptr& expr)
|
||||
void decompiler::process_expr_assign(const gsc::context_ptr& ctx, gsc::expr_assign_ptr& expr)
|
||||
{
|
||||
if(expr->type == gsc::node_t::expr_increment)
|
||||
{
|
||||
@ -2999,6 +2976,55 @@ void decompiler::process_expr_assign(const gsc::context_ptr& ctx, const gsc::exp
|
||||
{
|
||||
process_expr(ctx, expr->rvalue);
|
||||
process_expr(ctx, expr->lvalue);
|
||||
|
||||
if(expr->type == gsc::node_t::expr_assign_equal)
|
||||
{
|
||||
switch(expr->rvalue.as_node->type)
|
||||
{
|
||||
case gsc::node_t::expr_bitwise_or:
|
||||
if(expr->lvalue == expr->rvalue.as_bitwise_or->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_bitwise_or>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_bitwise_and:
|
||||
if(expr->lvalue == expr->rvalue.as_bitwise_and->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_bitwise_and>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_bitwise_exor:
|
||||
if(expr->lvalue == expr->rvalue.as_bitwise_exor->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_bitwise_exor>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_shift_left:
|
||||
if(expr->lvalue == expr->rvalue.as_shift_left->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_shift_left>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_shift_right:
|
||||
if(expr->lvalue == expr->rvalue.as_shift_right->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_shift_right>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_add:
|
||||
if(expr->lvalue == expr->rvalue.as_add->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_add>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_sub:
|
||||
if(expr->lvalue == expr->rvalue.as_sub->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_sub>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_mult:
|
||||
if(expr->lvalue == expr->rvalue.as_mult->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_mult>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_div:
|
||||
if(expr->lvalue == expr->rvalue.as_div->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_div>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_mod:
|
||||
if(expr->lvalue == expr->rvalue.as_mod->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_mod>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ private:
|
||||
void process_stmt_break(const gsc::context_ptr& ctx, const gsc::stmt_break_ptr& stmt);
|
||||
void process_stmt_return(const gsc::context_ptr& ctx, const gsc::stmt_return_ptr& stmt);
|
||||
void process_expr(const gsc::context_ptr& ctx, gsc::expr_ptr& expr);
|
||||
void process_expr_assign(const gsc::context_ptr& ctx, const gsc::expr_assign_ptr& expr);
|
||||
void process_expr_assign(const gsc::context_ptr& ctx, gsc::expr_assign_ptr& expr);
|
||||
void process_expr_binary(const gsc::context_ptr& ctx, const gsc::expr_binary_ptr& expr);
|
||||
void process_expr_and(const gsc::context_ptr& ctx, const gsc::expr_and_ptr& expr);
|
||||
void process_expr_or(const gsc::context_ptr& ctx, const gsc::expr_or_ptr& expr);
|
||||
|
@ -546,7 +546,6 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
|
||||
break;
|
||||
case opcode::OP_ScriptLocalMethodChildThreadCall:
|
||||
{
|
||||
// TODO: child things...
|
||||
auto obj = gsc::expr_ptr(std::move(stack_.top()));
|
||||
stack_.pop();
|
||||
loc = obj.as_node->loc;
|
||||
@ -1395,7 +1394,6 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
|
||||
stack_.pop();
|
||||
args->loc = node->loc;
|
||||
args->list.push_back(std::move(node));
|
||||
|
||||
}
|
||||
loc = args->loc;
|
||||
|
||||
@ -1425,9 +1423,6 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
|
||||
}
|
||||
break;
|
||||
case opcode::OP_checkclearparams:
|
||||
{
|
||||
// no needed
|
||||
}
|
||||
break;
|
||||
case opcode::OP_notify:
|
||||
{
|
||||
@ -1736,9 +1731,6 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
|
||||
break;
|
||||
case opcode::OP_CastFieldObject:
|
||||
case opcode::OP_CastBool:
|
||||
{
|
||||
//continue;
|
||||
}
|
||||
break;
|
||||
case opcode::OP_BoolNot:
|
||||
{
|
||||
@ -1780,7 +1772,6 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
|
||||
{
|
||||
auto expr = std::make_unique<gsc::node_asm_jump>(loc, inst->data[0]);
|
||||
func_->block->stmts.push_back(gsc::stmt_ptr(std::move(expr)));
|
||||
|
||||
}
|
||||
break;
|
||||
case opcode::OP_jumpback:
|
||||
@ -1871,20 +1862,6 @@ void decompiler::decompile_block(const gsc::stmt_list_ptr& block)
|
||||
this->decompile_search_switch(block);
|
||||
this->decompile_search_ifelse(block);
|
||||
this->decompile_break_continue(block);
|
||||
this->decompile_nulls(block);
|
||||
}
|
||||
|
||||
void decompiler::decompile_nulls(const gsc::stmt_list_ptr& block)
|
||||
{
|
||||
auto index = 0;
|
||||
while(index < block->stmts.size())
|
||||
{
|
||||
if(block->stmts.at(index).as_node->type == gsc::node_t::null)
|
||||
{
|
||||
block->stmts.erase(block->stmts.begin() + index);
|
||||
}
|
||||
else index++;
|
||||
}
|
||||
}
|
||||
|
||||
void decompiler::decompile_search_infinite(const gsc::stmt_list_ptr& block)
|
||||
@ -2991,7 +2968,7 @@ void decompiler::process_expr(const gsc::context_ptr& ctx, gsc::expr_ptr& expr)
|
||||
}
|
||||
}
|
||||
|
||||
void decompiler::process_expr_assign(const gsc::context_ptr& ctx, const gsc::expr_assign_ptr& expr)
|
||||
void decompiler::process_expr_assign(const gsc::context_ptr& ctx, gsc::expr_assign_ptr& expr)
|
||||
{
|
||||
if(expr->type == gsc::node_t::expr_increment)
|
||||
{
|
||||
@ -3005,6 +2982,55 @@ void decompiler::process_expr_assign(const gsc::context_ptr& ctx, const gsc::exp
|
||||
{
|
||||
process_expr(ctx, expr->rvalue);
|
||||
process_expr(ctx, expr->lvalue);
|
||||
|
||||
if(expr->type == gsc::node_t::expr_assign_equal)
|
||||
{
|
||||
switch(expr->rvalue.as_node->type)
|
||||
{
|
||||
case gsc::node_t::expr_bitwise_or:
|
||||
if(expr->lvalue == expr->rvalue.as_bitwise_or->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_bitwise_or>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_bitwise_and:
|
||||
if(expr->lvalue == expr->rvalue.as_bitwise_and->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_bitwise_and>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_bitwise_exor:
|
||||
if(expr->lvalue == expr->rvalue.as_bitwise_exor->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_bitwise_exor>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_shift_left:
|
||||
if(expr->lvalue == expr->rvalue.as_shift_left->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_shift_left>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_shift_right:
|
||||
if(expr->lvalue == expr->rvalue.as_shift_right->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_shift_right>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_add:
|
||||
if(expr->lvalue == expr->rvalue.as_add->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_add>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_sub:
|
||||
if(expr->lvalue == expr->rvalue.as_sub->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_sub>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_mult:
|
||||
if(expr->lvalue == expr->rvalue.as_mult->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_mult>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_div:
|
||||
if(expr->lvalue == expr->rvalue.as_div->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_div>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_mod:
|
||||
if(expr->lvalue == expr->rvalue.as_mod->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_mod>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ private:
|
||||
void process_stmt_break(const gsc::context_ptr& ctx, const gsc::stmt_break_ptr& stmt);
|
||||
void process_stmt_return(const gsc::context_ptr& ctx, const gsc::stmt_return_ptr& stmt);
|
||||
void process_expr(const gsc::context_ptr& ctx, gsc::expr_ptr& expr);
|
||||
void process_expr_assign(const gsc::context_ptr& ctx, const gsc::expr_assign_ptr& expr);
|
||||
void process_expr_assign(const gsc::context_ptr& ctx, gsc::expr_assign_ptr& expr);
|
||||
void process_expr_binary(const gsc::context_ptr& ctx, const gsc::expr_binary_ptr& expr);
|
||||
void process_expr_and(const gsc::context_ptr& ctx, const gsc::expr_and_ptr& expr);
|
||||
void process_expr_or(const gsc::context_ptr& ctx, const gsc::expr_or_ptr& expr);
|
||||
|
@ -546,7 +546,6 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
|
||||
break;
|
||||
case opcode::OP_ScriptLocalMethodChildThreadCall:
|
||||
{
|
||||
// TODO: child things...
|
||||
auto obj = gsc::expr_ptr(std::move(stack_.top()));
|
||||
stack_.pop();
|
||||
loc = obj.as_node->loc;
|
||||
@ -1395,7 +1394,6 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
|
||||
stack_.pop();
|
||||
args->loc = node->loc;
|
||||
args->list.push_back(std::move(node));
|
||||
|
||||
}
|
||||
loc = args->loc;
|
||||
|
||||
@ -1425,9 +1423,6 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
|
||||
}
|
||||
break;
|
||||
case opcode::OP_checkclearparams:
|
||||
{
|
||||
// no needed
|
||||
}
|
||||
break;
|
||||
case opcode::OP_notify:
|
||||
{
|
||||
@ -1736,9 +1731,6 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
|
||||
break;
|
||||
case opcode::OP_CastFieldObject:
|
||||
case opcode::OP_CastBool:
|
||||
{
|
||||
//continue;
|
||||
}
|
||||
break;
|
||||
case opcode::OP_BoolNot:
|
||||
{
|
||||
@ -1780,7 +1772,6 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
|
||||
{
|
||||
auto expr = std::make_unique<gsc::node_asm_jump>(loc, inst->data[0]);
|
||||
func_->block->stmts.push_back(gsc::stmt_ptr(std::move(expr)));
|
||||
|
||||
}
|
||||
break;
|
||||
case opcode::OP_jumpback:
|
||||
@ -1880,20 +1871,6 @@ void decompiler::decompile_block(const gsc::stmt_list_ptr& block)
|
||||
this->decompile_search_switch(block);
|
||||
this->decompile_search_ifelse(block);
|
||||
this->decompile_break_continue(block);
|
||||
this->decompile_nulls(block);
|
||||
}
|
||||
|
||||
void decompiler::decompile_nulls(const gsc::stmt_list_ptr& block)
|
||||
{
|
||||
auto index = 0;
|
||||
while(index < block->stmts.size())
|
||||
{
|
||||
if(block->stmts.at(index).as_node->type == gsc::node_t::null)
|
||||
{
|
||||
block->stmts.erase(block->stmts.begin() + index);
|
||||
}
|
||||
else index++;
|
||||
}
|
||||
}
|
||||
|
||||
void decompiler::decompile_search_infinite(const gsc::stmt_list_ptr& block)
|
||||
@ -3000,7 +2977,7 @@ void decompiler::process_expr(const gsc::context_ptr& ctx, gsc::expr_ptr& expr)
|
||||
}
|
||||
}
|
||||
|
||||
void decompiler::process_expr_assign(const gsc::context_ptr& ctx, const gsc::expr_assign_ptr& expr)
|
||||
void decompiler::process_expr_assign(const gsc::context_ptr& ctx, gsc::expr_assign_ptr& expr)
|
||||
{
|
||||
if(expr->type == gsc::node_t::expr_increment)
|
||||
{
|
||||
@ -3014,6 +2991,55 @@ void decompiler::process_expr_assign(const gsc::context_ptr& ctx, const gsc::exp
|
||||
{
|
||||
process_expr(ctx, expr->rvalue);
|
||||
process_expr(ctx, expr->lvalue);
|
||||
|
||||
if(expr->type == gsc::node_t::expr_assign_equal)
|
||||
{
|
||||
switch(expr->rvalue.as_node->type)
|
||||
{
|
||||
case gsc::node_t::expr_bitwise_or:
|
||||
if(expr->lvalue == expr->rvalue.as_bitwise_or->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_bitwise_or>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_bitwise_and:
|
||||
if(expr->lvalue == expr->rvalue.as_bitwise_and->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_bitwise_and>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_bitwise_exor:
|
||||
if(expr->lvalue == expr->rvalue.as_bitwise_exor->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_bitwise_exor>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_shift_left:
|
||||
if(expr->lvalue == expr->rvalue.as_shift_left->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_shift_left>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_shift_right:
|
||||
if(expr->lvalue == expr->rvalue.as_shift_right->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_shift_right>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_add:
|
||||
if(expr->lvalue == expr->rvalue.as_add->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_add>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_sub:
|
||||
if(expr->lvalue == expr->rvalue.as_sub->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_sub>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_mult:
|
||||
if(expr->lvalue == expr->rvalue.as_mult->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_mult>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_div:
|
||||
if(expr->lvalue == expr->rvalue.as_div->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_div>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
case gsc::node_t::expr_mod:
|
||||
if(expr->lvalue == expr->rvalue.as_mod->lvalue)
|
||||
expr = std::make_unique<gsc::node_expr_assign_mod>(std::move(expr->lvalue), std::move(expr->rvalue.as_mod->rvalue));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ private:
|
||||
void process_stmt_break(const gsc::context_ptr& ctx, const gsc::stmt_break_ptr& stmt);
|
||||
void process_stmt_return(const gsc::context_ptr& ctx, const gsc::stmt_return_ptr& stmt);
|
||||
void process_expr(const gsc::context_ptr& ctx, gsc::expr_ptr& expr);
|
||||
void process_expr_assign(const gsc::context_ptr& ctx, const gsc::expr_assign_ptr& expr);
|
||||
void process_expr_assign(const gsc::context_ptr& ctx, gsc::expr_assign_ptr& expr);
|
||||
void process_expr_binary(const gsc::context_ptr& ctx, const gsc::expr_binary_ptr& expr);
|
||||
void process_expr_and(const gsc::context_ptr& ctx, const gsc::expr_and_ptr& expr);
|
||||
void process_expr_or(const gsc::context_ptr& ctx, const gsc::expr_or_ptr& expr);
|
||||
|
@ -29,6 +29,7 @@ enum class node_t
|
||||
data_undefined,
|
||||
data_empty_array,
|
||||
data_thisthread,
|
||||
expr_paren,
|
||||
expr_size,
|
||||
expr_field,
|
||||
expr_array,
|
||||
@ -134,6 +135,7 @@ struct node_game;
|
||||
struct node_undefined;
|
||||
struct node_empty_array;
|
||||
struct node_thisthread;
|
||||
struct node_expr_paren;
|
||||
struct node_expr_size;
|
||||
struct node_expr_field;
|
||||
struct node_expr_array;
|
||||
@ -237,6 +239,7 @@ using game_ptr = std::unique_ptr<node_game>;
|
||||
using undefined_ptr = std::unique_ptr<node_undefined>;
|
||||
using empty_array_ptr = std::unique_ptr<node_empty_array>;
|
||||
using thisthread_ptr = std::unique_ptr<node_thisthread>;
|
||||
using expr_paren_ptr = std::unique_ptr<node_expr_paren>;
|
||||
using expr_size_ptr = std::unique_ptr<node_expr_size>;
|
||||
using expr_field_ptr = std::unique_ptr<node_expr_field>;
|
||||
using expr_array_ptr = std::unique_ptr<node_expr_array>;
|
||||
@ -354,6 +357,7 @@ union expr_ptr
|
||||
undefined_ptr as_undefined;
|
||||
empty_array_ptr as_empty_array;
|
||||
thisthread_ptr as_thisthread;
|
||||
expr_paren_ptr as_paren;
|
||||
expr_size_ptr as_size;
|
||||
expr_field_ptr as_field;
|
||||
expr_array_ptr as_array;
|
||||
@ -408,12 +412,15 @@ union expr_ptr
|
||||
new(&as_node) node_ptr(std::move(val.as_node));
|
||||
}
|
||||
|
||||
~expr_ptr(){}
|
||||
|
||||
expr_ptr& operator=(expr_ptr && val)
|
||||
{
|
||||
new(&as_node) node_ptr(std::move(val.as_node));
|
||||
return *(expr_ptr*)&as_node;
|
||||
}
|
||||
~expr_ptr(){}
|
||||
|
||||
bool operator==(const expr_ptr& rhs) const;
|
||||
};
|
||||
|
||||
union stmt_ptr
|
||||
@ -542,6 +549,11 @@ struct node_true : public node
|
||||
{
|
||||
return "true";
|
||||
}
|
||||
|
||||
friend bool operator==(const node_true& lhs, const node_true& rhs)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
struct node_false : public node
|
||||
@ -553,6 +565,11 @@ struct node_false : public node
|
||||
{
|
||||
return "false";
|
||||
}
|
||||
|
||||
friend bool operator==(const node_false& lhs, const node_false& rhs)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
struct node_integer : public node
|
||||
@ -569,6 +586,11 @@ struct node_integer : public node
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
friend bool operator==(const node_integer& lhs, const node_integer& rhs)
|
||||
{
|
||||
return lhs.value == rhs.value;
|
||||
}
|
||||
};
|
||||
|
||||
struct node_float : public node
|
||||
@ -585,6 +607,11 @@ struct node_float : public node
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
friend bool operator==(const node_float& lhs, const node_float& rhs)
|
||||
{
|
||||
return lhs.value == rhs.value;
|
||||
}
|
||||
};
|
||||
|
||||
struct node_vector : public node
|
||||
@ -603,6 +630,11 @@ struct node_vector : public node
|
||||
{
|
||||
return "( "s + x.as_node->print() + ", " + y.as_node->print() + ", "+ z.as_node->print() + " )";
|
||||
}
|
||||
|
||||
friend bool operator==(const node_vector& lhs, const node_vector& rhs)
|
||||
{
|
||||
return lhs.x == rhs.x && lhs.y == rhs.y && lhs.z == rhs.z;
|
||||
}
|
||||
};
|
||||
|
||||
struct node_string : public node
|
||||
@ -619,6 +651,11 @@ struct node_string : public node
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
friend bool operator==(const node_string& lhs, const node_string& rhs)
|
||||
{
|
||||
return lhs.value == rhs.value;
|
||||
}
|
||||
};
|
||||
|
||||
struct node_istring : public node
|
||||
@ -635,6 +672,11 @@ struct node_istring : public node
|
||||
{
|
||||
return "&"s += value;
|
||||
}
|
||||
|
||||
friend bool operator==(const node_istring& lhs, const node_istring& rhs)
|
||||
{
|
||||
return lhs.value == rhs.value;
|
||||
}
|
||||
};
|
||||
|
||||
struct node_file : public node
|
||||
@ -656,6 +698,11 @@ struct node_file : public node
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
friend bool operator==(const node_file& lhs, const node_file& rhs)
|
||||
{
|
||||
return lhs.value == rhs.value;
|
||||
}
|
||||
};
|
||||
|
||||
struct node_name : public node
|
||||
@ -672,6 +719,11 @@ struct node_name : public node
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
friend bool operator==(const node_name& lhs, const node_name& rhs)
|
||||
{
|
||||
return lhs.value == rhs.value;
|
||||
}
|
||||
};
|
||||
|
||||
struct node_animtree : public node
|
||||
@ -684,6 +736,11 @@ struct node_animtree : public node
|
||||
{
|
||||
return "#animtree";
|
||||
}
|
||||
|
||||
friend bool operator==(const node_animtree& lhs, const node_animtree& rhs)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
struct node_animation : public node
|
||||
@ -700,6 +757,11 @@ struct node_animation : public node
|
||||
{
|
||||
return "%"s += value;
|
||||
}
|
||||
|
||||
friend bool operator==(const node_animation& lhs, const node_animation& rhs)
|
||||
{
|
||||
return lhs.value == rhs.value;
|
||||
}
|
||||
};
|
||||
|
||||
struct node_level : public node
|
||||
@ -712,6 +774,11 @@ struct node_level : public node
|
||||
{
|
||||
return "level";
|
||||
}
|
||||
|
||||
friend bool operator==(const node_level& lhs, const node_level& rhs)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
struct node_anim : public node
|
||||
@ -724,6 +791,11 @@ struct node_anim : public node
|
||||
{
|
||||
return "anim";
|
||||
}
|
||||
|
||||
friend bool operator==(const node_anim& lhs, const node_anim& rhs)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
struct node_self : public node
|
||||
@ -736,6 +808,11 @@ struct node_self : public node
|
||||
{
|
||||
return "self";
|
||||
}
|
||||
|
||||
friend bool operator==(const node_self& lhs, const node_self& rhs)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
struct node_game : public node
|
||||
@ -748,6 +825,11 @@ struct node_game : public node
|
||||
{
|
||||
return "game";
|
||||
}
|
||||
|
||||
friend bool operator==(const node_game& lhs, const node_game& rhs)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
struct node_undefined : public node
|
||||
@ -760,6 +842,11 @@ struct node_undefined : public node
|
||||
{
|
||||
return "undefined";
|
||||
}
|
||||
|
||||
friend bool operator==(const node_undefined& lhs, const node_undefined& rhs)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
struct node_empty_array : public node
|
||||
@ -772,6 +859,11 @@ struct node_empty_array : public node
|
||||
{
|
||||
return "[]";
|
||||
}
|
||||
|
||||
friend bool operator==(const node_empty_array& lhs, const node_empty_array& rhs)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
struct node_thisthread : public node
|
||||
@ -784,6 +876,32 @@ struct node_thisthread : public node
|
||||
{
|
||||
return "thisthread";
|
||||
}
|
||||
|
||||
friend bool operator==(const node_thisthread& lhs, const node_thisthread& rhs)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
struct node_expr_paren : public node
|
||||
{
|
||||
expr_ptr expr;
|
||||
|
||||
node_expr_paren(expr_ptr expr)
|
||||
: node(node_t::expr_paren), expr(std::move(expr)) {}
|
||||
|
||||
node_expr_paren(const location& loc, expr_ptr expr)
|
||||
: node(node_t::expr_paren, loc), expr(std::move(expr)) {}
|
||||
|
||||
auto print() -> std::string override
|
||||
{
|
||||
return "(" + expr.as_node->print() + ")";
|
||||
}
|
||||
|
||||
friend bool operator==(const node_expr_paren& lhs, const node_expr_paren& rhs)
|
||||
{
|
||||
return lhs.expr == rhs.expr;
|
||||
}
|
||||
};
|
||||
|
||||
struct node_expr_size : public node
|
||||
@ -800,6 +918,11 @@ struct node_expr_size : public node
|
||||
{
|
||||
return obj.as_node->print() + ".size";
|
||||
}
|
||||
|
||||
friend bool operator==(const node_expr_size& lhs, const node_expr_size& rhs)
|
||||
{
|
||||
return lhs.obj == rhs.obj;
|
||||
}
|
||||
};
|
||||
|
||||
struct node_expr_field : public node
|
||||
@ -817,6 +940,11 @@ struct node_expr_field : public node
|
||||
{
|
||||
return obj.as_node->print() + "." + field->print();
|
||||
}
|
||||
|
||||
friend bool operator==(const node_expr_field& lhs, const node_expr_field& rhs)
|
||||
{
|
||||
return lhs.obj == rhs.obj && lhs.field == rhs.field;
|
||||
}
|
||||
};
|
||||
|
||||
struct node_expr_array : public node
|
||||
@ -834,6 +962,11 @@ struct node_expr_array : public node
|
||||
{
|
||||
return obj.as_node->print() + "[" + key.as_node->print() + "]";
|
||||
}
|
||||
|
||||
friend bool operator==(const node_expr_array& lhs, const node_expr_array& rhs)
|
||||
{
|
||||
return lhs.obj == rhs.obj && lhs.key == rhs.key;
|
||||
}
|
||||
};
|
||||
|
||||
struct node_expr_arguments : public node
|
||||
|
@ -5,4 +5,65 @@
|
||||
|
||||
#include "stdafx.hpp"
|
||||
|
||||
std::uint32_t xsk::gsc::node::indent_;
|
||||
namespace xsk
|
||||
{
|
||||
|
||||
std::uint32_t gsc::node::indent_;
|
||||
|
||||
bool gsc::expr_ptr::operator==(const gsc::expr_ptr& rhs) const
|
||||
{
|
||||
if(as_node->type != rhs.as_node->type)
|
||||
return false;
|
||||
|
||||
switch(as_node->type)
|
||||
{
|
||||
case gsc::node_t::data_true:
|
||||
return *as_true == *rhs.as_true;
|
||||
case gsc::node_t::data_false:
|
||||
return *as_false == *rhs.as_false;
|
||||
case gsc::node_t::data_integer:
|
||||
return *as_integer == *rhs.as_integer;
|
||||
case gsc::node_t::data_float:
|
||||
return *as_float == *rhs.as_float;
|
||||
case gsc::node_t::data_vector:
|
||||
return *as_vector == *rhs.as_vector;
|
||||
case gsc::node_t::data_string:
|
||||
return *as_string == *rhs.as_string;
|
||||
case gsc::node_t::data_istring:
|
||||
return *as_istring == *rhs.as_istring;
|
||||
case gsc::node_t::data_file:
|
||||
return *as_file == *rhs.as_file;
|
||||
case gsc::node_t::data_name:
|
||||
return *as_name == *rhs.as_name;
|
||||
case gsc::node_t::data_animtree:
|
||||
return *as_animtree == *rhs.as_animtree;
|
||||
case gsc::node_t::data_animation:
|
||||
return *as_animation == *rhs.as_animation;
|
||||
case gsc::node_t::data_level:
|
||||
return *as_level == *rhs.as_level;
|
||||
case gsc::node_t::data_anim:
|
||||
return *as_anim == *rhs.as_anim;
|
||||
case gsc::node_t::data_self:
|
||||
return *as_self == *rhs.as_self;
|
||||
case gsc::node_t::data_game:
|
||||
return *as_game == *rhs.as_game;
|
||||
case gsc::node_t::data_undefined:
|
||||
return *as_undefined == *rhs.as_undefined;
|
||||
case gsc::node_t::data_empty_array:
|
||||
return *as_empty_array == *rhs.as_empty_array;
|
||||
case gsc::node_t::data_thisthread:
|
||||
return *as_thisthread == *rhs.as_thisthread;
|
||||
case gsc::node_t::expr_paren:
|
||||
return *as_paren == *rhs.as_paren;
|
||||
case gsc::node_t::expr_size:
|
||||
return *as_size == *rhs.as_size;
|
||||
case gsc::node_t::expr_field:
|
||||
return *as_field == *rhs.as_field;
|
||||
case gsc::node_t::expr_array:
|
||||
return *as_array == *rhs.as_array;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace xsk
|
||||
|
Loading…
Reference in New Issue
Block a user