fix default order

This commit is contained in:
xensik 2021-05-15 12:04:48 +02:00
parent 7fd69dc70c
commit e25d69e74a
14 changed files with 49 additions and 0 deletions

View File

@ -615,6 +615,11 @@ void compiler::emit_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_swi
if(entry.as_node->type == gsc::node_t::stmt_case)
{
if(has_default)
{
gsc::comp_error(stmt->loc, "default must be last case");
}
auto& case_ = entry.as_case;
if(case_->value.as_node->type == gsc::node_t::data_integer)
{

View File

@ -2525,6 +2525,8 @@ void decompiler::decompile_switch(const gsc::stmt_list_ptr& block, std::uint32_t
auto list = std::make_unique<gsc::node_stmt_list>(loc);
list->is_case = true;
auto stmt = gsc::stmt_ptr(std::make_unique<gsc::node_stmt_default>(loc_pos, std::move(list)));
while(block->stmts.at(loc_idx).as_node->type == gsc::node_t::stmt_case)
loc_idx++;
block->stmts.insert(block->stmts.begin() + loc_idx, std::move(stmt));
idx += 2;
}

View File

@ -615,6 +615,11 @@ void compiler::emit_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_swi
if(entry.as_node->type == gsc::node_t::stmt_case)
{
if(has_default)
{
gsc::comp_error(stmt->loc, "default must be last case");
}
auto& case_ = entry.as_case;
if(case_->value.as_node->type == gsc::node_t::data_integer)
{

View File

@ -2525,6 +2525,8 @@ void decompiler::decompile_switch(const gsc::stmt_list_ptr& block, std::uint32_t
auto list = std::make_unique<gsc::node_stmt_list>(loc);
list->is_case = true;
auto stmt = gsc::stmt_ptr(std::make_unique<gsc::node_stmt_default>(loc_pos, std::move(list)));
while(block->stmts.at(loc_idx).as_node->type == gsc::node_t::stmt_case)
loc_idx++;
block->stmts.insert(block->stmts.begin() + loc_idx, std::move(stmt));
idx += 2;
}

View File

@ -609,6 +609,11 @@ void compiler::emit_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_swi
if(entry.as_node->type == gsc::node_t::stmt_case)
{
if(has_default)
{
gsc::comp_error(stmt->loc, "default must be last case");
}
auto& case_ = entry.as_case;
if(case_->value.as_node->type == gsc::node_t::data_integer)
{

View File

@ -2519,6 +2519,8 @@ void decompiler::decompile_switch(const gsc::stmt_list_ptr& block, std::uint32_t
auto list = std::make_unique<gsc::node_stmt_list>(loc);
list->is_case = true;
auto stmt = gsc::stmt_ptr(std::make_unique<gsc::node_stmt_default>(loc_pos, std::move(list)));
while(block->stmts.at(loc_idx).as_node->type == gsc::node_t::stmt_case)
loc_idx++;
block->stmts.insert(block->stmts.begin() + loc_idx, std::move(stmt));
idx += 2;
}

View File

@ -609,6 +609,11 @@ void compiler::emit_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_swi
if(entry.as_node->type == gsc::node_t::stmt_case)
{
if(has_default)
{
gsc::comp_error(stmt->loc, "default must be last case");
}
auto& case_ = entry.as_case;
if(case_->value.as_node->type == gsc::node_t::data_integer)
{

View File

@ -2519,6 +2519,8 @@ void decompiler::decompile_switch(const gsc::stmt_list_ptr& block, std::uint32_t
auto list = std::make_unique<gsc::node_stmt_list>(loc);
list->is_case = true;
auto stmt = gsc::stmt_ptr(std::make_unique<gsc::node_stmt_default>(loc_pos, std::move(list)));
while(block->stmts.at(loc_idx).as_node->type == gsc::node_t::stmt_case)
loc_idx++;
block->stmts.insert(block->stmts.begin() + loc_idx, std::move(stmt));
idx += 2;
}

View File

@ -609,6 +609,11 @@ void compiler::emit_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_swi
if(entry.as_node->type == gsc::node_t::stmt_case)
{
if(has_default)
{
gsc::comp_error(stmt->loc, "default must be last case");
}
auto& case_ = entry.as_case;
if(case_->value.as_node->type == gsc::node_t::data_integer)
{

View File

@ -2519,6 +2519,8 @@ void decompiler::decompile_switch(const gsc::stmt_list_ptr& block, std::uint32_t
auto list = std::make_unique<gsc::node_stmt_list>(loc);
list->is_case = true;
auto stmt = gsc::stmt_ptr(std::make_unique<gsc::node_stmt_default>(loc_pos, std::move(list)));
while(block->stmts.at(loc_idx).as_node->type == gsc::node_t::stmt_case)
loc_idx++;
block->stmts.insert(block->stmts.begin() + loc_idx, std::move(stmt));
idx += 2;
}

View File

@ -615,6 +615,11 @@ void compiler::emit_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_swi
if(entry.as_node->type == gsc::node_t::stmt_case)
{
if(has_default)
{
gsc::comp_error(stmt->loc, "default must be last case");
}
auto& case_ = entry.as_case;
if(case_->value.as_node->type == gsc::node_t::data_integer)
{

View File

@ -2525,6 +2525,8 @@ void decompiler::decompile_switch(const gsc::stmt_list_ptr& block, std::uint32_t
auto list = std::make_unique<gsc::node_stmt_list>(loc);
list->is_case = true;
auto stmt = gsc::stmt_ptr(std::make_unique<gsc::node_stmt_default>(loc_pos, std::move(list)));
while(block->stmts.at(loc_idx).as_node->type == gsc::node_t::stmt_case)
loc_idx++;
block->stmts.insert(block->stmts.begin() + loc_idx, std::move(stmt));
idx += 2;
}

View File

@ -615,6 +615,11 @@ void compiler::emit_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_swi
if(entry.as_node->type == gsc::node_t::stmt_case)
{
if(has_default)
{
gsc::comp_error(stmt->loc, "default must be last case");
}
auto& case_ = entry.as_case;
if(case_->value.as_node->type == gsc::node_t::data_integer)
{

View File

@ -2534,6 +2534,8 @@ void decompiler::decompile_switch(const gsc::stmt_list_ptr& block, std::uint32_t
auto list = std::make_unique<gsc::node_stmt_list>(loc);
list->is_case = true;
auto stmt = gsc::stmt_ptr(std::make_unique<gsc::node_stmt_default>(loc_pos, std::move(list)));
while(block->stmts.at(loc_idx).as_node->type == gsc::node_t::stmt_case)
loc_idx++;
block->stmts.insert(block->stmts.begin() + loc_idx, std::move(stmt));
idx += 2;
}