h1 methods fix & add builtins
This commit is contained in:
parent
d8a651a844
commit
71818f0aa3
86780
src/h1/xsk/resolver.cpp
86780
src/h1/xsk/resolver.cpp
File diff suppressed because it is too large
Load Diff
@ -29,6 +29,9 @@ public:
|
|||||||
static auto find_function(const std::string& name) -> bool;
|
static auto find_function(const std::string& name) -> bool;
|
||||||
static auto find_method(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);
|
||||||
|
|
||||||
static auto make_token(std::string_view str) -> std::string;
|
static auto make_token(std::string_view str) -> std::string;
|
||||||
static auto file_data(const std::string& name) -> std::tuple<const std::string*, char*, size_t>;
|
static auto file_data(const std::string& name) -> std::tuple<const std::string*, char*, size_t>;
|
||||||
static auto fs_to_game_path(const std::filesystem::path& file) -> std::filesystem::path;
|
static auto fs_to_game_path(const std::filesystem::path& file) -> std::filesystem::path;
|
||||||
|
@ -175,6 +175,62 @@ auto resolver::find_method(const std::string& name) -> bool
|
|||||||
return false;
|
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 error(utils::string::va("builtin function '%s' already defined.", name.data()));
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto str = string_map.find(name);
|
||||||
|
|
||||||
|
if (str != string_map.end())
|
||||||
|
{
|
||||||
|
function_map.insert({ id, *str });
|
||||||
|
function_map_rev.insert({ *str, id });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto ins = string_map.insert(name);
|
||||||
|
|
||||||
|
if (ins.second)
|
||||||
|
{
|
||||||
|
function_map.insert({ id, *ins.first });
|
||||||
|
function_map_rev.insert({ *ins.first, 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 error(utils::string::va("builtin method '%s' already defined.", name.data()));
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto str = string_map.find(name);
|
||||||
|
|
||||||
|
if (str != string_map.end())
|
||||||
|
{
|
||||||
|
method_map.insert({ id, *str });
|
||||||
|
method_map_rev.insert({ *str, id });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto ins = string_map.insert(name);
|
||||||
|
|
||||||
|
if (ins.second)
|
||||||
|
{
|
||||||
|
method_map.insert({ id, *ins.first });
|
||||||
|
method_map_rev.insert({ *ins.first, id });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto resolver::make_token(std::string_view str) -> std::string
|
auto resolver::make_token(std::string_view str) -> std::string
|
||||||
{
|
{
|
||||||
if (str.starts_with("_id_") || str.starts_with("_func_") || str.starts_with("_meth_"))
|
if (str.starts_with("_id_") || str.starts_with("_func_") || str.starts_with("_meth_"))
|
||||||
|
@ -32,6 +32,9 @@ public:
|
|||||||
static auto find_function(const std::string& name) -> bool;
|
static auto find_function(const std::string& name) -> bool;
|
||||||
static auto find_method(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);
|
||||||
|
|
||||||
static auto make_token(std::string_view str) -> std::string;
|
static auto make_token(std::string_view str) -> std::string;
|
||||||
static auto file_data(const std::string& name) -> std::tuple<const std::string*, char*, size_t>;
|
static auto file_data(const std::string& name) -> std::tuple<const std::string*, char*, size_t>;
|
||||||
static auto fs_to_game_path(const std::filesystem::path& file) -> std::filesystem::path;
|
static auto fs_to_game_path(const std::filesystem::path& file) -> std::filesystem::path;
|
||||||
|
@ -206,6 +206,62 @@ auto resolver::find_method(const std::string& name) -> bool
|
|||||||
return false;
|
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 error(utils::string::va("builtin function '%s' already defined.", name.data()));
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto str = string_map.find(name);
|
||||||
|
|
||||||
|
if (str != string_map.end())
|
||||||
|
{
|
||||||
|
function_map.insert({ id, *str });
|
||||||
|
function_map_rev.insert({ *str, id });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto ins = string_map.insert(name);
|
||||||
|
|
||||||
|
if (ins.second)
|
||||||
|
{
|
||||||
|
function_map.insert({ id, *ins.first });
|
||||||
|
function_map_rev.insert({ *ins.first, 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 error(utils::string::va("builtin method '%s' already defined.", name.data()));
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto str = string_map.find(name);
|
||||||
|
|
||||||
|
if (str != string_map.end())
|
||||||
|
{
|
||||||
|
method_map.insert({ id, *str });
|
||||||
|
method_map_rev.insert({ *str, id });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto ins = string_map.insert(name);
|
||||||
|
|
||||||
|
if (ins.second)
|
||||||
|
{
|
||||||
|
method_map.insert({ id, *ins.first });
|
||||||
|
method_map_rev.insert({ *ins.first, id });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto resolver::make_token(std::string_view str) -> std::string
|
auto resolver::make_token(std::string_view str) -> std::string
|
||||||
{
|
{
|
||||||
if (str.starts_with("_id_") || str.starts_with("_func_") || str.starts_with("_meth_"))
|
if (str.starts_with("_id_") || str.starts_with("_func_") || str.starts_with("_meth_"))
|
||||||
|
@ -32,6 +32,9 @@ public:
|
|||||||
static auto find_function(const std::string& name) -> bool;
|
static auto find_function(const std::string& name) -> bool;
|
||||||
static auto find_method(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);
|
||||||
|
|
||||||
static auto make_token(std::string_view str) -> std::string;
|
static auto make_token(std::string_view str) -> std::string;
|
||||||
static auto file_data(const std::string& name) -> std::tuple<const std::string*, char*, size_t>;
|
static auto file_data(const std::string& name) -> std::tuple<const std::string*, char*, size_t>;
|
||||||
static auto fs_to_game_path(const std::filesystem::path& file) -> std::filesystem::path;
|
static auto fs_to_game_path(const std::filesystem::path& file) -> std::filesystem::path;
|
||||||
|
@ -206,6 +206,62 @@ auto resolver::find_method(const std::string& name) -> bool
|
|||||||
return false;
|
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 error(utils::string::va("builtin function '%s' already defined.", name.data()));
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto str = string_map.find(name);
|
||||||
|
|
||||||
|
if (str != string_map.end())
|
||||||
|
{
|
||||||
|
function_map.insert({ id, *str });
|
||||||
|
function_map_rev.insert({ *str, id });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto ins = string_map.insert(name);
|
||||||
|
|
||||||
|
if (ins.second)
|
||||||
|
{
|
||||||
|
function_map.insert({ id, *ins.first });
|
||||||
|
function_map_rev.insert({ *ins.first, 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 error(utils::string::va("builtin method '%s' already defined.", name.data()));
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto str = string_map.find(name);
|
||||||
|
|
||||||
|
if (str != string_map.end())
|
||||||
|
{
|
||||||
|
method_map.insert({ id, *str });
|
||||||
|
method_map_rev.insert({ *str, id });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto ins = string_map.insert(name);
|
||||||
|
|
||||||
|
if (ins.second)
|
||||||
|
{
|
||||||
|
method_map.insert({ id, *ins.first });
|
||||||
|
method_map_rev.insert({ *ins.first, id });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto resolver::make_token(std::string_view str) -> std::string
|
auto resolver::make_token(std::string_view str) -> std::string
|
||||||
{
|
{
|
||||||
if (str.starts_with("_id_") || str.starts_with("_func_") || str.starts_with("_meth_"))
|
if (str.starts_with("_id_") || str.starts_with("_func_") || str.starts_with("_meth_"))
|
||||||
|
@ -32,6 +32,9 @@ public:
|
|||||||
static auto find_function(const std::string& name) -> bool;
|
static auto find_function(const std::string& name) -> bool;
|
||||||
static auto find_method(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);
|
||||||
|
|
||||||
static auto make_token(std::string_view str) -> std::string;
|
static auto make_token(std::string_view str) -> std::string;
|
||||||
static auto file_data(const std::string& name) -> std::tuple<const std::string*, char*, size_t>;
|
static auto file_data(const std::string& name) -> std::tuple<const std::string*, char*, size_t>;
|
||||||
static auto fs_to_game_path(const std::filesystem::path& file) -> std::filesystem::path;
|
static auto fs_to_game_path(const std::filesystem::path& file) -> std::filesystem::path;
|
||||||
|
@ -206,6 +206,62 @@ auto resolver::find_method(const std::string& name) -> bool
|
|||||||
return false;
|
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 error(utils::string::va("builtin function '%s' already defined.", name.data()));
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto str = string_map.find(name);
|
||||||
|
|
||||||
|
if (str != string_map.end())
|
||||||
|
{
|
||||||
|
function_map.insert({ id, *str });
|
||||||
|
function_map_rev.insert({ *str, id });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto ins = string_map.insert(name);
|
||||||
|
|
||||||
|
if (ins.second)
|
||||||
|
{
|
||||||
|
function_map.insert({ id, *ins.first });
|
||||||
|
function_map_rev.insert({ *ins.first, 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 error(utils::string::va("builtin method '%s' already defined.", name.data()));
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto str = string_map.find(name);
|
||||||
|
|
||||||
|
if (str != string_map.end())
|
||||||
|
{
|
||||||
|
method_map.insert({ id, *str });
|
||||||
|
method_map_rev.insert({ *str, id });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto ins = string_map.insert(name);
|
||||||
|
|
||||||
|
if (ins.second)
|
||||||
|
{
|
||||||
|
method_map.insert({ id, *ins.first });
|
||||||
|
method_map_rev.insert({ *ins.first, id });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto resolver::make_token(std::string_view str) -> std::string
|
auto resolver::make_token(std::string_view str) -> std::string
|
||||||
{
|
{
|
||||||
if (str.starts_with("_id_") || str.starts_with("_func_") || str.starts_with("_meth_"))
|
if (str.starts_with("_id_") || str.starts_with("_func_") || str.starts_with("_meth_"))
|
||||||
|
@ -32,6 +32,9 @@ public:
|
|||||||
static auto find_function(const std::string& name) -> bool;
|
static auto find_function(const std::string& name) -> bool;
|
||||||
static auto find_method(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);
|
||||||
|
|
||||||
static auto make_token(std::string_view str) -> std::string;
|
static auto make_token(std::string_view str) -> std::string;
|
||||||
static auto file_data(const std::string& name) -> std::tuple<const std::string*, char*, size_t>;
|
static auto file_data(const std::string& name) -> std::tuple<const std::string*, char*, size_t>;
|
||||||
static auto fs_to_game_path(const std::filesystem::path& file) -> std::filesystem::path;
|
static auto fs_to_game_path(const std::filesystem::path& file) -> std::filesystem::path;
|
||||||
|
@ -206,6 +206,62 @@ auto resolver::find_method(const std::string& name) -> bool
|
|||||||
return false;
|
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 error(utils::string::va("builtin function '%s' already defined.", name.data()));
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto str = string_map.find(name);
|
||||||
|
|
||||||
|
if (str != string_map.end())
|
||||||
|
{
|
||||||
|
function_map.insert({ id, *str });
|
||||||
|
function_map_rev.insert({ *str, id });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto ins = string_map.insert(name);
|
||||||
|
|
||||||
|
if (ins.second)
|
||||||
|
{
|
||||||
|
function_map.insert({ id, *ins.first });
|
||||||
|
function_map_rev.insert({ *ins.first, 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 error(utils::string::va("builtin method '%s' already defined.", name.data()));
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto str = string_map.find(name);
|
||||||
|
|
||||||
|
if (str != string_map.end())
|
||||||
|
{
|
||||||
|
method_map.insert({ id, *str });
|
||||||
|
method_map_rev.insert({ *str, id });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto ins = string_map.insert(name);
|
||||||
|
|
||||||
|
if (ins.second)
|
||||||
|
{
|
||||||
|
method_map.insert({ id, *ins.first });
|
||||||
|
method_map_rev.insert({ *ins.first, id });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto resolver::make_token(std::string_view str) -> std::string
|
auto resolver::make_token(std::string_view str) -> std::string
|
||||||
{
|
{
|
||||||
if (str.starts_with("_id_") || str.starts_with("_func_") || str.starts_with("_meth_"))
|
if (str.starts_with("_id_") || str.starts_with("_func_") || str.starts_with("_meth_"))
|
||||||
|
@ -32,6 +32,9 @@ public:
|
|||||||
static auto find_function(const std::string& name) -> bool;
|
static auto find_function(const std::string& name) -> bool;
|
||||||
static auto find_method(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);
|
||||||
|
|
||||||
static auto make_token(std::string_view str) -> std::string;
|
static auto make_token(std::string_view str) -> std::string;
|
||||||
static auto file_data(const std::string& name) -> std::tuple<const std::string*, char*, size_t>;
|
static auto file_data(const std::string& name) -> std::tuple<const std::string*, char*, size_t>;
|
||||||
static auto fs_to_game_path(const std::filesystem::path& file) -> std::filesystem::path;
|
static auto fs_to_game_path(const std::filesystem::path& file) -> std::filesystem::path;
|
||||||
|
@ -206,6 +206,62 @@ auto resolver::find_method(const std::string& name) -> bool
|
|||||||
return false;
|
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 error(utils::string::va("builtin function '%s' already defined.", name.data()));
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto str = string_map.find(name);
|
||||||
|
|
||||||
|
if (str != string_map.end())
|
||||||
|
{
|
||||||
|
function_map.insert({ id, *str });
|
||||||
|
function_map_rev.insert({ *str, id });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto ins = string_map.insert(name);
|
||||||
|
|
||||||
|
if (ins.second)
|
||||||
|
{
|
||||||
|
function_map.insert({ id, *ins.first });
|
||||||
|
function_map_rev.insert({ *ins.first, 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 error(utils::string::va("builtin method '%s' already defined.", name.data()));
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto str = string_map.find(name);
|
||||||
|
|
||||||
|
if (str != string_map.end())
|
||||||
|
{
|
||||||
|
method_map.insert({ id, *str });
|
||||||
|
method_map_rev.insert({ *str, id });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto ins = string_map.insert(name);
|
||||||
|
|
||||||
|
if (ins.second)
|
||||||
|
{
|
||||||
|
method_map.insert({ id, *ins.first });
|
||||||
|
method_map_rev.insert({ *ins.first, id });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto resolver::make_token(std::string_view str) -> std::string
|
auto resolver::make_token(std::string_view str) -> std::string
|
||||||
{
|
{
|
||||||
if (str.starts_with("_id_") || str.starts_with("_func_") || str.starts_with("_meth_"))
|
if (str.starts_with("_id_") || str.starts_with("_func_") || str.starts_with("_meth_"))
|
||||||
|
@ -32,6 +32,9 @@ public:
|
|||||||
static auto find_function(const std::string& name) -> bool;
|
static auto find_function(const std::string& name) -> bool;
|
||||||
static auto find_method(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);
|
||||||
|
|
||||||
static auto make_token(std::string_view str) -> std::string;
|
static auto make_token(std::string_view str) -> std::string;
|
||||||
static auto file_data(const std::string& name) -> std::tuple<const std::string*, char*, size_t>;
|
static auto file_data(const std::string& name) -> std::tuple<const std::string*, char*, size_t>;
|
||||||
static auto fs_to_game_path(const std::filesystem::path& file) -> std::filesystem::path;
|
static auto fs_to_game_path(const std::filesystem::path& file) -> std::filesystem::path;
|
||||||
|
@ -206,6 +206,62 @@ auto resolver::find_method(const std::string& name) -> bool
|
|||||||
return false;
|
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 error(utils::string::va("builtin function '%s' already defined.", name.data()));
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto str = string_map.find(name);
|
||||||
|
|
||||||
|
if (str != string_map.end())
|
||||||
|
{
|
||||||
|
function_map.insert({ id, *str });
|
||||||
|
function_map_rev.insert({ *str, id });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto ins = string_map.insert(name);
|
||||||
|
|
||||||
|
if (ins.second)
|
||||||
|
{
|
||||||
|
function_map.insert({ id, *ins.first });
|
||||||
|
function_map_rev.insert({ *ins.first, 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 error(utils::string::va("builtin method '%s' already defined.", name.data()));
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto str = string_map.find(name);
|
||||||
|
|
||||||
|
if (str != string_map.end())
|
||||||
|
{
|
||||||
|
method_map.insert({ id, *str });
|
||||||
|
method_map_rev.insert({ *str, id });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto ins = string_map.insert(name);
|
||||||
|
|
||||||
|
if (ins.second)
|
||||||
|
{
|
||||||
|
method_map.insert({ id, *ins.first });
|
||||||
|
method_map_rev.insert({ *ins.first, id });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto resolver::make_token(std::string_view str) -> std::string
|
auto resolver::make_token(std::string_view str) -> std::string
|
||||||
{
|
{
|
||||||
if (str.starts_with("_id_") || str.starts_with("_func_") || str.starts_with("_meth_"))
|
if (str.starts_with("_id_") || str.starts_with("_func_") || str.starts_with("_meth_"))
|
||||||
|
@ -32,6 +32,9 @@ public:
|
|||||||
static auto find_function(const std::string& name) -> bool;
|
static auto find_function(const std::string& name) -> bool;
|
||||||
static auto find_method(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);
|
||||||
|
|
||||||
static auto make_token(std::string_view str) -> std::string;
|
static auto make_token(std::string_view str) -> std::string;
|
||||||
static auto file_data(const std::string& name) -> std::tuple<const std::string*, char*, size_t>;
|
static auto file_data(const std::string& name) -> std::tuple<const std::string*, char*, size_t>;
|
||||||
static auto fs_to_game_path(const std::filesystem::path& file) -> std::filesystem::path;
|
static auto fs_to_game_path(const std::filesystem::path& file) -> std::filesystem::path;
|
||||||
|
Loading…
Reference in New Issue
Block a user