@@ -23,7 +23,7 @@ function::~function() {
|
||||
}
|
||||
|
||||
function::function(function&& other) noexcept
|
||||
: m_name(std::move(other.m_name)), m_type(other.m_type), m_paramCount(other.m_paramCount) {
|
||||
: m_type(other.m_type), m_paramCount(other.m_paramCount) {
|
||||
switch (m_type) {
|
||||
case function_t::Normal: {
|
||||
m_value.position = other.m_value.position;
|
||||
@@ -42,7 +42,6 @@ function::function(function&& other) noexcept
|
||||
function& function::operator=(function&& other) noexcept {
|
||||
if (this == &other) return *this;
|
||||
|
||||
m_name = std::move(other.m_name);
|
||||
m_type = other.m_type;
|
||||
m_paramCount = other.m_paramCount;
|
||||
switch (m_type) {
|
||||
@@ -63,7 +62,7 @@ function& function::operator=(function&& other) noexcept {
|
||||
}
|
||||
|
||||
function::function(const function& other)
|
||||
: m_name(other.m_name), m_type(other.m_type), m_paramCount(other.m_paramCount) {
|
||||
: m_type(other.m_type), m_paramCount(other.m_paramCount) {
|
||||
switch (m_type) {
|
||||
case function_t::Normal: {
|
||||
m_value.position = other.m_value.position;
|
||||
@@ -81,7 +80,6 @@ function::function(const function& other)
|
||||
function& function::operator=(const function& other) {
|
||||
if (this == &other) return *this;
|
||||
|
||||
m_name = other.m_name;
|
||||
m_type = other.m_type;
|
||||
m_paramCount = other.m_paramCount;
|
||||
switch (m_type) {
|
||||
|
||||
+2
-2
@@ -60,8 +60,8 @@ int main(int argc, char** argv) {
|
||||
|
||||
furvm::mod_h mod = context->emplace("main", s_bytecode, s_bytecode + sizeof(s_bytecode));
|
||||
mod->emplace_type(std::make_shared<furvm::type>(context->at("core")->type_at(2), 10)).dispatch();
|
||||
auto mainFunc = mod->emplace_function("main", 0, 0);
|
||||
mod->emplace_function_private("print", 1, "print").dispatch();
|
||||
auto mainFunc = mod->emplace_function_named("main", 0, 0);
|
||||
mod->emplace_function(1, "print").dispatch();
|
||||
#endif
|
||||
mod->set_native_function("print", [](furvm::executor& executor) { print_thing(*executor.load_thing(0)); });
|
||||
|
||||
|
||||
+10
-5
@@ -27,9 +27,8 @@ std::ostream& mod::serialize(std::ostream& os) const {
|
||||
continue;
|
||||
}
|
||||
|
||||
function_h func = m_functions.at(id);
|
||||
bool isPublic = m_publicFunctions.find(func->name()) != m_publicFunctions.end();
|
||||
detail::serialize(os, isPublic ? func->name() : ""); // private functions have empty names
|
||||
function_h func = m_functions.at(id);
|
||||
detail::serialize(os, m_functionMap.at(func.id()));
|
||||
detail::serialize(os, func->param_count());
|
||||
detail::serialize(os, std::uint8_t(func->type()));
|
||||
switch (func->type()) {
|
||||
@@ -98,12 +97,18 @@ mod mod::load(std::istream& is) {
|
||||
case function_t::Normal: {
|
||||
decltype(std::declval<function>().position()) offset = 0;
|
||||
detail::load(is, offset);
|
||||
mod.emplace_function(id, std::move(name), paramCount, offset).dispatch();
|
||||
if (name.empty())
|
||||
mod.emplace_function_named(std::move(name), id, paramCount, offset).dispatch();
|
||||
else
|
||||
mod.emplace_function(id, paramCount, offset).dispatch();
|
||||
} break;
|
||||
case function_t::Native: {
|
||||
std::string native;
|
||||
detail::load(is, native);
|
||||
mod.emplace_function(id, std::move(name), paramCount, std::move(native)).dispatch();
|
||||
if (name.empty())
|
||||
mod.emplace_function_named(std::move(name), id, paramCount, std::move(native)).dispatch();
|
||||
else
|
||||
mod.emplace_function(id, paramCount, std::move(native)).dispatch();
|
||||
} break;
|
||||
case function_t::Import: {
|
||||
std::string modName;
|
||||
|
||||
Reference in New Issue
Block a user