Skip to content
Snippets Groups Projects

Fix a vicious bug in symbol table management

1 file
+ 9
6
Compare changes
  • Side-by-side
  • Inline
  • cb888d72
    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.
+ 9
6
@@ -267,12 +267,15 @@ class SymbolTable
clearValues()
{
for (auto& symbol : m_symbol_list) {
std::visit(
[](auto&& value) {
using T = std::decay_t<decltype(value)>;
value = T{};
},
symbol.attributes().value());
// local functions must kept their values (id)
if (symbol.attributes().dataType() != ASTNodeDataType::function_t) {
std::visit(
[](auto&& value) {
using T = std::decay_t<decltype(value)>;
value = T{};
},
symbol.attributes().value());
}
}
}
Loading