refactor(furvm): use the handle system

Refs: #12
This commit is contained in:
2026-06-17 13:59:54 +02:00
parent e8ccaa6390
commit 00bcc0e6a5
10 changed files with 112 additions and 53 deletions
+37
View File
@@ -54,4 +54,41 @@ function& function::operator=(function&& other) noexcept {
return *this;
}
function::function(const function& other)
: m_name(other.m_name), m_type(other.m_type) {
switch (m_type) {
case function_t::Normal: {
m_value.position = other.m_value.position;
} break;
case function_t::Native: {
new (&m_value.native) native_function(other.m_value.native);
} break;
case function_t::Import: {
m_value.imp.moduleName = other.m_value.imp.moduleName;
m_value.imp.function = other.m_value.imp.function;
} break;
}
}
function& function::operator=(const function& other) {
if (this == &other) return *this;
m_name = other.m_name;
m_type = other.m_type;
switch (m_type) {
case function_t::Normal: {
m_value.position = other.m_value.position;
} break;
case function_t::Native: {
new (&m_value.native) native_function(other.m_value.native);
} break;
case function_t::Import: {
m_value.imp.moduleName = other.m_value.imp.moduleName;
m_value.imp.function = other.m_value.imp.function;
} break;
}
return *this;
}
} // namespace furvm