Save procedure info in the symbol table
This commit is contained in:
@ -53,6 +53,11 @@ namespace elna::boot
|
||||
{
|
||||
}
|
||||
|
||||
type::type(std::shared_ptr<procedure_type> procedure)
|
||||
: tag(type_tag::procedure), procedure(procedure)
|
||||
{
|
||||
}
|
||||
|
||||
void type::copy(const type& other)
|
||||
{
|
||||
switch (other.tag)
|
||||
@ -77,6 +82,9 @@ namespace elna::boot
|
||||
case type_tag::array:
|
||||
new (&array) std::shared_ptr<array_type>(other.array);
|
||||
break;
|
||||
case type_tag::procedure:
|
||||
new (&procedure) std::shared_ptr<procedure_type>(other.procedure);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,6 +118,9 @@ namespace elna::boot
|
||||
case type_tag::array:
|
||||
new (&array) std::shared_ptr<array_type>(std::move(other.array));
|
||||
break;
|
||||
case type_tag::procedure:
|
||||
new (&procedure) std::shared_ptr<procedure_type>(std::move(other.procedure));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -164,85 +175,52 @@ namespace elna::boot
|
||||
case type_tag::array:
|
||||
this->array.~shared_ptr<array_type>();
|
||||
break;
|
||||
case type_tag::procedure:
|
||||
this->procedure.~shared_ptr<procedure_type>();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
std::shared_ptr<alias_type> type::get<alias_type>() const
|
||||
{
|
||||
if (tag == type_tag::alias)
|
||||
{
|
||||
return this->alias.lock();
|
||||
}
|
||||
else
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
return tag == type_tag::alias ? this->alias.lock() : nullptr;
|
||||
}
|
||||
|
||||
template<>
|
||||
std::shared_ptr<primitive_type> type::get<primitive_type>() const
|
||||
{
|
||||
if (tag == type_tag::primitive)
|
||||
{
|
||||
return this->primitive;
|
||||
}
|
||||
else
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
return tag == type_tag::primitive ? this->primitive : nullptr;
|
||||
}
|
||||
|
||||
template<>
|
||||
std::shared_ptr<record_type> type::get<record_type>() const
|
||||
{
|
||||
if (tag == type_tag::record)
|
||||
{
|
||||
return this->record;
|
||||
}
|
||||
else
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
return tag == type_tag::record ? this->record : nullptr;
|
||||
}
|
||||
|
||||
template<>
|
||||
std::shared_ptr<union_type> type::get<union_type>() const
|
||||
{
|
||||
if (tag == type_tag::_union)
|
||||
{
|
||||
return this->_union;
|
||||
}
|
||||
else
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
return tag == type_tag::_union ? this->_union : nullptr;
|
||||
}
|
||||
|
||||
template<>
|
||||
std::shared_ptr<pointer_type> type::get<pointer_type>() const
|
||||
{
|
||||
if (tag == type_tag::pointer)
|
||||
{
|
||||
return this->pointer;
|
||||
}
|
||||
else
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
return tag == type_tag::pointer ? this->pointer : nullptr;
|
||||
}
|
||||
|
||||
template<>
|
||||
std::shared_ptr<array_type> type::get<array_type>() const
|
||||
{
|
||||
if (tag == type_tag::array)
|
||||
{
|
||||
return this->array;
|
||||
}
|
||||
else
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
return tag == type_tag::array ? this->array : nullptr;
|
||||
}
|
||||
|
||||
template<>
|
||||
std::shared_ptr<procedure_type> type::get<procedure_type>() const
|
||||
{
|
||||
return tag == type_tag::procedure ? this->procedure : nullptr;
|
||||
}
|
||||
|
||||
bool type::empty() const
|
||||
@ -284,6 +262,11 @@ namespace elna::boot
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<procedure_info> info::is_procedure()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
type_info::type_info(const type symbol)
|
||||
: symbol(symbol)
|
||||
{
|
||||
@ -294,6 +277,16 @@ namespace elna::boot
|
||||
return std::static_pointer_cast<type_info>(shared_from_this());
|
||||
}
|
||||
|
||||
procedure_info::procedure_info(const procedure_type symbol, const std::vector<std::string> names)
|
||||
: symbol(symbol), names(names)
|
||||
{
|
||||
}
|
||||
|
||||
std::shared_ptr<procedure_info> procedure_info::is_procedure()
|
||||
{
|
||||
return std::static_pointer_cast<procedure_info>(shared_from_this());
|
||||
}
|
||||
|
||||
std::shared_ptr<symbol_table> builtin_symbol_table()
|
||||
{
|
||||
auto result = std::make_shared<symbol_table>();
|
||||
|
Reference in New Issue
Block a user