ostream& CAstStatIf::print(ostream &out, int indent) const { string ind(indent, ' '); out << ind << "if cond" << endl; _cond->print(out, indent+2); out << ind << "if-body" << endl; if (_ifBody != NULL) { CAstStatement *s = _ifBody; do { s->print(out, indent+2); s = s->GetNext(); } while (s != NULL); } else out << ind << " empty." << endl; out << ind << "else-body" << endl; if (_elseBody != NULL) { CAstStatement *s = _elseBody; do { s->print(out, indent+2); s = s->GetNext(); } while (s != NULL); } else out << ind << " empty." << endl; return out; }
ostream& CAstScope::print(ostream &out, int indent) const { string ind(indent, ' '); out << ind << "CAstScope: '" << _name << "'" << endl; out << ind << " symbol table:" << endl; _symtab->print(out, indent+4); out << ind << " statement list:" << endl; CAstStatement *s = GetStatementSequence(); if (s != NULL) { do { s->print(out, indent+4); s = s->GetNext(); } while (s != NULL); } else { out << ind << " empty." << endl; } out << ind << " nested scopes:" << endl; if (_children.size() > 0) { for (size_t i=0; i<_children.size(); i++) { _children[i]->print(out, indent+4); } } else { out << ind << " empty." << endl; } out << ind << endl; return out; }