custom builtin support

This commit is contained in:
xensik 2021-05-20 20:53:23 +02:00
parent 3d94bb6fb9
commit 8d886570aa
2 changed files with 30 additions and 0 deletions

View File

@ -164,6 +164,33 @@ auto resolver::find_method(const std::string& name) -> bool
return false;
}
void resolver::add_function(const std::string& name, std::uint16_t id)
{
const auto itr = function_map_rev.find(name);
if (itr != function_map_rev.end())
{
throw gsc::error("builtin function '" + name + "' already defined.");
}
function_map.insert({ id, name });
function_map_rev.insert({ name, id });
}
void resolver::add_method(const std::string& name, std::uint16_t id)
{
const auto itr = method_map_rev.find(name);
if (itr != method_map_rev.end())
{
throw gsc::error("builtin method '" + name + "' already defined.");
}
method_map.insert({ id, name });
method_map_rev.insert({ name, id });
}
const std::array<gsc::pair_8C, 153> opcode_list
{{
{ std::uint8_t(opcode::OP_End),"END" },

View File

@ -28,6 +28,9 @@ public:
static auto find_function(const std::string& name) -> bool;
static auto find_method(const std::string& name) -> bool;
static void add_function(const std::string& name, std::uint16_t id);
static void add_method(const std::string& name, std::uint16_t id);
};
} // namespace xsk::gsc::iw5