fix(ast): 删掉ast结构
This commit is contained in:
@@ -19,14 +19,14 @@ class SemaVisitor {
|
||||
explicit SemaVisitor(SymbolTable& table) : table_(table) {}
|
||||
|
||||
void CheckBlock(const ast::Block& block) {
|
||||
for (const auto& decl : block.varDecls) {
|
||||
table_.Add(decl->name);
|
||||
if (decl->init) CheckExpr(*decl->init);
|
||||
}
|
||||
for (const auto& stmt : block.stmts) {
|
||||
if (auto ret = dynamic_cast<ast::ReturnStmt*>(stmt.get())) {
|
||||
for (const auto& item : block.items) {
|
||||
if (auto decl = dynamic_cast<ast::VarDecl*>(item.get())) {
|
||||
table_.Add(decl->name);
|
||||
if (decl->init) CheckExpr(*decl->init);
|
||||
continue;
|
||||
}
|
||||
if (auto ret = dynamic_cast<ast::ReturnStmt*>(item.get())) {
|
||||
CheckExpr(*ret->value);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user