Implement enumeration type
This commit is contained in:
@ -58,6 +58,11 @@ namespace elna::boot
|
||||
{
|
||||
}
|
||||
|
||||
type::type(std::shared_ptr<enumeration_type> enumeration)
|
||||
: tag(type_tag::enumeration), enumeration(enumeration)
|
||||
{
|
||||
}
|
||||
|
||||
void type::copy(const type& other)
|
||||
{
|
||||
switch (other.tag)
|
||||
@ -85,6 +90,9 @@ namespace elna::boot
|
||||
case type_tag::procedure:
|
||||
new (&procedure) std::shared_ptr<procedure_type>(other.procedure);
|
||||
break;
|
||||
case type_tag::enumeration:
|
||||
new (&enumeration) std::shared_ptr<enumeration_type>(other.enumeration);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,6 +129,9 @@ namespace elna::boot
|
||||
case type_tag::procedure:
|
||||
new (&procedure) std::shared_ptr<procedure_type>(std::move(other.procedure));
|
||||
break;
|
||||
case type_tag::enumeration:
|
||||
new (&enumeration) std::shared_ptr<enumeration_type>(std::move(other.enumeration));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -178,6 +189,9 @@ namespace elna::boot
|
||||
case type_tag::procedure:
|
||||
this->procedure.~shared_ptr<procedure_type>();
|
||||
break;
|
||||
case type_tag::enumeration:
|
||||
this->enumeration.~shared_ptr<enumeration_type>();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -223,6 +237,12 @@ namespace elna::boot
|
||||
return tag == type_tag::procedure ? this->procedure : nullptr;
|
||||
}
|
||||
|
||||
template<>
|
||||
std::shared_ptr<enumeration_type> type::get<enumeration_type>() const
|
||||
{
|
||||
return tag == type_tag::enumeration ? this->enumeration : nullptr;
|
||||
}
|
||||
|
||||
bool type::empty() const
|
||||
{
|
||||
return tag == type_tag::empty;
|
||||
@ -253,6 +273,11 @@ namespace elna::boot
|
||||
{
|
||||
}
|
||||
|
||||
enumeration_type::enumeration_type(const std::vector<std::string>& members)
|
||||
: members(members)
|
||||
{
|
||||
}
|
||||
|
||||
info::~info()
|
||||
{
|
||||
}
|
||||
@ -287,6 +312,11 @@ namespace elna::boot
|
||||
return std::static_pointer_cast<procedure_info>(shared_from_this());
|
||||
}
|
||||
|
||||
constant_info::constant_info(const variant& symbol)
|
||||
: symbol(symbol)
|
||||
{
|
||||
}
|
||||
|
||||
std::shared_ptr<symbol_table> builtin_symbol_table()
|
||||
{
|
||||
auto result = std::make_shared<symbol_table>();
|
||||
|
Reference in New Issue
Block a user