Skip to content
Snippets Groups Projects
Commit cb888d72 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Fix a vicious bug in symbol table management

Functions identifiers are also stored in symbol tables.
When a block of code is left, all local variables are reset to avoid
useless memory consumption.

The problem was that locally defined functions lost their associate id
which is necessary to retrieve the function in the function
table. When a function was defined in a block, its id were set to 0...

Now functions identifiers are no more clean-up.
parent 150aadc1
No related branches found
No related tags found
1 merge request!77Fix a vicious bug in symbol table management
This commit is part of merge request !77. Comments created here will be created in the context of that merge request.
...@@ -267,6 +267,8 @@ class SymbolTable ...@@ -267,6 +267,8 @@ class SymbolTable
clearValues() clearValues()
{ {
for (auto& symbol : m_symbol_list) { for (auto& symbol : m_symbol_list) {
// local functions must kept their values (id)
if (symbol.attributes().dataType() != ASTNodeDataType::function_t) {
std::visit( std::visit(
[](auto&& value) { [](auto&& value) {
using T = std::decay_t<decltype(value)>; using T = std::decay_t<decltype(value)>;
...@@ -275,6 +277,7 @@ class SymbolTable ...@@ -275,6 +277,7 @@ class SymbolTable
symbol.attributes().value()); symbol.attributes().value());
} }
} }
}
auto auto
find(const std::string& symbol, const TAO_PEGTL_NAMESPACE::position& use_position) find(const std::string& symbol, const TAO_PEGTL_NAMESPACE::position& use_position)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment