fixes
This commit is contained in:
parent
1a47d46ae8
commit
698053dbab
@ -384,19 +384,19 @@ void assembler::assemble_builtin_call(const gsc::instruction_ptr& inst, bool met
|
|||||||
|
|
||||||
if (arg_num)
|
if (arg_num)
|
||||||
{
|
{
|
||||||
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stol(inst->data[0])));
|
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stoi(inst->data[0])));
|
||||||
|
|
||||||
if (method)
|
if (method)
|
||||||
id = inst->data[1].substr(0, 3) == "_ID" ? std::stol(inst->data[1].substr(3)) : resolver::method_id(inst->data[1]);
|
id = inst->data[1].substr(0, 3) == "_ID" ? std::stoi(inst->data[1].substr(3)) : resolver::method_id(inst->data[1]);
|
||||||
else
|
else
|
||||||
id = inst->data[1].substr(0, 3) == "_ID" ? std::stol(inst->data[1].substr(3)) : resolver::function_id(inst->data[1]);
|
id = inst->data[1].substr(0, 3) == "_ID" ? std::stoi(inst->data[1].substr(3)) : resolver::function_id(inst->data[1]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (method)
|
if (method)
|
||||||
id = inst->data[0].substr(0, 3) == "_ID" ? std::stol(inst->data[0].substr(3)) : resolver::method_id(inst->data[0]);
|
id = inst->data[0].substr(0, 3) == "_ID" ? std::stoi(inst->data[0].substr(3)) : resolver::method_id(inst->data[0]);
|
||||||
else
|
else
|
||||||
id = inst->data[0].substr(0, 3) == "_ID" ? std::stol(inst->data[0].substr(3)) : resolver::function_id(inst->data[0]);
|
id = inst->data[0].substr(0, 3) == "_ID" ? std::stoi(inst->data[0].substr(3)) : resolver::function_id(inst->data[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
script_->write<std::uint16_t>(id);
|
script_->write<std::uint16_t>(id);
|
||||||
@ -414,7 +414,7 @@ void assembler::assemble_local_call(const gsc::instruction_ptr& inst, bool threa
|
|||||||
|
|
||||||
if (thread)
|
if (thread)
|
||||||
{
|
{
|
||||||
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stol(inst->data[1])));
|
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stoi(inst->data[1])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -429,15 +429,15 @@ void assembler::assemble_far_call(const gsc::instruction_ptr& inst, bool thread)
|
|||||||
|
|
||||||
if (thread)
|
if (thread)
|
||||||
{
|
{
|
||||||
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stol(inst->data[0])));
|
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stoi(inst->data[0])));
|
||||||
|
|
||||||
file_id = inst->data[1].substr(0, 3) == "_ID" ? std::stol(inst->data[1].substr(3)) : resolver::file_id(inst->data[1]);
|
file_id = inst->data[1].substr(0, 3) == "_ID" ? std::stoi(inst->data[1].substr(3)) : resolver::file_id(inst->data[1]);
|
||||||
func_id = inst->data[2].substr(0, 3) == "_ID" ? std::stol(inst->data[2].substr(3)) : resolver::token_id(inst->data[2]);
|
func_id = inst->data[2].substr(0, 3) == "_ID" ? std::stoi(inst->data[2].substr(3)) : resolver::token_id(inst->data[2]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
file_id = inst->data[0].substr(0, 3) == "_ID" ? std::stol(inst->data[0].substr(3)) : resolver::file_id(inst->data[0]);
|
file_id = inst->data[0].substr(0, 3) == "_ID" ? std::stoi(inst->data[0].substr(3)) : resolver::file_id(inst->data[0]);
|
||||||
func_id = inst->data[1].substr(0, 3) == "_ID" ? std::stol(inst->data[1].substr(3)) : resolver::token_id(inst->data[1]);
|
func_id = inst->data[1].substr(0, 3) == "_ID" ? std::stoi(inst->data[1].substr(3)) : resolver::token_id(inst->data[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
stack_->write<std::uint16_t>(file_id);
|
stack_->write<std::uint16_t>(file_id);
|
||||||
@ -463,7 +463,7 @@ void assembler::assemble_end_switch(const gsc::instruction_ptr& inst)
|
|||||||
|
|
||||||
if (utils::string::is_number(inst->data[0]))
|
if (utils::string::is_number(inst->data[0]))
|
||||||
{
|
{
|
||||||
casenum = std::stol(inst->data[0]);
|
casenum = std::stoi(inst->data[0]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -480,7 +480,7 @@ void assembler::assemble_end_switch(const gsc::instruction_ptr& inst)
|
|||||||
{
|
{
|
||||||
if (utils::string::is_number(inst->data[1 + (3 * i) + 1]))
|
if (utils::string::is_number(inst->data[1 + (3 * i) + 1]))
|
||||||
{
|
{
|
||||||
script_->write<uint32_t>((std::stol(inst->data[1 + (3 * i) + 1]) & 0xFFFFFF) + 0x800000);
|
script_->write<uint32_t>((std::stoi(inst->data[1 + (3 * i) + 1]) & 0xFFFFFF) + 0x800000);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -519,7 +519,7 @@ void assembler::assemble_field_variable(const gsc::instruction_ptr& inst)
|
|||||||
|
|
||||||
if (inst->data[0].substr(0, 3) == "_ID")
|
if (inst->data[0].substr(0, 3) == "_ID")
|
||||||
{
|
{
|
||||||
field_id = (std::uint16_t)std::stol(inst->data[0].substr(3));
|
field_id = (std::uint16_t)std::stoi(inst->data[0].substr(3));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1140,6 +1140,10 @@ void compiler::emit_expr_function(const gsc::context_ptr& ctx, const gsc::expr_f
|
|||||||
{
|
{
|
||||||
far = true;
|
far = true;
|
||||||
}
|
}
|
||||||
|
else if(is_include_call(name, file))
|
||||||
|
{
|
||||||
|
far = true;
|
||||||
|
}
|
||||||
else if(is_builtin_method(name))
|
else if(is_builtin_method(name))
|
||||||
{
|
{
|
||||||
builtin = true;
|
builtin = true;
|
||||||
@ -1153,6 +1157,10 @@ void compiler::emit_expr_function(const gsc::context_ptr& ctx, const gsc::expr_f
|
|||||||
{
|
{
|
||||||
local = true;
|
local = true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw gsc::comp_error(expr->loc, "couldn't determine function reference type");
|
||||||
|
}
|
||||||
|
|
||||||
if(local)
|
if(local)
|
||||||
{
|
{
|
||||||
@ -1634,7 +1642,7 @@ void compiler::emit_integer(const gsc::context_ptr& ctx, const gsc::integer_ptr&
|
|||||||
{
|
{
|
||||||
emit_opcode(ctx, opcode::OP_GetNegByte, num->value.substr(1));
|
emit_opcode(ctx, opcode::OP_GetNegByte, num->value.substr(1));
|
||||||
}
|
}
|
||||||
else if(value < 65536)
|
else if(value > 0 && value < 65536)
|
||||||
{
|
{
|
||||||
emit_opcode(ctx, opcode::OP_GetUnsignedShort, num->value);
|
emit_opcode(ctx, opcode::OP_GetUnsignedShort, num->value);
|
||||||
}
|
}
|
||||||
@ -2203,6 +2211,23 @@ auto compiler::variable_initialized(const gsc::context_ptr& ctx, const gsc::name
|
|||||||
throw gsc::comp_error(name->loc, "local variable '" + name->value + "' not found.");
|
throw gsc::comp_error(name->loc, "local variable '" + name->value + "' not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto compiler::is_include_call(const std::string& name, std::string& file) -> bool
|
||||||
|
{
|
||||||
|
for(const auto& inc : includes_)
|
||||||
|
{
|
||||||
|
for(const auto& fun : inc.funcs)
|
||||||
|
{
|
||||||
|
if(name == fun)
|
||||||
|
{
|
||||||
|
file = inc.name;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
auto compiler::is_local_call(const std::string& name) -> bool
|
auto compiler::is_local_call(const std::string& name) -> bool
|
||||||
{
|
{
|
||||||
for(const auto& f : local_functions_)
|
for(const auto& f : local_functions_)
|
||||||
|
@ -131,6 +131,7 @@ private:
|
|||||||
auto variable_create_index(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> std::string;
|
auto variable_create_index(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> std::string;
|
||||||
auto variable_access_index(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> std::string;
|
auto variable_access_index(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> std::string;
|
||||||
auto variable_initialized(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> bool;
|
auto variable_initialized(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> bool;
|
||||||
|
auto is_include_call(const std::string& name, std::string& file) -> bool;
|
||||||
auto is_local_call(const std::string& name) -> bool;
|
auto is_local_call(const std::string& name) -> bool;
|
||||||
auto is_builtin_call(const std::string& name) -> bool;
|
auto is_builtin_call(const std::string& name) -> bool;
|
||||||
auto is_builtin_func(const std::string& name) -> bool;
|
auto is_builtin_func(const std::string& name) -> bool;
|
||||||
|
@ -384,19 +384,19 @@ void assembler::assemble_builtin_call(const gsc::instruction_ptr& inst, bool met
|
|||||||
|
|
||||||
if (arg_num)
|
if (arg_num)
|
||||||
{
|
{
|
||||||
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stol(inst->data[0])));
|
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stoi(inst->data[0])));
|
||||||
|
|
||||||
if (method)
|
if (method)
|
||||||
id = inst->data[1].substr(0, 3) == "_ID" ? std::stol(inst->data[1].substr(3)) : resolver::method_id(inst->data[1]);
|
id = inst->data[1].substr(0, 3) == "_ID" ? std::stoi(inst->data[1].substr(3)) : resolver::method_id(inst->data[1]);
|
||||||
else
|
else
|
||||||
id = inst->data[1].substr(0, 3) == "_ID" ? std::stol(inst->data[1].substr(3)) : resolver::function_id(inst->data[1]);
|
id = inst->data[1].substr(0, 3) == "_ID" ? std::stoi(inst->data[1].substr(3)) : resolver::function_id(inst->data[1]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (method)
|
if (method)
|
||||||
id = inst->data[0].substr(0, 3) == "_ID" ? std::stol(inst->data[0].substr(3)) : resolver::method_id(inst->data[0]);
|
id = inst->data[0].substr(0, 3) == "_ID" ? std::stoi(inst->data[0].substr(3)) : resolver::method_id(inst->data[0]);
|
||||||
else
|
else
|
||||||
id = inst->data[0].substr(0, 3) == "_ID" ? std::stol(inst->data[0].substr(3)) : resolver::function_id(inst->data[0]);
|
id = inst->data[0].substr(0, 3) == "_ID" ? std::stoi(inst->data[0].substr(3)) : resolver::function_id(inst->data[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
script_->write<std::uint16_t>(id);
|
script_->write<std::uint16_t>(id);
|
||||||
@ -414,7 +414,7 @@ void assembler::assemble_local_call(const gsc::instruction_ptr& inst, bool threa
|
|||||||
|
|
||||||
if (thread)
|
if (thread)
|
||||||
{
|
{
|
||||||
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stol(inst->data[1])));
|
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stoi(inst->data[1])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -429,15 +429,15 @@ void assembler::assemble_far_call(const gsc::instruction_ptr& inst, bool thread)
|
|||||||
|
|
||||||
if (thread)
|
if (thread)
|
||||||
{
|
{
|
||||||
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stol(inst->data[0])));
|
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stoi(inst->data[0])));
|
||||||
|
|
||||||
file_id = inst->data[1].substr(0, 3) == "_ID" ? std::stol(inst->data[1].substr(3)) : resolver::file_id(inst->data[1]);
|
file_id = inst->data[1].substr(0, 3) == "_ID" ? std::stoi(inst->data[1].substr(3)) : resolver::file_id(inst->data[1]);
|
||||||
func_id = inst->data[2].substr(0, 3) == "_ID" ? std::stol(inst->data[2].substr(3)) : resolver::token_id(inst->data[2]);
|
func_id = inst->data[2].substr(0, 3) == "_ID" ? std::stoi(inst->data[2].substr(3)) : resolver::token_id(inst->data[2]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
file_id = inst->data[0].substr(0, 3) == "_ID" ? std::stol(inst->data[0].substr(3)) : resolver::file_id(inst->data[0]);
|
file_id = inst->data[0].substr(0, 3) == "_ID" ? std::stoi(inst->data[0].substr(3)) : resolver::file_id(inst->data[0]);
|
||||||
func_id = inst->data[1].substr(0, 3) == "_ID" ? std::stol(inst->data[1].substr(3)) : resolver::token_id(inst->data[1]);
|
func_id = inst->data[1].substr(0, 3) == "_ID" ? std::stoi(inst->data[1].substr(3)) : resolver::token_id(inst->data[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
stack_->write<std::uint16_t>(file_id);
|
stack_->write<std::uint16_t>(file_id);
|
||||||
@ -463,7 +463,7 @@ void assembler::assemble_end_switch(const gsc::instruction_ptr& inst)
|
|||||||
|
|
||||||
if (utils::string::is_number(inst->data[0]))
|
if (utils::string::is_number(inst->data[0]))
|
||||||
{
|
{
|
||||||
casenum = std::stol(inst->data[0]);
|
casenum = std::stoi(inst->data[0]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -480,7 +480,7 @@ void assembler::assemble_end_switch(const gsc::instruction_ptr& inst)
|
|||||||
{
|
{
|
||||||
if (utils::string::is_number(inst->data[1 + (3 * i) + 1]))
|
if (utils::string::is_number(inst->data[1 + (3 * i) + 1]))
|
||||||
{
|
{
|
||||||
script_->write<uint32_t>((std::stol(inst->data[1 + (3 * i) + 1]) & 0xFFFFFF) + 0x800000);
|
script_->write<uint32_t>((std::stoi(inst->data[1 + (3 * i) + 1]) & 0xFFFFFF) + 0x800000);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -519,7 +519,7 @@ void assembler::assemble_field_variable(const gsc::instruction_ptr& inst)
|
|||||||
|
|
||||||
if (inst->data[0].substr(0, 3) == "_ID")
|
if (inst->data[0].substr(0, 3) == "_ID")
|
||||||
{
|
{
|
||||||
field_id = (std::uint16_t)std::stol(inst->data[0].substr(3));
|
field_id = (std::uint16_t)std::stoi(inst->data[0].substr(3));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1140,6 +1140,10 @@ void compiler::emit_expr_function(const gsc::context_ptr& ctx, const gsc::expr_f
|
|||||||
{
|
{
|
||||||
far = true;
|
far = true;
|
||||||
}
|
}
|
||||||
|
else if(is_include_call(name, file))
|
||||||
|
{
|
||||||
|
far = true;
|
||||||
|
}
|
||||||
else if(is_builtin_method(name))
|
else if(is_builtin_method(name))
|
||||||
{
|
{
|
||||||
builtin = true;
|
builtin = true;
|
||||||
@ -1153,6 +1157,10 @@ void compiler::emit_expr_function(const gsc::context_ptr& ctx, const gsc::expr_f
|
|||||||
{
|
{
|
||||||
local = true;
|
local = true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw gsc::comp_error(expr->loc, "couldn't determine function reference type");
|
||||||
|
}
|
||||||
|
|
||||||
if(local)
|
if(local)
|
||||||
{
|
{
|
||||||
@ -1634,7 +1642,7 @@ void compiler::emit_integer(const gsc::context_ptr& ctx, const gsc::integer_ptr&
|
|||||||
{
|
{
|
||||||
emit_opcode(ctx, opcode::OP_GetNegByte, num->value.substr(1));
|
emit_opcode(ctx, opcode::OP_GetNegByte, num->value.substr(1));
|
||||||
}
|
}
|
||||||
else if(value < 65536)
|
else if(value > 0 && value < 65536)
|
||||||
{
|
{
|
||||||
emit_opcode(ctx, opcode::OP_GetUnsignedShort, num->value);
|
emit_opcode(ctx, opcode::OP_GetUnsignedShort, num->value);
|
||||||
}
|
}
|
||||||
@ -2203,6 +2211,23 @@ auto compiler::variable_initialized(const gsc::context_ptr& ctx, const gsc::name
|
|||||||
throw gsc::comp_error(name->loc, "local variable '" + name->value + "' not found.");
|
throw gsc::comp_error(name->loc, "local variable '" + name->value + "' not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto compiler::is_include_call(const std::string& name, std::string& file) -> bool
|
||||||
|
{
|
||||||
|
for(const auto& inc : includes_)
|
||||||
|
{
|
||||||
|
for(const auto& fun : inc.funcs)
|
||||||
|
{
|
||||||
|
if(name == fun)
|
||||||
|
{
|
||||||
|
file = inc.name;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
auto compiler::is_local_call(const std::string& name) -> bool
|
auto compiler::is_local_call(const std::string& name) -> bool
|
||||||
{
|
{
|
||||||
for(const auto& f : local_functions_)
|
for(const auto& f : local_functions_)
|
||||||
|
@ -131,6 +131,7 @@ private:
|
|||||||
auto variable_create_index(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> std::string;
|
auto variable_create_index(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> std::string;
|
||||||
auto variable_access_index(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> std::string;
|
auto variable_access_index(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> std::string;
|
||||||
auto variable_initialized(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> bool;
|
auto variable_initialized(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> bool;
|
||||||
|
auto is_include_call(const std::string& name, std::string& file) -> bool;
|
||||||
auto is_local_call(const std::string& name) -> bool;
|
auto is_local_call(const std::string& name) -> bool;
|
||||||
auto is_builtin_call(const std::string& name) -> bool;
|
auto is_builtin_call(const std::string& name) -> bool;
|
||||||
auto is_builtin_func(const std::string& name) -> bool;
|
auto is_builtin_func(const std::string& name) -> bool;
|
||||||
|
@ -261,7 +261,7 @@ void assembler::assemble_instruction(const gsc::instruction_ptr& inst)
|
|||||||
break;
|
break;
|
||||||
case opcode::OP_waittillmatch:
|
case opcode::OP_waittillmatch:
|
||||||
script_->write<std::uint8_t>(static_cast<std::uint8_t>(inst->opcode));
|
script_->write<std::uint8_t>(static_cast<std::uint8_t>(inst->opcode));
|
||||||
script_->write<std::uint16_t>(static_cast<std::uint16_t>(std::stol(inst->data[0])));
|
script_->write<std::uint16_t>(static_cast<std::uint16_t>(std::stoi(inst->data[0])));
|
||||||
break;
|
break;
|
||||||
case opcode::OP_CreateLocalVariable:
|
case opcode::OP_CreateLocalVariable:
|
||||||
case opcode::OP_RemoveLocalVariables:
|
case opcode::OP_RemoveLocalVariables:
|
||||||
@ -278,7 +278,7 @@ void assembler::assemble_instruction(const gsc::instruction_ptr& inst)
|
|||||||
case opcode::OP_ClearLocalVariableFieldCached:
|
case opcode::OP_ClearLocalVariableFieldCached:
|
||||||
case opcode::OP_EvalLocalVariableObjectCached:
|
case opcode::OP_EvalLocalVariableObjectCached:
|
||||||
script_->write<std::uint8_t>(static_cast<std::uint8_t>(inst->opcode));
|
script_->write<std::uint8_t>(static_cast<std::uint8_t>(inst->opcode));
|
||||||
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stol(inst->data[0])));
|
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stoi(inst->data[0])));
|
||||||
break;
|
break;
|
||||||
case opcode::OP_EvalLevelFieldVariable:
|
case opcode::OP_EvalLevelFieldVariable:
|
||||||
case opcode::OP_EvalAnimFieldVariable:
|
case opcode::OP_EvalAnimFieldVariable:
|
||||||
@ -301,7 +301,7 @@ void assembler::assemble_instruction(const gsc::instruction_ptr& inst)
|
|||||||
case opcode::OP_CallBuiltinPointer:
|
case opcode::OP_CallBuiltinPointer:
|
||||||
case opcode::OP_CallBuiltinMethodPointer:
|
case opcode::OP_CallBuiltinMethodPointer:
|
||||||
script_->write<std::uint8_t>(static_cast<std::uint8_t>(inst->opcode));
|
script_->write<std::uint8_t>(static_cast<std::uint8_t>(inst->opcode));
|
||||||
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stol(inst->data[0])));
|
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stoi(inst->data[0])));
|
||||||
break;
|
break;
|
||||||
case opcode::OP_ScriptLocalFunctionCall2:
|
case opcode::OP_ScriptLocalFunctionCall2:
|
||||||
case opcode::OP_ScriptLocalFunctionCall:
|
case opcode::OP_ScriptLocalFunctionCall:
|
||||||
@ -382,19 +382,19 @@ void assembler::assemble_builtin_call(const gsc::instruction_ptr& inst, bool met
|
|||||||
|
|
||||||
if (arg_num)
|
if (arg_num)
|
||||||
{
|
{
|
||||||
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stol(inst->data[0])));
|
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stoi(inst->data[0])));
|
||||||
|
|
||||||
if (method)
|
if (method)
|
||||||
id = inst->data[1].substr(0, 3) == "_ID" ? std::stol(inst->data[1].substr(3)) : resolver::method_id(inst->data[1]);
|
id = inst->data[1].substr(0, 3) == "_ID" ? std::stoi(inst->data[1].substr(3)) : resolver::method_id(inst->data[1]);
|
||||||
else
|
else
|
||||||
id = inst->data[1].substr(0, 3) == "_ID" ? std::stol(inst->data[1].substr(3)) : resolver::function_id(inst->data[1]);
|
id = inst->data[1].substr(0, 3) == "_ID" ? std::stoi(inst->data[1].substr(3)) : resolver::function_id(inst->data[1]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (method)
|
if (method)
|
||||||
id = inst->data[0].substr(0, 3) == "_ID" ? std::stol(inst->data[0].substr(3)) : resolver::method_id(inst->data[0]);
|
id = inst->data[0].substr(0, 3) == "_ID" ? std::stoi(inst->data[0].substr(3)) : resolver::method_id(inst->data[0]);
|
||||||
else
|
else
|
||||||
id = inst->data[0].substr(0, 3) == "_ID" ? std::stol(inst->data[0].substr(3)) : resolver::function_id(inst->data[0]);
|
id = inst->data[0].substr(0, 3) == "_ID" ? std::stoi(inst->data[0].substr(3)) : resolver::function_id(inst->data[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
script_->write<std::uint16_t>(id);
|
script_->write<std::uint16_t>(id);
|
||||||
@ -412,7 +412,7 @@ void assembler::assemble_local_call(const gsc::instruction_ptr& inst, bool threa
|
|||||||
|
|
||||||
if (thread)
|
if (thread)
|
||||||
{
|
{
|
||||||
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stol(inst->data[1])));
|
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stoi(inst->data[1])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -427,15 +427,15 @@ void assembler::assemble_far_call(const gsc::instruction_ptr& inst, bool thread)
|
|||||||
|
|
||||||
if (thread)
|
if (thread)
|
||||||
{
|
{
|
||||||
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stol(inst->data[0])));
|
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stoi(inst->data[0])));
|
||||||
|
|
||||||
file_id = inst->data[1].substr(0, 3) == "_ID" ? std::stol(inst->data[1].substr(3)) : resolver::file_id(inst->data[1]);
|
file_id = inst->data[1].substr(0, 3) == "_ID" ? std::stoi(inst->data[1].substr(3)) : resolver::file_id(inst->data[1]);
|
||||||
func_id = inst->data[2].substr(0, 3) == "_ID" ? std::stol(inst->data[2].substr(3)) : resolver::token_id(inst->data[2]);
|
func_id = inst->data[2].substr(0, 3) == "_ID" ? std::stoi(inst->data[2].substr(3)) : resolver::token_id(inst->data[2]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
file_id = inst->data[0].substr(0, 3) == "_ID" ? std::stol(inst->data[0].substr(3)) : resolver::file_id(inst->data[0]);
|
file_id = inst->data[0].substr(0, 3) == "_ID" ? std::stoi(inst->data[0].substr(3)) : resolver::file_id(inst->data[0]);
|
||||||
func_id = inst->data[1].substr(0, 3) == "_ID" ? std::stol(inst->data[1].substr(3)) : resolver::token_id(inst->data[1]);
|
func_id = inst->data[1].substr(0, 3) == "_ID" ? std::stoi(inst->data[1].substr(3)) : resolver::token_id(inst->data[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
stack_->write<std::uint16_t>(file_id);
|
stack_->write<std::uint16_t>(file_id);
|
||||||
@ -462,7 +462,7 @@ void assembler::assemble_end_switch(const gsc::instruction_ptr& inst)
|
|||||||
throw asm_error("invalid endswitch number!");
|
throw asm_error("invalid endswitch number!");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint16_t casenum = std::stol(inst->data[0]);
|
std::uint16_t casenum = std::stoi(inst->data[0]);
|
||||||
|
|
||||||
script_->write<std::uint16_t>(casenum);
|
script_->write<std::uint16_t>(casenum);
|
||||||
|
|
||||||
@ -474,7 +474,7 @@ void assembler::assemble_end_switch(const gsc::instruction_ptr& inst)
|
|||||||
{
|
{
|
||||||
if (utils::string::is_number(inst->data[1 + (3 * i) + 1]))
|
if (utils::string::is_number(inst->data[1 + (3 * i) + 1]))
|
||||||
{
|
{
|
||||||
script_->write<uint32_t>((std::stol(inst->data[1 + (3 * i) + 1]) & 0xFFFFFF) + 0x800000);
|
script_->write<uint32_t>((std::stoi(inst->data[1 + (3 * i) + 1]) & 0xFFFFFF) + 0x800000);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -513,7 +513,7 @@ void assembler::assemble_field_variable(const gsc::instruction_ptr& inst)
|
|||||||
|
|
||||||
if (inst->data[0].substr(0, 3) == "_ID")
|
if (inst->data[0].substr(0, 3) == "_ID")
|
||||||
{
|
{
|
||||||
field_id = (std::uint16_t)std::stol(inst->data[0].substr(3));
|
field_id = (std::uint16_t)std::stoi(inst->data[0].substr(3));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1134,6 +1134,10 @@ void compiler::emit_expr_function(const gsc::context_ptr& ctx, const gsc::expr_f
|
|||||||
{
|
{
|
||||||
far = true;
|
far = true;
|
||||||
}
|
}
|
||||||
|
else if(is_include_call(name, file))
|
||||||
|
{
|
||||||
|
far = true;
|
||||||
|
}
|
||||||
else if(is_builtin_method(name))
|
else if(is_builtin_method(name))
|
||||||
{
|
{
|
||||||
builtin = true;
|
builtin = true;
|
||||||
@ -1147,6 +1151,10 @@ void compiler::emit_expr_function(const gsc::context_ptr& ctx, const gsc::expr_f
|
|||||||
{
|
{
|
||||||
local = true;
|
local = true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw gsc::comp_error(expr->loc, "couldn't determine function reference type");
|
||||||
|
}
|
||||||
|
|
||||||
if(local)
|
if(local)
|
||||||
{
|
{
|
||||||
@ -1628,7 +1636,7 @@ void compiler::emit_integer(const gsc::context_ptr& ctx, const gsc::integer_ptr&
|
|||||||
{
|
{
|
||||||
emit_opcode(ctx, opcode::OP_GetNegByte, num->value.substr(1));
|
emit_opcode(ctx, opcode::OP_GetNegByte, num->value.substr(1));
|
||||||
}
|
}
|
||||||
else if(value < 65536)
|
else if(value > 0 && value < 65536)
|
||||||
{
|
{
|
||||||
emit_opcode(ctx, opcode::OP_GetUnsignedShort, num->value);
|
emit_opcode(ctx, opcode::OP_GetUnsignedShort, num->value);
|
||||||
}
|
}
|
||||||
@ -2197,6 +2205,23 @@ auto compiler::variable_initialized(const gsc::context_ptr& ctx, const gsc::name
|
|||||||
throw gsc::comp_error(name->loc, "local variable '" + name->value + "' not found.");
|
throw gsc::comp_error(name->loc, "local variable '" + name->value + "' not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto compiler::is_include_call(const std::string& name, std::string& file) -> bool
|
||||||
|
{
|
||||||
|
for(const auto& inc : includes_)
|
||||||
|
{
|
||||||
|
for(const auto& fun : inc.funcs)
|
||||||
|
{
|
||||||
|
if(name == fun)
|
||||||
|
{
|
||||||
|
file = inc.name;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
auto compiler::is_local_call(const std::string& name) -> bool
|
auto compiler::is_local_call(const std::string& name) -> bool
|
||||||
{
|
{
|
||||||
for(const auto& f : local_functions_)
|
for(const auto& f : local_functions_)
|
||||||
@ -2812,6 +2837,61 @@ gsc::include_t compiler::include_common_scripts_utility_ =
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
gsc::include_t compiler::include_maps_mp_gametypes_hud_util_ =
|
||||||
|
{
|
||||||
|
"maps/mp/gametypes/_hud_util",
|
||||||
|
{
|
||||||
|
"setparent",
|
||||||
|
"getparent",
|
||||||
|
"addchild",
|
||||||
|
"removechild",
|
||||||
|
"setpoint",
|
||||||
|
"setpointbar",
|
||||||
|
"updatebar",
|
||||||
|
"updatebarscale",
|
||||||
|
"createfontstring",
|
||||||
|
"createserverfontstring",
|
||||||
|
"createservertimer",
|
||||||
|
"createtimer",
|
||||||
|
"createicon",
|
||||||
|
"createservericon",
|
||||||
|
"createserverbar",
|
||||||
|
"createbar",
|
||||||
|
"getcurrentfraction",
|
||||||
|
"createprimaryprogressbar",
|
||||||
|
"createprimaryprogressbartext",
|
||||||
|
"createteamprogressbar",
|
||||||
|
"createteamprogressbartext",
|
||||||
|
"setflashfrac",
|
||||||
|
"hideelem",
|
||||||
|
"showelem",
|
||||||
|
"flashthread",
|
||||||
|
"destroyelem",
|
||||||
|
"seticonshader",
|
||||||
|
"geticonshader",
|
||||||
|
"seticonsize",
|
||||||
|
"setwidth",
|
||||||
|
"setheight",
|
||||||
|
"setsize",
|
||||||
|
"updatechildren",
|
||||||
|
"transitionreset",
|
||||||
|
"transitionzoomin",
|
||||||
|
"transitionpulsefxin",
|
||||||
|
"transitionslidein",
|
||||||
|
"transitionslideout",
|
||||||
|
"transitionzoomout",
|
||||||
|
"transitionfadein",
|
||||||
|
"transitionfadeout",
|
||||||
|
"getweeklyref",
|
||||||
|
"getdailyref",
|
||||||
|
"ch_getprogress",
|
||||||
|
"ch_getstate",
|
||||||
|
"ch_setprogress",
|
||||||
|
"ch_setstate",
|
||||||
|
"ch_gettarget",
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
auto compiler::map_known_includes(const std::string& include) -> bool
|
auto compiler::map_known_includes(const std::string& include) -> bool
|
||||||
{
|
{
|
||||||
if(include == "maps/mp/_utility")
|
if(include == "maps/mp/_utility")
|
||||||
@ -2829,6 +2909,11 @@ auto compiler::map_known_includes(const std::string& include) -> bool
|
|||||||
includes_.push_back(include_common_scripts_createfx_);
|
includes_.push_back(include_common_scripts_createfx_);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else if(include == "maps/mp/gametypes/_hud_util")
|
||||||
|
{
|
||||||
|
includes_.push_back(include_maps_mp_gametypes_hud_util_);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -130,6 +130,7 @@ private:
|
|||||||
auto variable_create_index(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> std::string;
|
auto variable_create_index(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> std::string;
|
||||||
auto variable_access_index(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> std::string;
|
auto variable_access_index(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> std::string;
|
||||||
auto variable_initialized(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> bool;
|
auto variable_initialized(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> bool;
|
||||||
|
auto is_include_call(const std::string& name, std::string& file) -> bool;
|
||||||
auto is_local_call(const std::string& name) -> bool;
|
auto is_local_call(const std::string& name) -> bool;
|
||||||
auto is_builtin_call(const std::string& name) -> bool;
|
auto is_builtin_call(const std::string& name) -> bool;
|
||||||
auto is_builtin_func(const std::string& name) -> bool;
|
auto is_builtin_func(const std::string& name) -> bool;
|
||||||
@ -142,6 +143,7 @@ private:
|
|||||||
static gsc::include_t include_maps_mp_utility_;
|
static gsc::include_t include_maps_mp_utility_;
|
||||||
static gsc::include_t include_common_scripts_utility_;
|
static gsc::include_t include_common_scripts_utility_;
|
||||||
static gsc::include_t include_common_scripts_createfx_;
|
static gsc::include_t include_common_scripts_createfx_;
|
||||||
|
static gsc::include_t include_maps_mp_gametypes_hud_util_;
|
||||||
auto map_known_includes(const std::string& include) -> bool;
|
auto map_known_includes(const std::string& include) -> bool;
|
||||||
|
|
||||||
// debug
|
// debug
|
||||||
|
@ -383,19 +383,19 @@ void assembler::assemble_builtin_call(const gsc::instruction_ptr& inst, bool met
|
|||||||
|
|
||||||
if (arg_num)
|
if (arg_num)
|
||||||
{
|
{
|
||||||
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stol(inst->data[0])));
|
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stoi(inst->data[0])));
|
||||||
|
|
||||||
if (method)
|
if (method)
|
||||||
id = inst->data[1].substr(0, 3) == "_ID" ? std::stol(inst->data[1].substr(3)) : resolver::method_id(inst->data[1]);
|
id = inst->data[1].substr(0, 3) == "_ID" ? std::stoi(inst->data[1].substr(3)) : resolver::method_id(inst->data[1]);
|
||||||
else
|
else
|
||||||
id = inst->data[1].substr(0, 3) == "_ID" ? std::stol(inst->data[1].substr(3)) : resolver::function_id(inst->data[1]);
|
id = inst->data[1].substr(0, 3) == "_ID" ? std::stoi(inst->data[1].substr(3)) : resolver::function_id(inst->data[1]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (method)
|
if (method)
|
||||||
id = inst->data[0].substr(0, 3) == "_ID" ? std::stol(inst->data[0].substr(3)) : resolver::method_id(inst->data[0]);
|
id = inst->data[0].substr(0, 3) == "_ID" ? std::stoi(inst->data[0].substr(3)) : resolver::method_id(inst->data[0]);
|
||||||
else
|
else
|
||||||
id = inst->data[0].substr(0, 3) == "_ID" ? std::stol(inst->data[0].substr(3)) : resolver::function_id(inst->data[0]);
|
id = inst->data[0].substr(0, 3) == "_ID" ? std::stoi(inst->data[0].substr(3)) : resolver::function_id(inst->data[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
script_->write<std::uint16_t>(id);
|
script_->write<std::uint16_t>(id);
|
||||||
@ -413,7 +413,7 @@ void assembler::assemble_local_call(const gsc::instruction_ptr& inst, bool threa
|
|||||||
|
|
||||||
if (thread)
|
if (thread)
|
||||||
{
|
{
|
||||||
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stol(inst->data[1])));
|
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stoi(inst->data[1])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -428,15 +428,15 @@ void assembler::assemble_far_call(const gsc::instruction_ptr& inst, bool thread)
|
|||||||
|
|
||||||
if (thread)
|
if (thread)
|
||||||
{
|
{
|
||||||
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stol(inst->data[0])));
|
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stoi(inst->data[0])));
|
||||||
|
|
||||||
file_id = inst->data[1].substr(0, 3) == "_ID" ? std::stol(inst->data[1].substr(3)) : resolver::file_id(inst->data[1]);
|
file_id = inst->data[1].substr(0, 3) == "_ID" ? std::stoi(inst->data[1].substr(3)) : resolver::file_id(inst->data[1]);
|
||||||
func_id = inst->data[2].substr(0, 3) == "_ID" ? std::stol(inst->data[2].substr(3)) : resolver::token_id(inst->data[2]);
|
func_id = inst->data[2].substr(0, 3) == "_ID" ? std::stoi(inst->data[2].substr(3)) : resolver::token_id(inst->data[2]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
file_id = inst->data[0].substr(0, 3) == "_ID" ? std::stol(inst->data[0].substr(3)) : resolver::file_id(inst->data[0]);
|
file_id = inst->data[0].substr(0, 3) == "_ID" ? std::stoi(inst->data[0].substr(3)) : resolver::file_id(inst->data[0]);
|
||||||
func_id = inst->data[1].substr(0, 3) == "_ID" ? std::stol(inst->data[1].substr(3)) : resolver::token_id(inst->data[1]);
|
func_id = inst->data[1].substr(0, 3) == "_ID" ? std::stoi(inst->data[1].substr(3)) : resolver::token_id(inst->data[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
stack_->write<std::uint16_t>(file_id);
|
stack_->write<std::uint16_t>(file_id);
|
||||||
@ -462,7 +462,7 @@ void assembler::assemble_end_switch(const gsc::instruction_ptr& inst)
|
|||||||
|
|
||||||
if (utils::string::is_number(inst->data[0]))
|
if (utils::string::is_number(inst->data[0]))
|
||||||
{
|
{
|
||||||
casenum = std::stol(inst->data[0]);
|
casenum = std::stoi(inst->data[0]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -479,7 +479,7 @@ void assembler::assemble_end_switch(const gsc::instruction_ptr& inst)
|
|||||||
{
|
{
|
||||||
if (utils::string::is_number(inst->data[1 + (3 * i) + 1]))
|
if (utils::string::is_number(inst->data[1 + (3 * i) + 1]))
|
||||||
{
|
{
|
||||||
script_->write<uint32_t>((std::stol(inst->data[1 + (3 * i) + 1]) & 0xFFFFFF) + 0x800000);
|
script_->write<uint32_t>((std::stoi(inst->data[1 + (3 * i) + 1]) & 0xFFFFFF) + 0x800000);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -518,7 +518,7 @@ void assembler::assemble_field_variable(const gsc::instruction_ptr& inst)
|
|||||||
|
|
||||||
if (inst->data[0].substr(0, 3) == "_ID")
|
if (inst->data[0].substr(0, 3) == "_ID")
|
||||||
{
|
{
|
||||||
field_id = (std::uint16_t)std::stol(inst->data[0].substr(3));
|
field_id = (std::uint16_t)std::stoi(inst->data[0].substr(3));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1134,6 +1134,10 @@ void compiler::emit_expr_function(const gsc::context_ptr& ctx, const gsc::expr_f
|
|||||||
{
|
{
|
||||||
far = true;
|
far = true;
|
||||||
}
|
}
|
||||||
|
else if(is_include_call(name, file))
|
||||||
|
{
|
||||||
|
far = true;
|
||||||
|
}
|
||||||
else if(is_builtin_method(name))
|
else if(is_builtin_method(name))
|
||||||
{
|
{
|
||||||
builtin = true;
|
builtin = true;
|
||||||
@ -1147,6 +1151,10 @@ void compiler::emit_expr_function(const gsc::context_ptr& ctx, const gsc::expr_f
|
|||||||
{
|
{
|
||||||
local = true;
|
local = true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw gsc::comp_error(expr->loc, "couldn't determine function reference type");
|
||||||
|
}
|
||||||
|
|
||||||
if(local)
|
if(local)
|
||||||
{
|
{
|
||||||
@ -1628,7 +1636,7 @@ void compiler::emit_integer(const gsc::context_ptr& ctx, const gsc::integer_ptr&
|
|||||||
{
|
{
|
||||||
emit_opcode(ctx, opcode::OP_GetNegByte, num->value.substr(1));
|
emit_opcode(ctx, opcode::OP_GetNegByte, num->value.substr(1));
|
||||||
}
|
}
|
||||||
else if(value < 65536)
|
else if(value > 0 && value < 65536)
|
||||||
{
|
{
|
||||||
emit_opcode(ctx, opcode::OP_GetUnsignedShort, num->value);
|
emit_opcode(ctx, opcode::OP_GetUnsignedShort, num->value);
|
||||||
}
|
}
|
||||||
@ -2197,6 +2205,23 @@ auto compiler::variable_initialized(const gsc::context_ptr& ctx, const gsc::name
|
|||||||
throw gsc::comp_error(name->loc, "local variable '" + name->value + "' not found.");
|
throw gsc::comp_error(name->loc, "local variable '" + name->value + "' not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto compiler::is_include_call(const std::string& name, std::string& file) -> bool
|
||||||
|
{
|
||||||
|
for(const auto& inc : includes_)
|
||||||
|
{
|
||||||
|
for(const auto& fun : inc.funcs)
|
||||||
|
{
|
||||||
|
if(name == fun)
|
||||||
|
{
|
||||||
|
file = inc.name;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
auto compiler::is_local_call(const std::string& name) -> bool
|
auto compiler::is_local_call(const std::string& name) -> bool
|
||||||
{
|
{
|
||||||
for(const auto& f : local_functions_)
|
for(const auto& f : local_functions_)
|
||||||
|
@ -130,6 +130,7 @@ private:
|
|||||||
auto variable_create_index(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> std::string;
|
auto variable_create_index(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> std::string;
|
||||||
auto variable_access_index(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> std::string;
|
auto variable_access_index(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> std::string;
|
||||||
auto variable_initialized(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> bool;
|
auto variable_initialized(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> bool;
|
||||||
|
auto is_include_call(const std::string& name, std::string& file) -> bool;
|
||||||
auto is_local_call(const std::string& name) -> bool;
|
auto is_local_call(const std::string& name) -> bool;
|
||||||
auto is_builtin_call(const std::string& name) -> bool;
|
auto is_builtin_call(const std::string& name) -> bool;
|
||||||
auto is_builtin_func(const std::string& name) -> bool;
|
auto is_builtin_func(const std::string& name) -> bool;
|
||||||
|
@ -388,19 +388,19 @@ void assembler::assemble_builtin_call(const gsc::instruction_ptr& inst, bool met
|
|||||||
|
|
||||||
if (arg_num)
|
if (arg_num)
|
||||||
{
|
{
|
||||||
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stol(inst->data[0])));
|
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stoi(inst->data[0])));
|
||||||
|
|
||||||
if (method)
|
if (method)
|
||||||
id = inst->data[1].substr(0, 3) == "_ID" ? std::stol(inst->data[1].substr(3)) : resolver::method_id(inst->data[1]);
|
id = inst->data[1].substr(0, 3) == "_ID" ? std::stoi(inst->data[1].substr(3)) : resolver::method_id(inst->data[1]);
|
||||||
else
|
else
|
||||||
id = inst->data[1].substr(0, 3) == "_ID" ? std::stol(inst->data[1].substr(3)) : resolver::function_id(inst->data[1]);
|
id = inst->data[1].substr(0, 3) == "_ID" ? std::stoi(inst->data[1].substr(3)) : resolver::function_id(inst->data[1]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (method)
|
if (method)
|
||||||
id = inst->data[0].substr(0, 3) == "_ID" ? std::stol(inst->data[0].substr(3)) : resolver::method_id(inst->data[0]);
|
id = inst->data[0].substr(0, 3) == "_ID" ? std::stoi(inst->data[0].substr(3)) : resolver::method_id(inst->data[0]);
|
||||||
else
|
else
|
||||||
id = inst->data[0].substr(0, 3) == "_ID" ? std::stol(inst->data[0].substr(3)) : resolver::function_id(inst->data[0]);
|
id = inst->data[0].substr(0, 3) == "_ID" ? std::stoi(inst->data[0].substr(3)) : resolver::function_id(inst->data[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
script_->write<std::uint16_t>(id);
|
script_->write<std::uint16_t>(id);
|
||||||
@ -418,7 +418,7 @@ void assembler::assemble_local_call(const gsc::instruction_ptr& inst, bool threa
|
|||||||
|
|
||||||
if (thread)
|
if (thread)
|
||||||
{
|
{
|
||||||
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stol(inst->data[1])));
|
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stoi(inst->data[1])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -433,15 +433,15 @@ void assembler::assemble_far_call(const gsc::instruction_ptr& inst, bool thread)
|
|||||||
|
|
||||||
if (thread)
|
if (thread)
|
||||||
{
|
{
|
||||||
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stol(inst->data[0])));
|
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stoi(inst->data[0])));
|
||||||
|
|
||||||
file_id = inst->data[1].substr(0, 3) == "_ID" ? std::stol(inst->data[1].substr(3)) : resolver::file_id(inst->data[1]);
|
file_id = inst->data[1].substr(0, 3) == "_ID" ? std::stoi(inst->data[1].substr(3)) : resolver::file_id(inst->data[1]);
|
||||||
func_id = inst->data[2].substr(0, 3) == "_ID" ? std::stol(inst->data[2].substr(3)) : resolver::token_id(inst->data[2]);
|
func_id = inst->data[2].substr(0, 3) == "_ID" ? std::stoi(inst->data[2].substr(3)) : resolver::token_id(inst->data[2]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
file_id = inst->data[0].substr(0, 3) == "_ID" ? std::stol(inst->data[0].substr(3)) : resolver::file_id(inst->data[0]);
|
file_id = inst->data[0].substr(0, 3) == "_ID" ? std::stoi(inst->data[0].substr(3)) : resolver::file_id(inst->data[0]);
|
||||||
func_id = inst->data[1].substr(0, 3) == "_ID" ? std::stol(inst->data[1].substr(3)) : resolver::token_id(inst->data[1]);
|
func_id = inst->data[1].substr(0, 3) == "_ID" ? std::stoi(inst->data[1].substr(3)) : resolver::token_id(inst->data[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
stack_->write<std::uint32_t>(file_id);
|
stack_->write<std::uint32_t>(file_id);
|
||||||
@ -467,7 +467,7 @@ void assembler::assemble_end_switch(const gsc::instruction_ptr& inst)
|
|||||||
|
|
||||||
if (utils::string::is_number(inst->data[0]))
|
if (utils::string::is_number(inst->data[0]))
|
||||||
{
|
{
|
||||||
casenum = std::stol(inst->data[0]);
|
casenum = std::stoi(inst->data[0]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -484,7 +484,7 @@ void assembler::assemble_end_switch(const gsc::instruction_ptr& inst)
|
|||||||
{
|
{
|
||||||
if (utils::string::is_number(inst->data[1 + (3 * i) + 1]))
|
if (utils::string::is_number(inst->data[1 + (3 * i) + 1]))
|
||||||
{
|
{
|
||||||
script_->write<uint32_t>((std::stol(inst->data[1 + (3 * i) + 1]) & 0xFFFFFF) + 0x800000);
|
script_->write<uint32_t>((std::stoi(inst->data[1 + (3 * i) + 1]) & 0xFFFFFF) + 0x800000);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -523,7 +523,7 @@ void assembler::assemble_field_variable(const gsc::instruction_ptr& inst)
|
|||||||
|
|
||||||
if (inst->data[0].substr(0, 3) == "_ID")
|
if (inst->data[0].substr(0, 3) == "_ID")
|
||||||
{
|
{
|
||||||
field_id = std::stoul(inst->data[0].substr(3));
|
field_id = std::stoi(inst->data[0].substr(3));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1134,6 +1134,10 @@ void compiler::emit_expr_function(const gsc::context_ptr& ctx, const gsc::expr_f
|
|||||||
{
|
{
|
||||||
far = true;
|
far = true;
|
||||||
}
|
}
|
||||||
|
else if(is_include_call(name, file))
|
||||||
|
{
|
||||||
|
far = true;
|
||||||
|
}
|
||||||
else if(is_builtin_method(name))
|
else if(is_builtin_method(name))
|
||||||
{
|
{
|
||||||
builtin = true;
|
builtin = true;
|
||||||
@ -1147,6 +1151,10 @@ void compiler::emit_expr_function(const gsc::context_ptr& ctx, const gsc::expr_f
|
|||||||
{
|
{
|
||||||
local = true;
|
local = true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw gsc::comp_error(expr->loc, "couldn't determine function reference type");
|
||||||
|
}
|
||||||
|
|
||||||
if(local)
|
if(local)
|
||||||
{
|
{
|
||||||
@ -1628,7 +1636,7 @@ void compiler::emit_integer(const gsc::context_ptr& ctx, const gsc::integer_ptr&
|
|||||||
{
|
{
|
||||||
emit_opcode(ctx, opcode::OP_GetNegByte, num->value.substr(1));
|
emit_opcode(ctx, opcode::OP_GetNegByte, num->value.substr(1));
|
||||||
}
|
}
|
||||||
else if(value < 65536)
|
else if(value > 0 && value < 65536)
|
||||||
{
|
{
|
||||||
emit_opcode(ctx, opcode::OP_GetUnsignedShort, num->value);
|
emit_opcode(ctx, opcode::OP_GetUnsignedShort, num->value);
|
||||||
}
|
}
|
||||||
@ -2197,6 +2205,23 @@ auto compiler::variable_initialized(const gsc::context_ptr& ctx, const gsc::name
|
|||||||
throw gsc::comp_error(name->loc, "local variable '" + name->value + "' not found.");
|
throw gsc::comp_error(name->loc, "local variable '" + name->value + "' not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto compiler::is_include_call(const std::string& name, std::string& file) -> bool
|
||||||
|
{
|
||||||
|
for(const auto& inc : includes_)
|
||||||
|
{
|
||||||
|
for(const auto& fun : inc.funcs)
|
||||||
|
{
|
||||||
|
if(name == fun)
|
||||||
|
{
|
||||||
|
file = inc.name;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
auto compiler::is_local_call(const std::string& name) -> bool
|
auto compiler::is_local_call(const std::string& name) -> bool
|
||||||
{
|
{
|
||||||
for(const auto& f : local_functions_)
|
for(const auto& f : local_functions_)
|
||||||
|
@ -130,6 +130,7 @@ private:
|
|||||||
auto variable_create_index(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> std::string;
|
auto variable_create_index(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> std::string;
|
||||||
auto variable_access_index(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> std::string;
|
auto variable_access_index(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> std::string;
|
||||||
auto variable_initialized(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> bool;
|
auto variable_initialized(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> bool;
|
||||||
|
auto is_include_call(const std::string& name, std::string& file) -> bool;
|
||||||
auto is_local_call(const std::string& name) -> bool;
|
auto is_local_call(const std::string& name) -> bool;
|
||||||
auto is_builtin_call(const std::string& name) -> bool;
|
auto is_builtin_call(const std::string& name) -> bool;
|
||||||
auto is_builtin_func(const std::string& name) -> bool;
|
auto is_builtin_func(const std::string& name) -> bool;
|
||||||
|
@ -384,19 +384,19 @@ void assembler::assemble_builtin_call(const gsc::instruction_ptr& inst, bool met
|
|||||||
|
|
||||||
if (arg_num)
|
if (arg_num)
|
||||||
{
|
{
|
||||||
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stol(inst->data[0])));
|
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stoi(inst->data[0])));
|
||||||
|
|
||||||
if (method)
|
if (method)
|
||||||
id = inst->data[1].substr(0, 3) == "_ID" ? std::stol(inst->data[1].substr(3)) : resolver::method_id(inst->data[1]);
|
id = inst->data[1].substr(0, 3) == "_ID" ? std::stoi(inst->data[1].substr(3)) : resolver::method_id(inst->data[1]);
|
||||||
else
|
else
|
||||||
id = inst->data[1].substr(0, 3) == "_ID" ? std::stol(inst->data[1].substr(3)) : resolver::function_id(inst->data[1]);
|
id = inst->data[1].substr(0, 3) == "_ID" ? std::stoi(inst->data[1].substr(3)) : resolver::function_id(inst->data[1]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (method)
|
if (method)
|
||||||
id = inst->data[0].substr(0, 3) == "_ID" ? std::stol(inst->data[0].substr(3)) : resolver::method_id(inst->data[0]);
|
id = inst->data[0].substr(0, 3) == "_ID" ? std::stoi(inst->data[0].substr(3)) : resolver::method_id(inst->data[0]);
|
||||||
else
|
else
|
||||||
id = inst->data[0].substr(0, 3) == "_ID" ? std::stol(inst->data[0].substr(3)) : resolver::function_id(inst->data[0]);
|
id = inst->data[0].substr(0, 3) == "_ID" ? std::stoi(inst->data[0].substr(3)) : resolver::function_id(inst->data[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
script_->write<std::uint16_t>(id);
|
script_->write<std::uint16_t>(id);
|
||||||
@ -414,7 +414,7 @@ void assembler::assemble_local_call(const gsc::instruction_ptr& inst, bool threa
|
|||||||
|
|
||||||
if (thread)
|
if (thread)
|
||||||
{
|
{
|
||||||
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stol(inst->data[1])));
|
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stoi(inst->data[1])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -429,15 +429,15 @@ void assembler::assemble_far_call(const gsc::instruction_ptr& inst, bool thread)
|
|||||||
|
|
||||||
if (thread)
|
if (thread)
|
||||||
{
|
{
|
||||||
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stol(inst->data[0])));
|
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stoi(inst->data[0])));
|
||||||
|
|
||||||
file_id = inst->data[1].substr(0, 3) == "_ID" ? std::stol(inst->data[1].substr(3)) : resolver::file_id(inst->data[1]);
|
file_id = inst->data[1].substr(0, 3) == "_ID" ? std::stoi(inst->data[1].substr(3)) : resolver::file_id(inst->data[1]);
|
||||||
func_id = inst->data[2].substr(0, 3) == "_ID" ? std::stol(inst->data[2].substr(3)) : resolver::token_id(inst->data[2]);
|
func_id = inst->data[2].substr(0, 3) == "_ID" ? std::stoi(inst->data[2].substr(3)) : resolver::token_id(inst->data[2]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
file_id = inst->data[0].substr(0, 3) == "_ID" ? std::stol(inst->data[0].substr(3)) : resolver::file_id(inst->data[0]);
|
file_id = inst->data[0].substr(0, 3) == "_ID" ? std::stoi(inst->data[0].substr(3)) : resolver::file_id(inst->data[0]);
|
||||||
func_id = inst->data[1].substr(0, 3) == "_ID" ? std::stol(inst->data[1].substr(3)) : resolver::token_id(inst->data[1]);
|
func_id = inst->data[1].substr(0, 3) == "_ID" ? std::stoi(inst->data[1].substr(3)) : resolver::token_id(inst->data[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
stack_->write<std::uint16_t>(file_id);
|
stack_->write<std::uint16_t>(file_id);
|
||||||
@ -463,7 +463,7 @@ void assembler::assemble_end_switch(const gsc::instruction_ptr& inst)
|
|||||||
|
|
||||||
if (utils::string::is_number(inst->data[0]))
|
if (utils::string::is_number(inst->data[0]))
|
||||||
{
|
{
|
||||||
casenum = std::stol(inst->data[0]);
|
casenum = std::stoi(inst->data[0]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -480,7 +480,7 @@ void assembler::assemble_end_switch(const gsc::instruction_ptr& inst)
|
|||||||
{
|
{
|
||||||
if (utils::string::is_number(inst->data[1 + (3 * i) + 1]))
|
if (utils::string::is_number(inst->data[1 + (3 * i) + 1]))
|
||||||
{
|
{
|
||||||
script_->write<uint32_t>((std::stol(inst->data[1 + (3 * i) + 1]) & 0xFFFFFF) + 0x800000);
|
script_->write<uint32_t>((std::stoi(inst->data[1 + (3 * i) + 1]) & 0xFFFFFF) + 0x800000);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -519,7 +519,7 @@ void assembler::assemble_field_variable(const gsc::instruction_ptr& inst)
|
|||||||
|
|
||||||
if (inst->data[0].substr(0, 3) == "_ID")
|
if (inst->data[0].substr(0, 3) == "_ID")
|
||||||
{
|
{
|
||||||
field_id = (std::uint16_t)std::stol(inst->data[0].substr(3));
|
field_id = (std::uint16_t)std::stoi(inst->data[0].substr(3));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1140,6 +1140,10 @@ void compiler::emit_expr_function(const gsc::context_ptr& ctx, const gsc::expr_f
|
|||||||
{
|
{
|
||||||
far = true;
|
far = true;
|
||||||
}
|
}
|
||||||
|
else if(is_include_call(name, file))
|
||||||
|
{
|
||||||
|
far = true;
|
||||||
|
}
|
||||||
else if(is_builtin_method(name))
|
else if(is_builtin_method(name))
|
||||||
{
|
{
|
||||||
builtin = true;
|
builtin = true;
|
||||||
@ -1153,6 +1157,10 @@ void compiler::emit_expr_function(const gsc::context_ptr& ctx, const gsc::expr_f
|
|||||||
{
|
{
|
||||||
local = true;
|
local = true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw gsc::comp_error(expr->loc, "couldn't determine function reference type");
|
||||||
|
}
|
||||||
|
|
||||||
if(local)
|
if(local)
|
||||||
{
|
{
|
||||||
@ -1634,7 +1642,7 @@ void compiler::emit_integer(const gsc::context_ptr& ctx, const gsc::integer_ptr&
|
|||||||
{
|
{
|
||||||
emit_opcode(ctx, opcode::OP_GetNegByte, num->value.substr(1));
|
emit_opcode(ctx, opcode::OP_GetNegByte, num->value.substr(1));
|
||||||
}
|
}
|
||||||
else if(value < 65536)
|
else if(value > 0 && value < 65536)
|
||||||
{
|
{
|
||||||
emit_opcode(ctx, opcode::OP_GetUnsignedShort, num->value);
|
emit_opcode(ctx, opcode::OP_GetUnsignedShort, num->value);
|
||||||
}
|
}
|
||||||
@ -2203,6 +2211,23 @@ auto compiler::variable_initialized(const gsc::context_ptr& ctx, const gsc::name
|
|||||||
throw gsc::comp_error(name->loc, "local variable '" + name->value + "' not found.");
|
throw gsc::comp_error(name->loc, "local variable '" + name->value + "' not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto compiler::is_include_call(const std::string& name, std::string& file) -> bool
|
||||||
|
{
|
||||||
|
for(const auto& inc : includes_)
|
||||||
|
{
|
||||||
|
for(const auto& fun : inc.funcs)
|
||||||
|
{
|
||||||
|
if(name == fun)
|
||||||
|
{
|
||||||
|
file = inc.name;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
auto compiler::is_local_call(const std::string& name) -> bool
|
auto compiler::is_local_call(const std::string& name) -> bool
|
||||||
{
|
{
|
||||||
for(const auto& f : local_functions_)
|
for(const auto& f : local_functions_)
|
||||||
|
@ -131,6 +131,7 @@ private:
|
|||||||
auto variable_create_index(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> std::string;
|
auto variable_create_index(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> std::string;
|
||||||
auto variable_access_index(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> std::string;
|
auto variable_access_index(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> std::string;
|
||||||
auto variable_initialized(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> bool;
|
auto variable_initialized(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> bool;
|
||||||
|
auto is_include_call(const std::string& name, std::string& file) -> bool;
|
||||||
auto is_local_call(const std::string& name) -> bool;
|
auto is_local_call(const std::string& name) -> bool;
|
||||||
auto is_builtin_call(const std::string& name) -> bool;
|
auto is_builtin_call(const std::string& name) -> bool;
|
||||||
auto is_builtin_func(const std::string& name) -> bool;
|
auto is_builtin_func(const std::string& name) -> bool;
|
||||||
|
@ -385,19 +385,19 @@ void assembler::assemble_builtin_call(const gsc::instruction_ptr& inst, bool met
|
|||||||
|
|
||||||
if (arg_num)
|
if (arg_num)
|
||||||
{
|
{
|
||||||
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stol(inst->data[0])));
|
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stoi(inst->data[0])));
|
||||||
|
|
||||||
if (method)
|
if (method)
|
||||||
id = inst->data[1].substr(0, 3) == "_ID" ? std::stol(inst->data[1].substr(3)) : resolver::method_id(inst->data[1]);
|
id = inst->data[1].substr(0, 3) == "_ID" ? std::stoi(inst->data[1].substr(3)) : resolver::method_id(inst->data[1]);
|
||||||
else
|
else
|
||||||
id = inst->data[1].substr(0, 3) == "_ID" ? std::stol(inst->data[1].substr(3)) : resolver::function_id(inst->data[1]);
|
id = inst->data[1].substr(0, 3) == "_ID" ? std::stoi(inst->data[1].substr(3)) : resolver::function_id(inst->data[1]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (method)
|
if (method)
|
||||||
id = inst->data[0].substr(0, 3) == "_ID" ? std::stol(inst->data[0].substr(3)) : resolver::method_id(inst->data[0]);
|
id = inst->data[0].substr(0, 3) == "_ID" ? std::stoi(inst->data[0].substr(3)) : resolver::method_id(inst->data[0]);
|
||||||
else
|
else
|
||||||
id = inst->data[0].substr(0, 3) == "_ID" ? std::stol(inst->data[0].substr(3)) : resolver::function_id(inst->data[0]);
|
id = inst->data[0].substr(0, 3) == "_ID" ? std::stoi(inst->data[0].substr(3)) : resolver::function_id(inst->data[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
script_->write<std::uint16_t>(id);
|
script_->write<std::uint16_t>(id);
|
||||||
@ -415,7 +415,7 @@ void assembler::assemble_local_call(const gsc::instruction_ptr& inst, bool threa
|
|||||||
|
|
||||||
if (thread)
|
if (thread)
|
||||||
{
|
{
|
||||||
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stol(inst->data[1])));
|
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stoi(inst->data[1])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -430,15 +430,15 @@ void assembler::assemble_far_call(const gsc::instruction_ptr& inst, bool thread)
|
|||||||
|
|
||||||
if (thread)
|
if (thread)
|
||||||
{
|
{
|
||||||
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stol(inst->data[0])));
|
script_->write<std::uint8_t>(static_cast<std::uint8_t>(std::stoi(inst->data[0])));
|
||||||
|
|
||||||
file_id = inst->data[1].substr(0, 3) == "_ID" ? std::stol(inst->data[1].substr(3)) : resolver::file_id(inst->data[1]);
|
file_id = inst->data[1].substr(0, 3) == "_ID" ? std::stoi(inst->data[1].substr(3)) : resolver::file_id(inst->data[1]);
|
||||||
func_id = inst->data[2].substr(0, 3) == "_ID" ? std::stol(inst->data[2].substr(3)) : resolver::token_id(inst->data[2]);
|
func_id = inst->data[2].substr(0, 3) == "_ID" ? std::stoi(inst->data[2].substr(3)) : resolver::token_id(inst->data[2]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
file_id = inst->data[0].substr(0, 3) == "_ID" ? std::stol(inst->data[0].substr(3)) : resolver::file_id(inst->data[0]);
|
file_id = inst->data[0].substr(0, 3) == "_ID" ? std::stoi(inst->data[0].substr(3)) : resolver::file_id(inst->data[0]);
|
||||||
func_id = inst->data[1].substr(0, 3) == "_ID" ? std::stol(inst->data[1].substr(3)) : resolver::token_id(inst->data[1]);
|
func_id = inst->data[1].substr(0, 3) == "_ID" ? std::stoi(inst->data[1].substr(3)) : resolver::token_id(inst->data[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
stack_->write<std::uint16_t>(file_id);
|
stack_->write<std::uint16_t>(file_id);
|
||||||
@ -464,7 +464,7 @@ void assembler::assemble_end_switch(const gsc::instruction_ptr& inst)
|
|||||||
|
|
||||||
if (utils::string::is_number(inst->data[0]))
|
if (utils::string::is_number(inst->data[0]))
|
||||||
{
|
{
|
||||||
casenum = std::stol(inst->data[0]);
|
casenum = std::stoi(inst->data[0]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -481,7 +481,7 @@ void assembler::assemble_end_switch(const gsc::instruction_ptr& inst)
|
|||||||
{
|
{
|
||||||
if (utils::string::is_number(inst->data[1 + (3 * i) + 1]))
|
if (utils::string::is_number(inst->data[1 + (3 * i) + 1]))
|
||||||
{
|
{
|
||||||
script_->write<uint32_t>((std::stol(inst->data[1 + (3 * i) + 1]) & 0xFFFFFF) + 0x800000);
|
script_->write<uint32_t>((std::stoi(inst->data[1 + (3 * i) + 1]) & 0xFFFFFF) + 0x800000);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -520,7 +520,7 @@ void assembler::assemble_field_variable(const gsc::instruction_ptr& inst)
|
|||||||
|
|
||||||
if (inst->data[0].substr(0, 3) == "_ID")
|
if (inst->data[0].substr(0, 3) == "_ID")
|
||||||
{
|
{
|
||||||
field_id = (std::uint16_t)std::stol(inst->data[0].substr(3));
|
field_id = (std::uint16_t)std::stoi(inst->data[0].substr(3));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1140,6 +1140,10 @@ void compiler::emit_expr_function(const gsc::context_ptr& ctx, const gsc::expr_f
|
|||||||
{
|
{
|
||||||
far = true;
|
far = true;
|
||||||
}
|
}
|
||||||
|
else if(is_include_call(name, file))
|
||||||
|
{
|
||||||
|
far = true;
|
||||||
|
}
|
||||||
else if(is_builtin_method(name))
|
else if(is_builtin_method(name))
|
||||||
{
|
{
|
||||||
builtin = true;
|
builtin = true;
|
||||||
@ -1153,6 +1157,10 @@ void compiler::emit_expr_function(const gsc::context_ptr& ctx, const gsc::expr_f
|
|||||||
{
|
{
|
||||||
local = true;
|
local = true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw gsc::comp_error(expr->loc, "couldn't determine function reference type");
|
||||||
|
}
|
||||||
|
|
||||||
if(local)
|
if(local)
|
||||||
{
|
{
|
||||||
@ -1634,7 +1642,7 @@ void compiler::emit_integer(const gsc::context_ptr& ctx, const gsc::integer_ptr&
|
|||||||
{
|
{
|
||||||
emit_opcode(ctx, opcode::OP_GetNegByte, num->value.substr(1));
|
emit_opcode(ctx, opcode::OP_GetNegByte, num->value.substr(1));
|
||||||
}
|
}
|
||||||
else if(value < 65536)
|
else if(value > 0 && value < 65536)
|
||||||
{
|
{
|
||||||
emit_opcode(ctx, opcode::OP_GetUnsignedShort, num->value);
|
emit_opcode(ctx, opcode::OP_GetUnsignedShort, num->value);
|
||||||
}
|
}
|
||||||
@ -2203,6 +2211,23 @@ auto compiler::variable_initialized(const gsc::context_ptr& ctx, const gsc::name
|
|||||||
throw gsc::comp_error(name->loc, "local variable '" + name->value + "' not found.");
|
throw gsc::comp_error(name->loc, "local variable '" + name->value + "' not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto compiler::is_include_call(const std::string& name, std::string& file) -> bool
|
||||||
|
{
|
||||||
|
for(const auto& inc : includes_)
|
||||||
|
{
|
||||||
|
for(const auto& fun : inc.funcs)
|
||||||
|
{
|
||||||
|
if(name == fun)
|
||||||
|
{
|
||||||
|
file = inc.name;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
auto compiler::is_local_call(const std::string& name) -> bool
|
auto compiler::is_local_call(const std::string& name) -> bool
|
||||||
{
|
{
|
||||||
for(const auto& f : local_functions_)
|
for(const auto& f : local_functions_)
|
||||||
|
@ -131,6 +131,7 @@ private:
|
|||||||
auto variable_create_index(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> std::string;
|
auto variable_create_index(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> std::string;
|
||||||
auto variable_access_index(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> std::string;
|
auto variable_access_index(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> std::string;
|
||||||
auto variable_initialized(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> bool;
|
auto variable_initialized(const gsc::context_ptr& ctx, const gsc::name_ptr& name) -> bool;
|
||||||
|
auto is_include_call(const std::string& name, std::string& file) -> bool;
|
||||||
auto is_local_call(const std::string& name) -> bool;
|
auto is_local_call(const std::string& name) -> bool;
|
||||||
auto is_builtin_call(const std::string& name) -> bool;
|
auto is_builtin_call(const std::string& name) -> bool;
|
||||||
auto is_builtin_func(const std::string& name) -> bool;
|
auto is_builtin_func(const std::string& name) -> bool;
|
||||||
|
@ -1954,7 +1954,7 @@ struct node_stmt_for : public node
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data += "for ( " + pre_expr.as_node->print() + " " + expr.as_node->print() + "; " + post_expr.as_node->print() + " )";
|
data += "for ( " + pre_expr.as_node->print() + " " + expr.as_node->print() + "; " + post_expr.as_assign->expr->print() + " )";
|
||||||
data += "\n";
|
data += "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user