Var and Value classes cleanup and memory footprint reduction.
* Reduce Var instance size by moving the diagnostic message string to a
hash map for the instances that really have it (there are actually very
few such instances).
* Move common members from Var subclasses to the base class and
represent them more compactly.
* Remove RuleVar wrapper class, it is an extra object per rule-specific
variable.
* Rename Expr class to ValueList.
* Use additional constructors and convenience factory methods in Value
and its subclasses to avoid creating ValueList with a single element and
then compacting it.
* Use method overloading instead of having NewExpr2/NewExpr3, move them
for the global namespace to be factory methods of the Value class.
diff --git a/symtab.cc b/symtab.cc
index 5e6f062..3d49f2e 100644
--- a/symtab.cc
+++ b/symtab.cc
@@ -30,7 +30,7 @@
#include "var.h"
struct SymbolData {
- SymbolData() : gv(kUndefined) {}
+ SymbolData() : gv(Var::Undefined()) {}
Var* gv;
};
@@ -46,7 +46,7 @@
Var* Symbol::PeekGlobalVar() const {
if (static_cast<size_t>(v_) >= g_symbol_data.size()) {
- return kUndefined;
+ return Var::Undefined();
}
return g_symbol_data[v_].gv;
}