40 , fSymbolTableStack({
sym}) {}
44 bool visitStatement(
const Statement& stmt)
override {
49 bool containsSymbol =
false;
55 fSymbolTableStack.back()->foreach([&](std::string_view,
const Symbol* symbol) {
56 if (symbol == vardecl.
var()) {
57 containsSymbol =
true;
60 if (!containsSymbol) {
62 std::string(vardecl.
var()->
name()) +
63 "' is incorrectly scoped)");
66 return INHERITED::visitStatement(stmt);
69 bool visitExpression(
const Expression&)
override {
77 std::vector<SymbolTable*> fSymbolTableStack;
80 SymbolTableCorrectnessVisitor visitor{context, program.
fSymbols.get()};
81 for (
const std::unique_ptr<ProgramElement>& pe : program.
fOwnedElements) {
82 visitor.visitProgramElement(*pe);
#define INHERITED(method,...)
Position position() const
std::string_view name() const
virtual bool visitProgramElement(typename T::ProgramElement &programElement)
void CheckSymbolTableCorrectness(const Program &program)
std::vector< std::unique_ptr< ProgramElement > > fOwnedElements
std::shared_ptr< Context > fContext
std::unique_ptr< SymbolTable > fSymbols