compiler fixes
This commit is contained in:
parent
51e3236696
commit
7ce2add85b
@ -411,6 +411,12 @@ void compiler::emit_stmt_while(const gsc::context_ptr& ctx, const gsc::stmt_whil
|
|||||||
|
|
||||||
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
||||||
|
|
||||||
|
for(auto i = 0; i < ctx->local_vars_create_count; i++)
|
||||||
|
{
|
||||||
|
if(!ctx->local_vars.at(i).init)
|
||||||
|
ctx->local_vars.at(i).init = true;
|
||||||
|
}
|
||||||
|
|
||||||
auto begin_loc = insert_label();
|
auto begin_loc = insert_label();
|
||||||
|
|
||||||
bool const_cond = is_constant_condition(stmt->expr);
|
bool const_cond = is_constant_condition(stmt->expr);
|
||||||
@ -460,6 +466,13 @@ void compiler::emit_stmt_for(const gsc::context_ptr& ctx, const gsc::stmt_for_pt
|
|||||||
emit_create_local_vars(stmt->ctx);
|
emit_create_local_vars(stmt->ctx);
|
||||||
|
|
||||||
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
||||||
|
|
||||||
|
for(auto i = 0; i < ctx->local_vars_create_count; i++)
|
||||||
|
{
|
||||||
|
if(!ctx->local_vars.at(i).init)
|
||||||
|
ctx->local_vars.at(i).init = true;
|
||||||
|
}
|
||||||
|
|
||||||
ctx->transfer(stmt->ctx_post);
|
ctx->transfer(stmt->ctx_post);
|
||||||
|
|
||||||
auto begin_loc = insert_label();
|
auto begin_loc = insert_label();
|
||||||
@ -529,6 +542,12 @@ void compiler::emit_stmt_foreach(const gsc::context_ptr& ctx, const gsc::stmt_fo
|
|||||||
|
|
||||||
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
||||||
|
|
||||||
|
for(auto i = 0; i < ctx->local_vars_create_count; i++)
|
||||||
|
{
|
||||||
|
if(!ctx->local_vars.at(i).init)
|
||||||
|
ctx->local_vars.at(i).init = true;
|
||||||
|
}
|
||||||
|
|
||||||
ctx->transfer(stmt->ctx_post);
|
ctx->transfer(stmt->ctx_post);
|
||||||
|
|
||||||
auto begin_loc = insert_label();
|
auto begin_loc = insert_label();
|
||||||
@ -1475,7 +1494,6 @@ void compiler::emit_remove_local_vars(const gsc::context_ptr& ctx)
|
|||||||
|
|
||||||
void compiler::emit_object(const gsc::context_ptr& ctx, const gsc::expr_ptr& expr)
|
void compiler::emit_object(const gsc::context_ptr& ctx, const gsc::expr_ptr& expr)
|
||||||
{
|
{
|
||||||
// need revision used for clear variable
|
|
||||||
switch(expr.as_node->type)
|
switch(expr.as_node->type)
|
||||||
{
|
{
|
||||||
case gsc::node_t::data_level:
|
case gsc::node_t::data_level:
|
||||||
@ -1494,8 +1512,14 @@ void compiler::emit_object(const gsc::context_ptr& ctx, const gsc::expr_ptr& exp
|
|||||||
emit_expr_call(ctx, expr.as_call);
|
emit_expr_call(ctx, expr.as_call);
|
||||||
emit_opcode(ctx, opcode::OP_CastFieldObject);
|
emit_opcode(ctx, opcode::OP_CastFieldObject);
|
||||||
break;
|
break;
|
||||||
// array ?
|
case gsc::node_t::expr_array:
|
||||||
// field ?
|
emit_array_variable(ctx, expr.as_array);
|
||||||
|
emit_opcode(ctx, opcode::OP_CastFieldObject);
|
||||||
|
break;
|
||||||
|
case gsc::node_t::expr_field:
|
||||||
|
emit_field_variable(ctx, expr.as_field);
|
||||||
|
emit_opcode(ctx, opcode::OP_CastFieldObject);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw gsc::comp_error(expr.as_node->loc, "unknown object type");
|
throw gsc::comp_error(expr.as_node->loc, "unknown object type");
|
||||||
break;
|
break;
|
||||||
|
@ -411,6 +411,12 @@ void compiler::emit_stmt_while(const gsc::context_ptr& ctx, const gsc::stmt_whil
|
|||||||
|
|
||||||
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
||||||
|
|
||||||
|
for(auto i = 0; i < ctx->local_vars_create_count; i++)
|
||||||
|
{
|
||||||
|
if(!ctx->local_vars.at(i).init)
|
||||||
|
ctx->local_vars.at(i).init = true;
|
||||||
|
}
|
||||||
|
|
||||||
auto begin_loc = insert_label();
|
auto begin_loc = insert_label();
|
||||||
|
|
||||||
bool const_cond = is_constant_condition(stmt->expr);
|
bool const_cond = is_constant_condition(stmt->expr);
|
||||||
@ -460,6 +466,13 @@ void compiler::emit_stmt_for(const gsc::context_ptr& ctx, const gsc::stmt_for_pt
|
|||||||
emit_create_local_vars(stmt->ctx);
|
emit_create_local_vars(stmt->ctx);
|
||||||
|
|
||||||
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
||||||
|
|
||||||
|
for(auto i = 0; i < ctx->local_vars_create_count; i++)
|
||||||
|
{
|
||||||
|
if(!ctx->local_vars.at(i).init)
|
||||||
|
ctx->local_vars.at(i).init = true;
|
||||||
|
}
|
||||||
|
|
||||||
ctx->transfer(stmt->ctx_post);
|
ctx->transfer(stmt->ctx_post);
|
||||||
|
|
||||||
auto begin_loc = insert_label();
|
auto begin_loc = insert_label();
|
||||||
@ -529,6 +542,12 @@ void compiler::emit_stmt_foreach(const gsc::context_ptr& ctx, const gsc::stmt_fo
|
|||||||
|
|
||||||
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
||||||
|
|
||||||
|
for(auto i = 0; i < ctx->local_vars_create_count; i++)
|
||||||
|
{
|
||||||
|
if(!ctx->local_vars.at(i).init)
|
||||||
|
ctx->local_vars.at(i).init = true;
|
||||||
|
}
|
||||||
|
|
||||||
ctx->transfer(stmt->ctx_post);
|
ctx->transfer(stmt->ctx_post);
|
||||||
|
|
||||||
auto begin_loc = insert_label();
|
auto begin_loc = insert_label();
|
||||||
@ -1475,7 +1494,6 @@ void compiler::emit_remove_local_vars(const gsc::context_ptr& ctx)
|
|||||||
|
|
||||||
void compiler::emit_object(const gsc::context_ptr& ctx, const gsc::expr_ptr& expr)
|
void compiler::emit_object(const gsc::context_ptr& ctx, const gsc::expr_ptr& expr)
|
||||||
{
|
{
|
||||||
// need revision used for clear variable
|
|
||||||
switch(expr.as_node->type)
|
switch(expr.as_node->type)
|
||||||
{
|
{
|
||||||
case gsc::node_t::data_level:
|
case gsc::node_t::data_level:
|
||||||
@ -1494,8 +1512,14 @@ void compiler::emit_object(const gsc::context_ptr& ctx, const gsc::expr_ptr& exp
|
|||||||
emit_expr_call(ctx, expr.as_call);
|
emit_expr_call(ctx, expr.as_call);
|
||||||
emit_opcode(ctx, opcode::OP_CastFieldObject);
|
emit_opcode(ctx, opcode::OP_CastFieldObject);
|
||||||
break;
|
break;
|
||||||
// array ?
|
case gsc::node_t::expr_array:
|
||||||
// field ?
|
emit_array_variable(ctx, expr.as_array);
|
||||||
|
emit_opcode(ctx, opcode::OP_CastFieldObject);
|
||||||
|
break;
|
||||||
|
case gsc::node_t::expr_field:
|
||||||
|
emit_field_variable(ctx, expr.as_field);
|
||||||
|
emit_opcode(ctx, opcode::OP_CastFieldObject);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw gsc::comp_error(expr.as_node->loc, "unknown object type");
|
throw gsc::comp_error(expr.as_node->loc, "unknown object type");
|
||||||
break;
|
break;
|
||||||
|
@ -405,6 +405,12 @@ void compiler::emit_stmt_while(const gsc::context_ptr& ctx, const gsc::stmt_whil
|
|||||||
|
|
||||||
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
||||||
|
|
||||||
|
for(auto i = 0; i < ctx->local_vars_create_count; i++)
|
||||||
|
{
|
||||||
|
if(!ctx->local_vars.at(i).init)
|
||||||
|
ctx->local_vars.at(i).init = true;
|
||||||
|
}
|
||||||
|
|
||||||
auto begin_loc = insert_label();
|
auto begin_loc = insert_label();
|
||||||
|
|
||||||
bool const_cond = is_constant_condition(stmt->expr);
|
bool const_cond = is_constant_condition(stmt->expr);
|
||||||
@ -454,6 +460,13 @@ void compiler::emit_stmt_for(const gsc::context_ptr& ctx, const gsc::stmt_for_pt
|
|||||||
emit_create_local_vars(stmt->ctx);
|
emit_create_local_vars(stmt->ctx);
|
||||||
|
|
||||||
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
||||||
|
|
||||||
|
for(auto i = 0; i < ctx->local_vars_create_count; i++)
|
||||||
|
{
|
||||||
|
if(!ctx->local_vars.at(i).init)
|
||||||
|
ctx->local_vars.at(i).init = true;
|
||||||
|
}
|
||||||
|
|
||||||
ctx->transfer(stmt->ctx_post);
|
ctx->transfer(stmt->ctx_post);
|
||||||
|
|
||||||
auto begin_loc = insert_label();
|
auto begin_loc = insert_label();
|
||||||
@ -523,6 +536,12 @@ void compiler::emit_stmt_foreach(const gsc::context_ptr& ctx, const gsc::stmt_fo
|
|||||||
|
|
||||||
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
||||||
|
|
||||||
|
for(auto i = 0; i < ctx->local_vars_create_count; i++)
|
||||||
|
{
|
||||||
|
if(!ctx->local_vars.at(i).init)
|
||||||
|
ctx->local_vars.at(i).init = true;
|
||||||
|
}
|
||||||
|
|
||||||
ctx->transfer(stmt->ctx_post);
|
ctx->transfer(stmt->ctx_post);
|
||||||
|
|
||||||
auto begin_loc = insert_label();
|
auto begin_loc = insert_label();
|
||||||
@ -1469,7 +1488,6 @@ void compiler::emit_remove_local_vars(const gsc::context_ptr& ctx)
|
|||||||
|
|
||||||
void compiler::emit_object(const gsc::context_ptr& ctx, const gsc::expr_ptr& expr)
|
void compiler::emit_object(const gsc::context_ptr& ctx, const gsc::expr_ptr& expr)
|
||||||
{
|
{
|
||||||
// need revision used for clear variable
|
|
||||||
switch(expr.as_node->type)
|
switch(expr.as_node->type)
|
||||||
{
|
{
|
||||||
case gsc::node_t::data_level:
|
case gsc::node_t::data_level:
|
||||||
@ -1488,8 +1506,14 @@ void compiler::emit_object(const gsc::context_ptr& ctx, const gsc::expr_ptr& exp
|
|||||||
emit_expr_call(ctx, expr.as_call);
|
emit_expr_call(ctx, expr.as_call);
|
||||||
emit_opcode(ctx, opcode::OP_CastFieldObject);
|
emit_opcode(ctx, opcode::OP_CastFieldObject);
|
||||||
break;
|
break;
|
||||||
// array ?
|
case gsc::node_t::expr_array:
|
||||||
// field ?
|
emit_array_variable(ctx, expr.as_array);
|
||||||
|
emit_opcode(ctx, opcode::OP_CastFieldObject);
|
||||||
|
break;
|
||||||
|
case gsc::node_t::expr_field:
|
||||||
|
emit_field_variable(ctx, expr.as_field);
|
||||||
|
emit_opcode(ctx, opcode::OP_CastFieldObject);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw gsc::comp_error(expr.as_node->loc, "unknown object type");
|
throw gsc::comp_error(expr.as_node->loc, "unknown object type");
|
||||||
break;
|
break;
|
||||||
|
@ -405,6 +405,12 @@ void compiler::emit_stmt_while(const gsc::context_ptr& ctx, const gsc::stmt_whil
|
|||||||
|
|
||||||
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
||||||
|
|
||||||
|
for(auto i = 0; i < ctx->local_vars_create_count; i++)
|
||||||
|
{
|
||||||
|
if(!ctx->local_vars.at(i).init)
|
||||||
|
ctx->local_vars.at(i).init = true;
|
||||||
|
}
|
||||||
|
|
||||||
auto begin_loc = insert_label();
|
auto begin_loc = insert_label();
|
||||||
|
|
||||||
bool const_cond = is_constant_condition(stmt->expr);
|
bool const_cond = is_constant_condition(stmt->expr);
|
||||||
@ -454,6 +460,13 @@ void compiler::emit_stmt_for(const gsc::context_ptr& ctx, const gsc::stmt_for_pt
|
|||||||
emit_create_local_vars(stmt->ctx);
|
emit_create_local_vars(stmt->ctx);
|
||||||
|
|
||||||
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
||||||
|
|
||||||
|
for(auto i = 0; i < ctx->local_vars_create_count; i++)
|
||||||
|
{
|
||||||
|
if(!ctx->local_vars.at(i).init)
|
||||||
|
ctx->local_vars.at(i).init = true;
|
||||||
|
}
|
||||||
|
|
||||||
ctx->transfer(stmt->ctx_post);
|
ctx->transfer(stmt->ctx_post);
|
||||||
|
|
||||||
auto begin_loc = insert_label();
|
auto begin_loc = insert_label();
|
||||||
@ -523,6 +536,12 @@ void compiler::emit_stmt_foreach(const gsc::context_ptr& ctx, const gsc::stmt_fo
|
|||||||
|
|
||||||
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
||||||
|
|
||||||
|
for(auto i = 0; i < ctx->local_vars_create_count; i++)
|
||||||
|
{
|
||||||
|
if(!ctx->local_vars.at(i).init)
|
||||||
|
ctx->local_vars.at(i).init = true;
|
||||||
|
}
|
||||||
|
|
||||||
ctx->transfer(stmt->ctx_post);
|
ctx->transfer(stmt->ctx_post);
|
||||||
|
|
||||||
auto begin_loc = insert_label();
|
auto begin_loc = insert_label();
|
||||||
@ -1469,7 +1488,6 @@ void compiler::emit_remove_local_vars(const gsc::context_ptr& ctx)
|
|||||||
|
|
||||||
void compiler::emit_object(const gsc::context_ptr& ctx, const gsc::expr_ptr& expr)
|
void compiler::emit_object(const gsc::context_ptr& ctx, const gsc::expr_ptr& expr)
|
||||||
{
|
{
|
||||||
// need revision used for clear variable
|
|
||||||
switch(expr.as_node->type)
|
switch(expr.as_node->type)
|
||||||
{
|
{
|
||||||
case gsc::node_t::data_level:
|
case gsc::node_t::data_level:
|
||||||
@ -1488,8 +1506,14 @@ void compiler::emit_object(const gsc::context_ptr& ctx, const gsc::expr_ptr& exp
|
|||||||
emit_expr_call(ctx, expr.as_call);
|
emit_expr_call(ctx, expr.as_call);
|
||||||
emit_opcode(ctx, opcode::OP_CastFieldObject);
|
emit_opcode(ctx, opcode::OP_CastFieldObject);
|
||||||
break;
|
break;
|
||||||
// array ?
|
case gsc::node_t::expr_array:
|
||||||
// field ?
|
emit_array_variable(ctx, expr.as_array);
|
||||||
|
emit_opcode(ctx, opcode::OP_CastFieldObject);
|
||||||
|
break;
|
||||||
|
case gsc::node_t::expr_field:
|
||||||
|
emit_field_variable(ctx, expr.as_field);
|
||||||
|
emit_opcode(ctx, opcode::OP_CastFieldObject);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw gsc::comp_error(expr.as_node->loc, "unknown object type");
|
throw gsc::comp_error(expr.as_node->loc, "unknown object type");
|
||||||
break;
|
break;
|
||||||
|
@ -405,6 +405,12 @@ void compiler::emit_stmt_while(const gsc::context_ptr& ctx, const gsc::stmt_whil
|
|||||||
|
|
||||||
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
||||||
|
|
||||||
|
for(auto i = 0; i < ctx->local_vars_create_count; i++)
|
||||||
|
{
|
||||||
|
if(!ctx->local_vars.at(i).init)
|
||||||
|
ctx->local_vars.at(i).init = true;
|
||||||
|
}
|
||||||
|
|
||||||
auto begin_loc = insert_label();
|
auto begin_loc = insert_label();
|
||||||
|
|
||||||
bool const_cond = is_constant_condition(stmt->expr);
|
bool const_cond = is_constant_condition(stmt->expr);
|
||||||
@ -454,6 +460,13 @@ void compiler::emit_stmt_for(const gsc::context_ptr& ctx, const gsc::stmt_for_pt
|
|||||||
emit_create_local_vars(stmt->ctx);
|
emit_create_local_vars(stmt->ctx);
|
||||||
|
|
||||||
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
||||||
|
|
||||||
|
for(auto i = 0; i < ctx->local_vars_create_count; i++)
|
||||||
|
{
|
||||||
|
if(!ctx->local_vars.at(i).init)
|
||||||
|
ctx->local_vars.at(i).init = true;
|
||||||
|
}
|
||||||
|
|
||||||
ctx->transfer(stmt->ctx_post);
|
ctx->transfer(stmt->ctx_post);
|
||||||
|
|
||||||
auto begin_loc = insert_label();
|
auto begin_loc = insert_label();
|
||||||
@ -523,6 +536,12 @@ void compiler::emit_stmt_foreach(const gsc::context_ptr& ctx, const gsc::stmt_fo
|
|||||||
|
|
||||||
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
||||||
|
|
||||||
|
for(auto i = 0; i < ctx->local_vars_create_count; i++)
|
||||||
|
{
|
||||||
|
if(!ctx->local_vars.at(i).init)
|
||||||
|
ctx->local_vars.at(i).init = true;
|
||||||
|
}
|
||||||
|
|
||||||
ctx->transfer(stmt->ctx_post);
|
ctx->transfer(stmt->ctx_post);
|
||||||
|
|
||||||
auto begin_loc = insert_label();
|
auto begin_loc = insert_label();
|
||||||
@ -1469,7 +1488,6 @@ void compiler::emit_remove_local_vars(const gsc::context_ptr& ctx)
|
|||||||
|
|
||||||
void compiler::emit_object(const gsc::context_ptr& ctx, const gsc::expr_ptr& expr)
|
void compiler::emit_object(const gsc::context_ptr& ctx, const gsc::expr_ptr& expr)
|
||||||
{
|
{
|
||||||
// need revision used for clear variable
|
|
||||||
switch(expr.as_node->type)
|
switch(expr.as_node->type)
|
||||||
{
|
{
|
||||||
case gsc::node_t::data_level:
|
case gsc::node_t::data_level:
|
||||||
@ -1488,8 +1506,14 @@ void compiler::emit_object(const gsc::context_ptr& ctx, const gsc::expr_ptr& exp
|
|||||||
emit_expr_call(ctx, expr.as_call);
|
emit_expr_call(ctx, expr.as_call);
|
||||||
emit_opcode(ctx, opcode::OP_CastFieldObject);
|
emit_opcode(ctx, opcode::OP_CastFieldObject);
|
||||||
break;
|
break;
|
||||||
// array ?
|
case gsc::node_t::expr_array:
|
||||||
// field ?
|
emit_array_variable(ctx, expr.as_array);
|
||||||
|
emit_opcode(ctx, opcode::OP_CastFieldObject);
|
||||||
|
break;
|
||||||
|
case gsc::node_t::expr_field:
|
||||||
|
emit_field_variable(ctx, expr.as_field);
|
||||||
|
emit_opcode(ctx, opcode::OP_CastFieldObject);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw gsc::comp_error(expr.as_node->loc, "unknown object type");
|
throw gsc::comp_error(expr.as_node->loc, "unknown object type");
|
||||||
break;
|
break;
|
||||||
|
@ -411,6 +411,12 @@ void compiler::emit_stmt_while(const gsc::context_ptr& ctx, const gsc::stmt_whil
|
|||||||
|
|
||||||
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
||||||
|
|
||||||
|
for(auto i = 0; i < ctx->local_vars_create_count; i++)
|
||||||
|
{
|
||||||
|
if(!ctx->local_vars.at(i).init)
|
||||||
|
ctx->local_vars.at(i).init = true;
|
||||||
|
}
|
||||||
|
|
||||||
auto begin_loc = insert_label();
|
auto begin_loc = insert_label();
|
||||||
|
|
||||||
bool const_cond = is_constant_condition(stmt->expr);
|
bool const_cond = is_constant_condition(stmt->expr);
|
||||||
@ -460,6 +466,13 @@ void compiler::emit_stmt_for(const gsc::context_ptr& ctx, const gsc::stmt_for_pt
|
|||||||
emit_create_local_vars(stmt->ctx);
|
emit_create_local_vars(stmt->ctx);
|
||||||
|
|
||||||
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
||||||
|
|
||||||
|
for(auto i = 0; i < ctx->local_vars_create_count; i++)
|
||||||
|
{
|
||||||
|
if(!ctx->local_vars.at(i).init)
|
||||||
|
ctx->local_vars.at(i).init = true;
|
||||||
|
}
|
||||||
|
|
||||||
ctx->transfer(stmt->ctx_post);
|
ctx->transfer(stmt->ctx_post);
|
||||||
|
|
||||||
auto begin_loc = insert_label();
|
auto begin_loc = insert_label();
|
||||||
@ -529,6 +542,12 @@ void compiler::emit_stmt_foreach(const gsc::context_ptr& ctx, const gsc::stmt_fo
|
|||||||
|
|
||||||
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
||||||
|
|
||||||
|
for(auto i = 0; i < ctx->local_vars_create_count; i++)
|
||||||
|
{
|
||||||
|
if(!ctx->local_vars.at(i).init)
|
||||||
|
ctx->local_vars.at(i).init = true;
|
||||||
|
}
|
||||||
|
|
||||||
ctx->transfer(stmt->ctx_post);
|
ctx->transfer(stmt->ctx_post);
|
||||||
|
|
||||||
auto begin_loc = insert_label();
|
auto begin_loc = insert_label();
|
||||||
@ -1475,7 +1494,6 @@ void compiler::emit_remove_local_vars(const gsc::context_ptr& ctx)
|
|||||||
|
|
||||||
void compiler::emit_object(const gsc::context_ptr& ctx, const gsc::expr_ptr& expr)
|
void compiler::emit_object(const gsc::context_ptr& ctx, const gsc::expr_ptr& expr)
|
||||||
{
|
{
|
||||||
// need revision used for clear variable
|
|
||||||
switch(expr.as_node->type)
|
switch(expr.as_node->type)
|
||||||
{
|
{
|
||||||
case gsc::node_t::data_level:
|
case gsc::node_t::data_level:
|
||||||
@ -1494,8 +1512,14 @@ void compiler::emit_object(const gsc::context_ptr& ctx, const gsc::expr_ptr& exp
|
|||||||
emit_expr_call(ctx, expr.as_call);
|
emit_expr_call(ctx, expr.as_call);
|
||||||
emit_opcode(ctx, opcode::OP_CastFieldObject);
|
emit_opcode(ctx, opcode::OP_CastFieldObject);
|
||||||
break;
|
break;
|
||||||
// array ?
|
case gsc::node_t::expr_array:
|
||||||
// field ?
|
emit_array_variable(ctx, expr.as_array);
|
||||||
|
emit_opcode(ctx, opcode::OP_CastFieldObject);
|
||||||
|
break;
|
||||||
|
case gsc::node_t::expr_field:
|
||||||
|
emit_field_variable(ctx, expr.as_field);
|
||||||
|
emit_opcode(ctx, opcode::OP_CastFieldObject);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw gsc::comp_error(expr.as_node->loc, "unknown object type");
|
throw gsc::comp_error(expr.as_node->loc, "unknown object type");
|
||||||
break;
|
break;
|
||||||
|
@ -411,6 +411,12 @@ void compiler::emit_stmt_while(const gsc::context_ptr& ctx, const gsc::stmt_whil
|
|||||||
|
|
||||||
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
||||||
|
|
||||||
|
for(auto i = 0; i < ctx->local_vars_create_count; i++)
|
||||||
|
{
|
||||||
|
if(!ctx->local_vars.at(i).init)
|
||||||
|
ctx->local_vars.at(i).init = true;
|
||||||
|
}
|
||||||
|
|
||||||
auto begin_loc = insert_label();
|
auto begin_loc = insert_label();
|
||||||
|
|
||||||
bool const_cond = is_constant_condition(stmt->expr);
|
bool const_cond = is_constant_condition(stmt->expr);
|
||||||
@ -460,6 +466,13 @@ void compiler::emit_stmt_for(const gsc::context_ptr& ctx, const gsc::stmt_for_pt
|
|||||||
emit_create_local_vars(stmt->ctx);
|
emit_create_local_vars(stmt->ctx);
|
||||||
|
|
||||||
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
||||||
|
|
||||||
|
for(auto i = 0; i < ctx->local_vars_create_count; i++)
|
||||||
|
{
|
||||||
|
if(!ctx->local_vars.at(i).init)
|
||||||
|
ctx->local_vars.at(i).init = true;
|
||||||
|
}
|
||||||
|
|
||||||
ctx->transfer(stmt->ctx_post);
|
ctx->transfer(stmt->ctx_post);
|
||||||
|
|
||||||
auto begin_loc = insert_label();
|
auto begin_loc = insert_label();
|
||||||
@ -529,6 +542,12 @@ void compiler::emit_stmt_foreach(const gsc::context_ptr& ctx, const gsc::stmt_fo
|
|||||||
|
|
||||||
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
|
||||||
|
|
||||||
|
for(auto i = 0; i < ctx->local_vars_create_count; i++)
|
||||||
|
{
|
||||||
|
if(!ctx->local_vars.at(i).init)
|
||||||
|
ctx->local_vars.at(i).init = true;
|
||||||
|
}
|
||||||
|
|
||||||
ctx->transfer(stmt->ctx_post);
|
ctx->transfer(stmt->ctx_post);
|
||||||
|
|
||||||
auto begin_loc = insert_label();
|
auto begin_loc = insert_label();
|
||||||
@ -1475,7 +1494,6 @@ void compiler::emit_remove_local_vars(const gsc::context_ptr& ctx)
|
|||||||
|
|
||||||
void compiler::emit_object(const gsc::context_ptr& ctx, const gsc::expr_ptr& expr)
|
void compiler::emit_object(const gsc::context_ptr& ctx, const gsc::expr_ptr& expr)
|
||||||
{
|
{
|
||||||
// need revision used for clear variable
|
|
||||||
switch(expr.as_node->type)
|
switch(expr.as_node->type)
|
||||||
{
|
{
|
||||||
case gsc::node_t::data_level:
|
case gsc::node_t::data_level:
|
||||||
@ -1494,8 +1512,14 @@ void compiler::emit_object(const gsc::context_ptr& ctx, const gsc::expr_ptr& exp
|
|||||||
emit_expr_call(ctx, expr.as_call);
|
emit_expr_call(ctx, expr.as_call);
|
||||||
emit_opcode(ctx, opcode::OP_CastFieldObject);
|
emit_opcode(ctx, opcode::OP_CastFieldObject);
|
||||||
break;
|
break;
|
||||||
// array ?
|
case gsc::node_t::expr_array:
|
||||||
// field ?
|
emit_array_variable(ctx, expr.as_array);
|
||||||
|
emit_opcode(ctx, opcode::OP_CastFieldObject);
|
||||||
|
break;
|
||||||
|
case gsc::node_t::expr_field:
|
||||||
|
emit_field_variable(ctx, expr.as_field);
|
||||||
|
emit_opcode(ctx, opcode::OP_CastFieldObject);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw gsc::comp_error(expr.as_node->loc, "unknown object type");
|
throw gsc::comp_error(expr.as_node->loc, "unknown object type");
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user