Have WalkAST postorder callback function return an ASTNode *

In general, it should just return the original node pointer, but for type checking
and optimization passes, it can return a new value for the node (that will be
assigned where the old one was in the tree.)

Along the way, fixed some bugs in WalkAST() where the postorder callback wouldn't
end up being called for a few expr types (sizeof, dereference, address of, 
reference).
This commit is contained in:
Matt Pharr
2011-12-16 11:06:09 -08:00
parent 018aa96c8b
commit ced3f1f5fc
5 changed files with 73 additions and 59 deletions

View File

@@ -387,9 +387,8 @@ Function::GenerateIR() {
SourcePos firstStmtPos = sym->pos;
if (code) {
StmtList *sl = dynamic_cast<StmtList *>(code);
if (sl && sl->GetStatements().size() > 0 &&
sl->GetStatements()[0] != NULL)
firstStmtPos = sl->GetStatements()[0]->pos;
if (sl && sl->stmts.size() > 0 && sl->stmts[0] != NULL)
firstStmtPos = sl->stmts[0]->pos;
else
firstStmtPos = code->pos;
}