| [461046f] | 1 | //
 | 
|---|
 | 2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
 | 
|---|
 | 3 | //
 | 
|---|
 | 4 | // The contents of this file are covered under the licence agreement in the
 | 
|---|
 | 5 | // file "LICENCE" distributed with Cforall.
 | 
|---|
 | 6 | //
 | 
|---|
 | 7 | // Print.cpp --
 | 
|---|
 | 8 | //
 | 
|---|
 | 9 | // Author           : Thierry Delisle
 | 
|---|
 | 10 | // Created On       : Tue May 21 16:20:15 2019
 | 
|---|
 | 11 | // Last Modified By :
 | 
|---|
 | 12 | // Last Modified On :
 | 
|---|
 | 13 | // Update Count     :
 | 
|---|
 | 14 | //
 | 
|---|
 | 15 | 
 | 
|---|
 | 16 | #include "Print.hpp"
 | 
|---|
 | 17 | 
 | 
|---|
 | 18 | #include "Decl.hpp"
 | 
|---|
 | 19 | #include "Expr.hpp"
 | 
|---|
 | 20 | #include "Stmt.hpp"
 | 
|---|
 | 21 | #include "Type.hpp"
 | 
|---|
 | 22 | #include "TypeSubstitution.hpp"
 | 
|---|
 | 23 | 
 | 
|---|
| [a2e758e] | 24 | #include "Common/utility.h" // for group_iterate
 | 
|---|
 | 25 | 
 | 
|---|
| [5902625] | 26 | using namespace std;
 | 
|---|
| [461046f] | 27 | 
 | 
|---|
 | 28 | namespace ast {
 | 
|---|
 | 29 | 
 | 
|---|
 | 30 | template <typename C, typename... T>
 | 
|---|
 | 31 | constexpr auto make_array(T&&... values) ->
 | 
|---|
| [5902625] | 32 |         array<C,sizeof...(T)>
 | 
|---|
| [461046f] | 33 | {
 | 
|---|
| [5902625] | 34 |         return array<C,sizeof...(T)>{
 | 
|---|
 | 35 |                 forward<T>(values)...
 | 
|---|
| [461046f] | 36 |         };
 | 
|---|
 | 37 | }
 | 
|---|
 | 38 | 
 | 
|---|
| [e67991f] | 39 | class Printer final : public Visitor {
 | 
|---|
| [461046f] | 40 | public:
 | 
|---|
| [5902625] | 41 |         ostream & os;
 | 
|---|
| [461046f] | 42 |         Indenter indent;
 | 
|---|
| [5902625] | 43 |         bool short_mode;
 | 
|---|
| [461046f] | 44 | 
 | 
|---|
| [5902625] | 45 |         Printer(ostream & os, Indenter indent, bool short_mode) : os( os ), indent( indent ), short_mode(short_mode) {}
 | 
|---|
| [461046f] | 46 | 
 | 
|---|
 | 47 | private:
 | 
|---|
 | 48 |         template< typename C >
 | 
|---|
 | 49 |         void printAll( const C & c ) {
 | 
|---|
 | 50 |                 for ( const auto & i : c ) {
 | 
|---|
 | 51 |                         if ( i ) {
 | 
|---|
 | 52 |                                 os << indent;
 | 
|---|
 | 53 |                                 i->accept( *this );
 | 
|---|
 | 54 |                                 // need an endl after each element because it's not
 | 
|---|
 | 55 |                                 // easy to know when each individual item should end
 | 
|---|
| [5902625] | 56 |                                 os << endl;
 | 
|---|
| [461046f] | 57 |                         } // if
 | 
|---|
 | 58 |                 } // for
 | 
|---|
 | 59 |         }
 | 
|---|
 | 60 | 
 | 
|---|
| [20a5977] | 61 |         /// call if mandatory field is missing
 | 
|---|
 | 62 |         void undefined() {
 | 
|---|
 | 63 |                 os << "UNDEFINED";
 | 
|---|
 | 64 |         }
 | 
|---|
 | 65 | 
 | 
|---|
 | 66 |         /// call for fields that should be mandatory
 | 
|---|
 | 67 |         void safe_print( const ast::Node * n ) {
 | 
|---|
 | 68 |                 if ( n ) n->accept( *this );
 | 
|---|
 | 69 |                 else undefined();
 | 
|---|
 | 70 |         }
 | 
|---|
 | 71 | 
 | 
|---|
 | 72 |         /// call to print short form. Incorporates features of safe_print()
 | 
|---|
| [6f4b7f2] | 73 |         void short_print( const ast::Decl * n ) {
 | 
|---|
| [20a5977] | 74 |                 if ( ! n ) { undefined(); return; }
 | 
|---|
 | 75 |                 bool old_short = short_mode; short_mode = true;
 | 
|---|
 | 76 |                 n->accept( *this );
 | 
|---|
 | 77 |                 short_mode = old_short;
 | 
|---|
 | 78 |         }
 | 
|---|
 | 79 | 
 | 
|---|
| [461046f] | 80 |         static const char* Names[];
 | 
|---|
 | 81 | 
 | 
|---|
 | 82 |         struct Names {
 | 
|---|
 | 83 |                 static constexpr auto FuncSpecifiers = make_array<const char*>(
 | 
|---|
 | 84 |                         "inline", "_Noreturn", "fortran"
 | 
|---|
 | 85 |                 );
 | 
|---|
 | 86 | 
 | 
|---|
 | 87 |                 static constexpr auto StorageClasses = make_array<const char*>(
 | 
|---|
 | 88 |                         "extern", "static", "auto", "register", "_Thread_local"
 | 
|---|
 | 89 |                 );
 | 
|---|
 | 90 | 
 | 
|---|
 | 91 |                 static constexpr auto Qualifiers = make_array<const char*>(
 | 
|---|
 | 92 |                         "const", "restrict", "volatile", "lvalue", "mutex", "_Atomic"
 | 
|---|
 | 93 |                 );
 | 
|---|
 | 94 |         };
 | 
|---|
 | 95 | 
 | 
|---|
 | 96 |         template<typename storage_t, size_t N>
 | 
|---|
| [5902625] | 97 |         void print(const storage_t & storage, const array<const char *, N> & Names ) {
 | 
|---|
| [461046f] | 98 |                 if ( storage.any() ) {
 | 
|---|
 | 99 |                         for ( size_t i = 0; i < Names.size(); i += 1 ) {
 | 
|---|
 | 100 |                                 if ( storage[i] ) {
 | 
|---|
 | 101 |                                         os << Names[i] << ' ';
 | 
|---|
 | 102 |                                 }
 | 
|---|
 | 103 |                         }
 | 
|---|
 | 104 |                 }
 | 
|---|
 | 105 |         }
 | 
|---|
 | 106 | 
 | 
|---|
 | 107 |         void print( const ast::Function::Specs & specs ) {
 | 
|---|
 | 108 |                 print(specs, Names::FuncSpecifiers);
 | 
|---|
 | 109 |         }
 | 
|---|
 | 110 | 
 | 
|---|
 | 111 |         void print( const ast::Storage::Classes & storage ) {
 | 
|---|
 | 112 |                 print(storage, Names::StorageClasses);
 | 
|---|
 | 113 |         }
 | 
|---|
 | 114 | 
 | 
|---|
 | 115 |         void print( const ast::CV::Qualifiers & qualifiers ) {
 | 
|---|
 | 116 |                 print(qualifiers, Names::Qualifiers);
 | 
|---|
 | 117 |         }
 | 
|---|
 | 118 | 
 | 
|---|
| [94b1f718] | 119 |         void print( const std::vector<ast::Label> & labels ) {
 | 
|---|
 | 120 |                 if ( labels.empty() ) return;
 | 
|---|
 | 121 |                 os << indent << "... Labels: {";
 | 
|---|
 | 122 |                 bool isFirst = true;
 | 
|---|
 | 123 |                 for ( const Label & l : labels ) {
 | 
|---|
 | 124 |                         if ( isFirst ) { isFirst = false; } else { os << ","; }
 | 
|---|
 | 125 |                         os << l;
 | 
|---|
 | 126 |                 }
 | 
|---|
 | 127 |                 os << "}" << endl;
 | 
|---|
 | 128 |         }
 | 
|---|
 | 129 | 
 | 
|---|
| [20a5977] | 130 |         void print( const ast::Expr::InferUnion & inferred, unsigned level = 0 ) {
 | 
|---|
 | 131 |                 switch ( inferred.mode ) {
 | 
|---|
 | 132 |                 case ast::Expr::InferUnion::Empty: return;
 | 
|---|
 | 133 |                 case ast::Expr::InferUnion::Slots: {
 | 
|---|
| [d908563] | 134 |                         os << indent << "with " << inferred.data.resnSlots.size()
 | 
|---|
| [94b1f718] | 135 |                            << " pending inference slots" << endl;
 | 
|---|
| [20a5977] | 136 |                         return;
 | 
|---|
 | 137 |                 }
 | 
|---|
 | 138 |                 case ast::Expr::InferUnion::Params: {
 | 
|---|
| [94b1f718] | 139 |                         os << indent << "with inferred parameters " << level << ":" << endl;
 | 
|---|
| [20a5977] | 140 |                         ++indent;
 | 
|---|
 | 141 |                         for ( const auto & i : inferred.data.inferParams ) {
 | 
|---|
 | 142 |                                 os << indent;
 | 
|---|
 | 143 |                                 short_print( Decl::fromId( i.second.decl ) );
 | 
|---|
| [94b1f718] | 144 |                                 os << endl;
 | 
|---|
| [20a5977] | 145 |                                 print( i.second.expr->inferred, level+1 );
 | 
|---|
 | 146 |                         }
 | 
|---|
 | 147 |                         --indent;
 | 
|---|
 | 148 |                         return;
 | 
|---|
 | 149 |                 }
 | 
|---|
 | 150 |                 }
 | 
|---|
 | 151 |         }
 | 
|---|
 | 152 | 
 | 
|---|
| [b0ec971] | 153 |         void print( const ast::ParameterizedType::ForallList & forall ) {
 | 
|---|
| [d908563] | 154 |                 if ( forall.empty() ) return;
 | 
|---|
| [94b1f718] | 155 |                 os << "forall" << endl;
 | 
|---|
| [b0ec971] | 156 |                 ++indent;
 | 
|---|
 | 157 |                 printAll( forall );
 | 
|---|
 | 158 |                 os << indent;
 | 
|---|
 | 159 |                 --indent;
 | 
|---|
 | 160 |         }
 | 
|---|
 | 161 | 
 | 
|---|
 | 162 |         void print( const std::vector<ptr<Attribute>> & attrs ) {
 | 
|---|
 | 163 |                 if ( attrs.empty() ) return;
 | 
|---|
| [94b1f718] | 164 |                 os << "with attributes" << endl;
 | 
|---|
| [b0ec971] | 165 |                 ++indent;
 | 
|---|
 | 166 |                 printAll( attrs );
 | 
|---|
 | 167 |                 --indent;
 | 
|---|
 | 168 |         }
 | 
|---|
 | 169 | 
 | 
|---|
 | 170 |         void print( const std::vector<ptr<Expr>> & params ) {
 | 
|---|
 | 171 |                 if ( params.empty() ) return;
 | 
|---|
| [94b1f718] | 172 |                 os << endl << indent << "... with parameters" << endl;
 | 
|---|
| [b0ec971] | 173 |                 ++indent;
 | 
|---|
 | 174 |                 printAll( params );
 | 
|---|
 | 175 |                 --indent;
 | 
|---|
 | 176 |         }
 | 
|---|
 | 177 | 
 | 
|---|
| [5902625] | 178 |         void print( const ast::AggregateDecl * node ) {
 | 
|---|
| [6f4b7f2] | 179 |                 os << node->typeString() << " " << node->name;
 | 
|---|
| [a7d50b6] | 180 | 
 | 
|---|
| [6f4b7f2] | 181 |                 if ( ! short_mode && node->linkage != Linkage::Cforall ) {
 | 
|---|
| [5902625] | 182 |                         os << " " << Linkage::name( node->linkage );
 | 
|---|
| [6f4b7f2] | 183 |                 }
 | 
|---|
| [a7d50b6] | 184 | 
 | 
|---|
| [6f4b7f2] | 185 |                 os << " " << (node->body ? "with" : "without") << " body";
 | 
|---|
| [5902625] | 186 | 
 | 
|---|
 | 187 |                 if ( ! node->params.empty() ) {
 | 
|---|
 | 188 |                         os << endl << indent << "... with parameters" << endl;
 | 
|---|
 | 189 |                         ++indent;
 | 
|---|
 | 190 |                         printAll( node->params );
 | 
|---|
 | 191 |                         --indent;
 | 
|---|
| [6f4b7f2] | 192 |                 }
 | 
|---|
 | 193 | 
 | 
|---|
 | 194 |                 if ( ! short_mode && ! node->members.empty() ) {
 | 
|---|
| [5902625] | 195 |                         os << endl << indent << "... with members" << endl;
 | 
|---|
 | 196 |                         ++indent;
 | 
|---|
 | 197 |                         printAll( node->members );
 | 
|---|
 | 198 |                         --indent;
 | 
|---|
| [6f4b7f2] | 199 |                 }
 | 
|---|
 | 200 | 
 | 
|---|
 | 201 |                 if ( ! short_mode && ! node->attributes.empty() ) {
 | 
|---|
| [5902625] | 202 |                         os << endl << indent << "... with attributes" << endl;
 | 
|---|
 | 203 |                         ++indent;
 | 
|---|
 | 204 |                         printAll( node->attributes );
 | 
|---|
 | 205 |                         --indent;
 | 
|---|
| [6f4b7f2] | 206 |                 }
 | 
|---|
 | 207 | 
 | 
|---|
| [5902625] | 208 |                 os << endl;
 | 
|---|
 | 209 |         }
 | 
|---|
 | 210 | 
 | 
|---|
| [6f4b7f2] | 211 |         void preprint( const ast::NamedTypeDecl * node ) {
 | 
|---|
 | 212 |                 if ( ! node->name.empty() ) os << node->name << ": ";
 | 
|---|
| [5902625] | 213 | 
 | 
|---|
| [6f4b7f2] | 214 |                 if ( ! short_mode && node->linkage != Linkage::Cforall ) {
 | 
|---|
| [5902625] | 215 |                         os << Linkage::name( node->linkage ) << " ";
 | 
|---|
| [6f4b7f2] | 216 |                 }
 | 
|---|
 | 217 | 
 | 
|---|
| [5902625] | 218 |                 print( node->storage );
 | 
|---|
 | 219 |                 os << node->typeString();
 | 
|---|
| [a7d50b6] | 220 | 
 | 
|---|
| [5902625] | 221 |                 if ( node->base ) {
 | 
|---|
 | 222 |                         os << " for ";
 | 
|---|
 | 223 |                         ++indent;
 | 
|---|
 | 224 |                         node->base->accept( *this );
 | 
|---|
 | 225 |                         --indent;
 | 
|---|
| [6f4b7f2] | 226 |                 }
 | 
|---|
 | 227 | 
 | 
|---|
| [5902625] | 228 |                 if ( ! node->params.empty() ) {
 | 
|---|
 | 229 |                         os << endl << indent << "... with parameters" << endl;
 | 
|---|
 | 230 |                         ++indent;
 | 
|---|
 | 231 |                         printAll( node->params );
 | 
|---|
 | 232 |                         --indent;
 | 
|---|
| [6f4b7f2] | 233 |                 }
 | 
|---|
 | 234 | 
 | 
|---|
 | 235 |                 if ( ! short_mode && ! node->assertions.empty() ) {
 | 
|---|
| [5902625] | 236 |                         os << endl << indent << "... with assertions" << endl;
 | 
|---|
 | 237 |                         ++indent;
 | 
|---|
 | 238 |                         printAll( node->assertions );
 | 
|---|
 | 239 |                         --indent;
 | 
|---|
| [6f4b7f2] | 240 |                 }
 | 
|---|
| [5902625] | 241 |         }
 | 
|---|
| [b0ec971] | 242 | 
 | 
|---|
| [20a5977] | 243 |         void postprint( const ast::Expr * node ) {
 | 
|---|
 | 244 |                 print( node->inferred );
 | 
|---|
 | 245 | 
 | 
|---|
 | 246 |                 if ( node->env ) {
 | 
|---|
| [94b1f718] | 247 |                         os << endl << indent << "... with environment:" << endl;
 | 
|---|
| [20a5977] | 248 |                         ++indent;
 | 
|---|
 | 249 |                         node->env->accept( *this );
 | 
|---|
 | 250 |                         --indent;
 | 
|---|
 | 251 |                 }
 | 
|---|
| [a16e246] | 252 | 
 | 
|---|
| [20a5977] | 253 |                 if ( node->extension ) {
 | 
|---|
| [94b1f718] | 254 |                         os << endl << indent << "... with extension";
 | 
|---|
| [20a5977] | 255 |                 }
 | 
|---|
 | 256 |         }
 | 
|---|
 | 257 | 
 | 
|---|
 | 258 |         void preprint( const ast::Type * node ) {
 | 
|---|
 | 259 |                 print( node->qualifiers );
 | 
|---|
 | 260 |         }
 | 
|---|
 | 261 | 
 | 
|---|
 | 262 |         void preprint( const ast::ParameterizedType * node ) {
 | 
|---|
 | 263 |                 print( node->forall );
 | 
|---|
 | 264 |                 print( node->qualifiers );
 | 
|---|
 | 265 |         }
 | 
|---|
 | 266 | 
 | 
|---|
 | 267 |         void preprint( const ast::ReferenceToType * node ) {
 | 
|---|
 | 268 |                 print( node->forall );
 | 
|---|
 | 269 |                 print( node->attributes );
 | 
|---|
 | 270 |                 print( node->qualifiers );
 | 
|---|
 | 271 |         }
 | 
|---|
 | 272 | 
 | 
|---|
| [461046f] | 273 | public:
 | 
|---|
| [e67991f] | 274 |         virtual const ast::DeclWithType * visit( const ast::ObjectDecl * node ) override final {
 | 
|---|
| [6f4b7f2] | 275 |                 if ( ! node->name.empty() ) os << node->name << ": ";
 | 
|---|
| [461046f] | 276 | 
 | 
|---|
| [6f4b7f2] | 277 |                 if ( ! short_mode && node->linkage != Linkage::Cforall ) {
 | 
|---|
| [461046f] | 278 |                         os << Linkage::name( node->linkage ) << " ";
 | 
|---|
| [6f4b7f2] | 279 |                 }
 | 
|---|
| [461046f] | 280 | 
 | 
|---|
 | 281 |                 print( node->storage );
 | 
|---|
 | 282 | 
 | 
|---|
 | 283 |                 if ( node->type ) {
 | 
|---|
 | 284 |                         node->type->accept( *this );
 | 
|---|
 | 285 |                 } else {
 | 
|---|
| [20a5977] | 286 |                         os << "untyped entity";
 | 
|---|
| [6f4b7f2] | 287 |                 }
 | 
|---|
| [461046f] | 288 | 
 | 
|---|
| [6f4b7f2] | 289 |                 if ( ! short_mode && node->init ) {
 | 
|---|
 | 290 |                         ++indent;
 | 
|---|
| [461046f] | 291 |                         os << " with initializer (" << (
 | 
|---|
 | 292 |                                 node->init->maybeConstructed
 | 
|---|
 | 293 |                                         ? "maybe constructed"
 | 
|---|
 | 294 |                                         : "not constructed"
 | 
|---|
| [6f4b7f2] | 295 |                                 ) << ")" << endl << indent;
 | 
|---|
| [461046f] | 296 |                         node->init->accept( *this );
 | 
|---|
 | 297 |                         --indent;
 | 
|---|
| [5902625] | 298 |                         os << endl;
 | 
|---|
| [6f4b7f2] | 299 |                 }
 | 
|---|
| [461046f] | 300 | 
 | 
|---|
| [6f4b7f2] | 301 |                 if ( ! short_mode && ! node->attributes.empty() ) {
 | 
|---|
| [5902625] | 302 |                         os << endl << indent << "... with attributes:" << endl;
 | 
|---|
| [461046f] | 303 |                         ++indent;
 | 
|---|
 | 304 |                         printAll( node->attributes );
 | 
|---|
 | 305 |                         --indent;
 | 
|---|
 | 306 |                 }
 | 
|---|
 | 307 | 
 | 
|---|
 | 308 |                 if ( node->bitfieldWidth ) {
 | 
|---|
 | 309 |                         os << indent << " with bitfield width ";
 | 
|---|
 | 310 |                         node->bitfieldWidth->accept( *this );
 | 
|---|
| [6f4b7f2] | 311 |                 }
 | 
|---|
 | 312 | 
 | 
|---|
| [461046f] | 313 |                 return node;
 | 
|---|
 | 314 |         }
 | 
|---|
 | 315 | 
 | 
|---|
| [e67991f] | 316 |         virtual const ast::DeclWithType * visit( const ast::FunctionDecl * node ) override final {
 | 
|---|
| [6f4b7f2] | 317 |                 if ( !node->name.empty() ) os << node->name << ": ";
 | 
|---|
 | 318 | 
 | 
|---|
 | 319 |                 if ( ! short_mode && node->linkage != Linkage::Cforall ) {
 | 
|---|
| [5902625] | 320 |                         os << Linkage::name( node->linkage ) << " ";
 | 
|---|
| [6f4b7f2] | 321 |                 }
 | 
|---|
| [5902625] | 322 | 
 | 
|---|
| [6f4b7f2] | 323 |                 if ( ! short_mode ) printAll( node->attributes );
 | 
|---|
| [5902625] | 324 | 
 | 
|---|
 | 325 |                 print( node->storage );
 | 
|---|
 | 326 |                 print( node->funcSpec );
 | 
|---|
 | 327 | 
 | 
|---|
 | 328 |                 if ( node->type ) {
 | 
|---|
 | 329 |                         node->type->accept( *this );
 | 
|---|
 | 330 |                 } else {
 | 
|---|
| [20a5977] | 331 |                         os << "untyped entity";
 | 
|---|
| [6f4b7f2] | 332 |                 }
 | 
|---|
| [5902625] | 333 | 
 | 
|---|
| [6f4b7f2] | 334 |                 if ( ! short_mode && node->stmts ) {
 | 
|---|
| [5902625] | 335 |                         ++indent;
 | 
|---|
| [6f4b7f2] | 336 |                         os << " with body" << endl << indent;
 | 
|---|
| [5902625] | 337 |                         node->stmts->accept( *this );
 | 
|---|
 | 338 |                         --indent;
 | 
|---|
| [6f4b7f2] | 339 |                 }
 | 
|---|
 | 340 | 
 | 
|---|
| [461046f] | 341 |                 return node;
 | 
|---|
 | 342 |         }
 | 
|---|
 | 343 | 
 | 
|---|
| [e67991f] | 344 |         virtual const ast::Decl * visit( const ast::StructDecl * node ) override final {
 | 
|---|
| [5902625] | 345 |                 print(node);
 | 
|---|
| [461046f] | 346 |                 return node;
 | 
|---|
 | 347 |         }
 | 
|---|
 | 348 | 
 | 
|---|
| [e67991f] | 349 |         virtual const ast::Decl * visit( const ast::UnionDecl * node ) override final {
 | 
|---|
| [5902625] | 350 |                 print(node);
 | 
|---|
| [461046f] | 351 |                 return node;
 | 
|---|
 | 352 |         }
 | 
|---|
 | 353 | 
 | 
|---|
| [e67991f] | 354 |         virtual const ast::Decl * visit( const ast::EnumDecl * node ) override final {
 | 
|---|
| [5902625] | 355 |                 print(node);
 | 
|---|
| [461046f] | 356 |                 return node;
 | 
|---|
 | 357 |         }
 | 
|---|
 | 358 | 
 | 
|---|
| [e67991f] | 359 |         virtual const ast::Decl * visit( const ast::TraitDecl * node ) override final {
 | 
|---|
| [5902625] | 360 |                 print(node);
 | 
|---|
| [461046f] | 361 |                 return node;
 | 
|---|
 | 362 |         }
 | 
|---|
 | 363 | 
 | 
|---|
| [e67991f] | 364 |         virtual const ast::Decl * visit( const ast::TypeDecl * node ) override final {
 | 
|---|
| [6f4b7f2] | 365 |                 preprint( node );
 | 
|---|
 | 366 |                 if ( ! short_mode && node->init ) {
 | 
|---|
| [5902625] | 367 |                         os << endl << indent << "with type initializer: ";
 | 
|---|
 | 368 |                         ++indent;
 | 
|---|
 | 369 |                         node->init->accept( *this );
 | 
|---|
 | 370 |                         --indent;
 | 
|---|
 | 371 |                 }
 | 
|---|
| [6f4b7f2] | 372 | 
 | 
|---|
| [461046f] | 373 |                 return node;
 | 
|---|
 | 374 |         }
 | 
|---|
 | 375 | 
 | 
|---|
| [e67991f] | 376 |         virtual const ast::Decl * visit( const ast::TypedefDecl * node ) override final {
 | 
|---|
| [6f4b7f2] | 377 |                 preprint( node );
 | 
|---|
| [461046f] | 378 |                 return node;
 | 
|---|
 | 379 |         }
 | 
|---|
 | 380 | 
 | 
|---|
| [e67991f] | 381 |         virtual const ast::AsmDecl * visit( const ast::AsmDecl * node ) override final {
 | 
|---|
| [6f4b7f2] | 382 |                 safe_print( node->stmt );
 | 
|---|
| [461046f] | 383 |                 return node;
 | 
|---|
 | 384 |         }
 | 
|---|
 | 385 | 
 | 
|---|
| [e67991f] | 386 |         virtual const ast::StaticAssertDecl * visit( const ast::StaticAssertDecl * node ) override final {
 | 
|---|
| [5902625] | 387 |                 os << "Static Assert with condition: ";
 | 
|---|
 | 388 |                 ++indent;
 | 
|---|
| [6f4b7f2] | 389 |                 safe_print( node->cond );
 | 
|---|
 | 390 |                 os << endl << indent-1 << "and message: ";
 | 
|---|
 | 391 |                 safe_print( node->msg );
 | 
|---|
| [5902625] | 392 |                 --indent;
 | 
|---|
 | 393 |                 os << endl;
 | 
|---|
| [6f4b7f2] | 394 | 
 | 
|---|
| [461046f] | 395 |                 return node;
 | 
|---|
 | 396 |         }
 | 
|---|
 | 397 | 
 | 
|---|
| [e67991f] | 398 |         virtual const ast::CompoundStmt * visit( const ast::CompoundStmt * node ) override final {
 | 
|---|
| [94b1f718] | 399 |                 os << "Compound Statement:" << endl;
 | 
|---|
| [5902625] | 400 |                 ++indent;
 | 
|---|
 | 401 |                 printAll( node->kids );
 | 
|---|
 | 402 |                 --indent;
 | 
|---|
| [461046f] | 403 |                 return node;
 | 
|---|
 | 404 |         }
 | 
|---|
 | 405 | 
 | 
|---|
| [e67991f] | 406 |         virtual const ast::Stmt * visit( const ast::ExprStmt * node ) override final {
 | 
|---|
| [5902625] | 407 |                 ++indent;
 | 
|---|
 | 408 |                 os << "Expression Statement:" << endl << indent;
 | 
|---|
| [20a5977] | 409 |                 safe_print( node->expr );
 | 
|---|
| [5902625] | 410 |                 --indent;
 | 
|---|
| [461046f] | 411 |                 return node;
 | 
|---|
 | 412 |         }
 | 
|---|
 | 413 | 
 | 
|---|
| [e67991f] | 414 |         virtual const ast::Stmt * visit( const ast::AsmStmt * node ) override final {
 | 
|---|
| [5902625] | 415 |                 os << "Assembler Statement:" << endl;
 | 
|---|
 | 416 |                 ++indent;
 | 
|---|
| [94b1f718] | 417 |                 os << indent-1 << "instruction:" << endl << indent;
 | 
|---|
 | 418 |                 safe_print( node->instruction );
 | 
|---|
| [5902625] | 419 |                 if ( ! node->output.empty() ) {
 | 
|---|
| [94b1f718] | 420 |                         os << endl << indent << "output:" << endl;
 | 
|---|
| [5902625] | 421 |                         printAll( node->output );
 | 
|---|
 | 422 |                 } // if
 | 
|---|
 | 423 |                 if ( ! node->input.empty() ) {
 | 
|---|
| [94b1f718] | 424 |                         os << indent << "input:" << endl;
 | 
|---|
| [5902625] | 425 |                         printAll( node->input );
 | 
|---|
 | 426 |                 } // if
 | 
|---|
 | 427 |                 if ( ! node->clobber.empty() ) {
 | 
|---|
| [94b1f718] | 428 |                         os << indent << "clobber:" << endl;
 | 
|---|
| [5902625] | 429 |                         printAll( node->clobber );
 | 
|---|
 | 430 |                 } // if
 | 
|---|
 | 431 |                 --indent;
 | 
|---|
| [461046f] | 432 |                 return node;
 | 
|---|
 | 433 |         }
 | 
|---|
 | 434 | 
 | 
|---|
| [e67991f] | 435 |         virtual const ast::Stmt * visit( const ast::DirectiveStmt * node ) override final {
 | 
|---|
| [94b1f718] | 436 |                 os << "GCC Directive: " << node->directive << endl;
 | 
|---|
| [461046f] | 437 |                 return node;
 | 
|---|
 | 438 |         }
 | 
|---|
 | 439 | 
 | 
|---|
| [e67991f] | 440 |         virtual const ast::Stmt * visit( const ast::IfStmt * node ) override final {
 | 
|---|
| [94b1f718] | 441 |                 os << "If on condition:" << endl;
 | 
|---|
| [5902625] | 442 |                 ++indent;
 | 
|---|
| [94b1f718] | 443 |                 os << indent;
 | 
|---|
| [20a5977] | 444 |                 safe_print( node->cond );
 | 
|---|
| [5902625] | 445 |                 --indent;
 | 
|---|
 | 446 | 
 | 
|---|
| [94b1f718] | 447 |                 if ( ! node->inits.empty() ) {
 | 
|---|
 | 448 |                         os << indent << "... with initialization:" << endl;
 | 
|---|
| [5902625] | 449 |                         ++indent;
 | 
|---|
| [94b1f718] | 450 |                         for ( const ast::Stmt * stmt : node->inits ) {
 | 
|---|
| [5902625] | 451 |                                 os << indent;
 | 
|---|
| [94b1f718] | 452 |                                 safe_print( stmt );
 | 
|---|
| [5902625] | 453 |                         }
 | 
|---|
 | 454 |                         --indent;
 | 
|---|
 | 455 |                         os << endl;
 | 
|---|
 | 456 |                 }
 | 
|---|
 | 457 | 
 | 
|---|
| [94b1f718] | 458 |                 os << indent << "... then:" << endl;
 | 
|---|
| [5902625] | 459 | 
 | 
|---|
 | 460 |                 ++indent;
 | 
|---|
 | 461 |                 os << indent;
 | 
|---|
| [20a5977] | 462 |                 safe_print( node->thenPart );
 | 
|---|
| [5902625] | 463 |                 --indent;
 | 
|---|
 | 464 | 
 | 
|---|
 | 465 |                 if ( node->elsePart != 0 ) {
 | 
|---|
| [94b1f718] | 466 |                         os << indent << "... else:" << endl;
 | 
|---|
| [5902625] | 467 |                         ++indent;
 | 
|---|
 | 468 |                         os << indent;
 | 
|---|
 | 469 |                         node->elsePart->accept( *this );
 | 
|---|
 | 470 |                         --indent;
 | 
|---|
 | 471 |                 } // if
 | 
|---|
| [461046f] | 472 |                 return node;
 | 
|---|
 | 473 |         }
 | 
|---|
 | 474 | 
 | 
|---|
| [e67991f] | 475 |         virtual const ast::Stmt * visit( const ast::WhileStmt * node ) override final {
 | 
|---|
| [94b1f718] | 476 |                 if ( node->isDoWhile ) { os << "Do-"; }
 | 
|---|
 | 477 |                 os << "While on condition:" << endl;
 | 
|---|
 | 478 |                 ++indent;
 | 
|---|
 | 479 |                 safe_print( node->cond );
 | 
|---|
 | 480 |                 os << indent-1 << "... with body:" << endl;
 | 
|---|
 | 481 |                 safe_print( node->body );
 | 
|---|
 | 482 | 
 | 
|---|
 | 483 |                 if ( ! node->inits.empty() ) {
 | 
|---|
 | 484 |                         os << indent-1 << "... with inits:" << endl;
 | 
|---|
 | 485 |                         printAll( node->inits );
 | 
|---|
 | 486 |                 }
 | 
|---|
 | 487 |                 --indent;
 | 
|---|
 | 488 | 
 | 
|---|
| [461046f] | 489 |                 return node;
 | 
|---|
 | 490 |         }
 | 
|---|
 | 491 | 
 | 
|---|
| [e67991f] | 492 |         virtual const ast::Stmt * visit( const ast::ForStmt * node ) override final {
 | 
|---|
| [94b1f718] | 493 |                 os << "For Statement" << endl;
 | 
|---|
 | 494 | 
 | 
|---|
 | 495 |                 if ( ! node->inits.empty() ) {
 | 
|---|
 | 496 |                         os << indent << "... initialization:" << endl;
 | 
|---|
 | 497 |                         ++indent;
 | 
|---|
 | 498 |                         for ( const ast::Stmt * stmt : node->inits ) {
 | 
|---|
 | 499 |                                 os << indent+1;
 | 
|---|
 | 500 |                                 safe_print( stmt );
 | 
|---|
 | 501 |                         }
 | 
|---|
 | 502 |                         --indent;
 | 
|---|
 | 503 |                 }
 | 
|---|
 | 504 | 
 | 
|---|
 | 505 |                 if ( node->cond ) {
 | 
|---|
 | 506 |                         os << indent << "... condition:" << endl;
 | 
|---|
 | 507 |                         ++indent;
 | 
|---|
 | 508 |                         os << indent;
 | 
|---|
 | 509 |                         node->cond->accept( *this );
 | 
|---|
 | 510 |                         --indent;
 | 
|---|
 | 511 |                 }
 | 
|---|
 | 512 | 
 | 
|---|
 | 513 |                 if ( node->inc ) {
 | 
|---|
 | 514 |                         os << indent << "... increment:" << endl;
 | 
|---|
 | 515 |                         ++indent;
 | 
|---|
 | 516 |                         os << indent;
 | 
|---|
 | 517 |                         node->inc->accept( *this );
 | 
|---|
 | 518 |                         --indent;
 | 
|---|
 | 519 |                 }
 | 
|---|
 | 520 | 
 | 
|---|
 | 521 |                 if ( node->body ) {
 | 
|---|
 | 522 |                         os << indent << "... with body:" << endl;
 | 
|---|
 | 523 |                         ++indent;
 | 
|---|
 | 524 |                         os << indent;
 | 
|---|
 | 525 |                         node->body->accept( *this );
 | 
|---|
 | 526 |                         --indent;
 | 
|---|
 | 527 |                 }
 | 
|---|
 | 528 |                 os << endl;
 | 
|---|
 | 529 |                 print( node->labels );
 | 
|---|
 | 530 | 
 | 
|---|
| [461046f] | 531 |                 return node;
 | 
|---|
 | 532 |         }
 | 
|---|
 | 533 | 
 | 
|---|
| [e67991f] | 534 |         virtual const ast::Stmt * visit( const ast::SwitchStmt * node ) override final {
 | 
|---|
| [94b1f718] | 535 |                 os << "Switch on condition: ";
 | 
|---|
 | 536 |                 safe_print( node->cond );
 | 
|---|
 | 537 |                 os << endl;
 | 
|---|
 | 538 | 
 | 
|---|
 | 539 |                 ++indent;
 | 
|---|
 | 540 |                 for ( const ast::Stmt * stmt : node->stmts ) {
 | 
|---|
 | 541 |                         stmt->accept( *this );
 | 
|---|
 | 542 |                 }
 | 
|---|
 | 543 |                 --indent;
 | 
|---|
 | 544 | 
 | 
|---|
| [461046f] | 545 |                 return node;
 | 
|---|
 | 546 |         }
 | 
|---|
 | 547 | 
 | 
|---|
| [e67991f] | 548 |         virtual const ast::Stmt * visit( const ast::CaseStmt * node ) override final {
 | 
|---|
| [94b1f718] | 549 |                 if ( node->isDefault() ) {
 | 
|---|
 | 550 |                         os << indent << "Default ";
 | 
|---|
 | 551 |                 } else {
 | 
|---|
 | 552 |                         os << indent << "Case ";
 | 
|---|
 | 553 |                         safe_print( node->cond );
 | 
|---|
 | 554 |                 } // if
 | 
|---|
 | 555 |                 os << endl;
 | 
|---|
 | 556 | 
 | 
|---|
 | 557 |                 ++indent;
 | 
|---|
 | 558 |                 for ( const ast::Stmt * stmt : node->stmts ) {
 | 
|---|
 | 559 |                         os << indent;
 | 
|---|
 | 560 |                         stmt->accept( *this );
 | 
|---|
 | 561 |                 }
 | 
|---|
 | 562 |                 --indent;
 | 
|---|
 | 563 | 
 | 
|---|
| [461046f] | 564 |                 return node;
 | 
|---|
 | 565 |         }
 | 
|---|
 | 566 | 
 | 
|---|
| [e67991f] | 567 |         virtual const ast::Stmt * visit( const ast::BranchStmt * node ) override final {
 | 
|---|
| [94b1f718] | 568 |                 os << "Branch (" << node->kindName() << ")" << endl;
 | 
|---|
 | 569 |                 ++indent;
 | 
|---|
 | 570 |                 if ( ! node->target.empty() ) {
 | 
|---|
 | 571 |                         os << indent << "with target: " << node->target << endl;
 | 
|---|
 | 572 |                 }
 | 
|---|
 | 573 | 
 | 
|---|
 | 574 |                 if ( ! node->originalTarget.empty() ) {
 | 
|---|
 | 575 |                         os << indent << "with original target: " << node->originalTarget << endl;
 | 
|---|
 | 576 |                 }
 | 
|---|
 | 577 | 
 | 
|---|
 | 578 |                 if ( node->computedTarget ) {
 | 
|---|
 | 579 |                         os << indent << "with computed target: ";
 | 
|---|
 | 580 |                         node->computedTarget->accept( *this );
 | 
|---|
 | 581 |                         os << endl;
 | 
|---|
 | 582 |                 }
 | 
|---|
 | 583 |                 --indent;
 | 
|---|
 | 584 | 
 | 
|---|
| [461046f] | 585 |                 return node;
 | 
|---|
 | 586 |         }
 | 
|---|
 | 587 | 
 | 
|---|
| [e67991f] | 588 |         virtual const ast::Stmt * visit( const ast::ReturnStmt * node ) override final {
 | 
|---|
| [94b1f718] | 589 |                 os << "Return Statement, returning";
 | 
|---|
 | 590 |                 if ( node->expr ) {
 | 
|---|
 | 591 |                         ++indent;
 | 
|---|
 | 592 |                         os << ":" << endl << indent;
 | 
|---|
 | 593 |                         node->expr->accept( *this );
 | 
|---|
 | 594 |                         --indent;
 | 
|---|
 | 595 |                 } else {
 | 
|---|
 | 596 |                         os << " void";
 | 
|---|
 | 597 |                 }
 | 
|---|
 | 598 |                 os << endl;
 | 
|---|
 | 599 | 
 | 
|---|
| [461046f] | 600 |                 return node;
 | 
|---|
 | 601 |         }
 | 
|---|
 | 602 | 
 | 
|---|
| [e67991f] | 603 |         virtual const ast::Stmt * visit( const ast::ThrowStmt * node ) override final {
 | 
|---|
| [6f4b7f2] | 604 |                 if ( node->target ) os << "Non-Local ";
 | 
|---|
 | 605 | 
 | 
|---|
 | 606 |                 switch( node->kind ) {
 | 
|---|
 | 607 |                 case ast::ExceptionKind::Terminate: os << "Terminate "; break;
 | 
|---|
 | 608 |                 case ast::ExceptionKind::Resume:    os << "Resume ";    break;
 | 
|---|
 | 609 |                 }
 | 
|---|
 | 610 | 
 | 
|---|
 | 611 |                 ++indent;
 | 
|---|
 | 612 |                 os << "Throw Statement, raising: ";
 | 
|---|
 | 613 |                 safe_print( node->expr );
 | 
|---|
 | 614 |                 if ( node->target ) {
 | 
|---|
 | 615 |                         os << "... at: ";
 | 
|---|
 | 616 |                         node->target->accept( *this );
 | 
|---|
 | 617 |                 }
 | 
|---|
 | 618 |                 --indent;
 | 
|---|
 | 619 | 
 | 
|---|
| [461046f] | 620 |                 return node;
 | 
|---|
 | 621 |         }
 | 
|---|
 | 622 | 
 | 
|---|
| [e67991f] | 623 |         virtual const ast::Stmt * visit( const ast::TryStmt * node ) override final {
 | 
|---|
| [6f4b7f2] | 624 |                 ++indent;
 | 
|---|
| [a7d50b6] | 625 |                 os << "Try Statement" << endl << indent-1
 | 
|---|
| [6f4b7f2] | 626 |                    << "... with block:" << endl << indent;
 | 
|---|
 | 627 |                 safe_print( node->body );
 | 
|---|
 | 628 | 
 | 
|---|
 | 629 |                 os << indent-1 << "... and handlers:" << endl;
 | 
|---|
 | 630 |                 for ( const ast::CatchStmt * stmt : node->handlers ) {
 | 
|---|
 | 631 |                         os << indent;
 | 
|---|
 | 632 |                         stmt->accept( *this );
 | 
|---|
 | 633 |                 }
 | 
|---|
 | 634 | 
 | 
|---|
 | 635 |                 if ( node->finally ) {
 | 
|---|
 | 636 |                         os << indent-1 << "... and finally:" << endl << indent;
 | 
|---|
 | 637 |                         node->finally->accept( *this );
 | 
|---|
 | 638 |                 }
 | 
|---|
 | 639 |                 --indent;
 | 
|---|
 | 640 | 
 | 
|---|
| [461046f] | 641 |                 return node;
 | 
|---|
 | 642 |         }
 | 
|---|
 | 643 | 
 | 
|---|
| [e67991f] | 644 |         virtual const ast::Stmt * visit( const ast::CatchStmt * node ) override final {
 | 
|---|
| [6f4b7f2] | 645 |                 os << "Catch ";
 | 
|---|
 | 646 |                 switch ( node->kind ) {
 | 
|---|
 | 647 |                 case ast::ExceptionKind::Terminate: os << "Terminate "; break;
 | 
|---|
 | 648 |                 case ast::ExceptionKind::Resume:    os << "Resume ";    break;
 | 
|---|
 | 649 |                 }
 | 
|---|
 | 650 |                 os << "Statement" << endl << indent;
 | 
|---|
 | 651 | 
 | 
|---|
 | 652 |                 ++indent;
 | 
|---|
 | 653 |                 os << "... catching: ";
 | 
|---|
 | 654 |                 short_print( node->decl );
 | 
|---|
 | 655 |                 os << endl;
 | 
|---|
 | 656 | 
 | 
|---|
 | 657 |                 if ( node->cond ) {
 | 
|---|
 | 658 |                         os << indent-1 << "... with conditional:" << endl << indent;
 | 
|---|
 | 659 |                         node->cond->accept( *this );
 | 
|---|
 | 660 |                 }
 | 
|---|
 | 661 | 
 | 
|---|
 | 662 |                 os << indent-1 << "... with block:" << endl << indent;
 | 
|---|
 | 663 |                 safe_print( node->body );
 | 
|---|
 | 664 |                 --indent;
 | 
|---|
| [a7d50b6] | 665 | 
 | 
|---|
| [461046f] | 666 |                 return node;
 | 
|---|
 | 667 |         }
 | 
|---|
 | 668 | 
 | 
|---|
| [e67991f] | 669 |         virtual const ast::Stmt * visit( const ast::FinallyStmt * node ) override final {
 | 
|---|
| [6f4b7f2] | 670 |                 os << "Finally Statement" << endl;
 | 
|---|
 | 671 |                 os << indent << "... with block:" << endl;
 | 
|---|
 | 672 |                 ++indent;
 | 
|---|
 | 673 |                 os << indent;
 | 
|---|
 | 674 |                 safe_print( node->body );
 | 
|---|
 | 675 |                 --indent;
 | 
|---|
 | 676 | 
 | 
|---|
| [461046f] | 677 |                 return node;
 | 
|---|
 | 678 |         }
 | 
|---|
 | 679 | 
 | 
|---|
| [37cdd97] | 680 |         virtual const ast::Stmt * visit( const ast::SuspendStmt * node ) override final {
 | 
|---|
 | 681 |                 os << "Suspend Statement";
 | 
|---|
 | 682 |                 switch (node->type) {
 | 
|---|
 | 683 |                         case ast::SuspendStmt::None     : os << " with implicit target"; break;
 | 
|---|
 | 684 |                         case ast::SuspendStmt::Generator: os << " for generator"; break;
 | 
|---|
 | 685 |                         case ast::SuspendStmt::Coroutine: os << " for coroutine"; break;
 | 
|---|
 | 686 |                 }
 | 
|---|
 | 687 |                 os << endl;
 | 
|---|
 | 688 | 
 | 
|---|
 | 689 |                 ++indent;
 | 
|---|
 | 690 |                 if(node->then) {
 | 
|---|
 | 691 |                         os << indent << " with post statement :" << endl;
 | 
|---|
 | 692 |                         safe_print( node->then );
 | 
|---|
 | 693 |                 }
 | 
|---|
 | 694 |                 ++indent;
 | 
|---|
 | 695 | 
 | 
|---|
 | 696 |                 return node;
 | 
|---|
 | 697 |         }
 | 
|---|
 | 698 | 
 | 
|---|
| [e67991f] | 699 |         virtual const ast::Stmt * visit( const ast::WaitForStmt * node ) override final {
 | 
|---|
| [6f4b7f2] | 700 |                 os << "Waitfor Statement" << endl;
 | 
|---|
 | 701 |                 indent += 2;
 | 
|---|
 | 702 |                 for( const auto & clause : node->clauses ) {
 | 
|---|
 | 703 |                         os << indent-1 << "target function: ";
 | 
|---|
 | 704 |                         safe_print( clause.target.func );
 | 
|---|
| [a7d50b6] | 705 | 
 | 
|---|
| [6f4b7f2] | 706 |                         if ( ! clause.target.args.empty() ) {
 | 
|---|
 | 707 |                                 os << endl << indent-1 << "... with arguments:" << endl;
 | 
|---|
 | 708 |                                 for( const ast::Expr * arg : clause.target.args ) {
 | 
|---|
 | 709 |                                         arg->accept( *this );
 | 
|---|
 | 710 |                                 }
 | 
|---|
 | 711 |                         }
 | 
|---|
 | 712 | 
 | 
|---|
 | 713 |                         if ( clause.stmt ) {
 | 
|---|
 | 714 |                                 os << indent-1 << "... with statment:" << endl;
 | 
|---|
 | 715 |                                 clause.stmt->accept( *this );
 | 
|---|
 | 716 |                         }
 | 
|---|
 | 717 | 
 | 
|---|
 | 718 |                         if ( clause.cond ) {
 | 
|---|
 | 719 |                                 os << indent-1 << "... with condition:" << endl;
 | 
|---|
 | 720 |                                 clause.cond->accept( *this );
 | 
|---|
 | 721 |                         }
 | 
|---|
 | 722 |                 }
 | 
|---|
 | 723 | 
 | 
|---|
 | 724 |                 if ( node->timeout.time ) {
 | 
|---|
 | 725 |                         os << indent-1 << "timeout of:" << endl;
 | 
|---|
 | 726 |                         node->timeout.time->accept( *this );
 | 
|---|
 | 727 | 
 | 
|---|
 | 728 |                         if ( node->timeout.stmt ) {
 | 
|---|
 | 729 |                                 os << indent-1 << "... with statment:" << endl;
 | 
|---|
 | 730 |                                 node->timeout.stmt->accept( *this );
 | 
|---|
 | 731 |                         }
 | 
|---|
 | 732 | 
 | 
|---|
 | 733 |                         if ( node->timeout.cond ) {
 | 
|---|
 | 734 |                                 os << indent-1 << "... with condition:" << endl;
 | 
|---|
 | 735 |                                 node->timeout.cond->accept( *this );
 | 
|---|
 | 736 |                         }
 | 
|---|
 | 737 |                 }
 | 
|---|
 | 738 | 
 | 
|---|
 | 739 |                 if ( node->orElse.stmt ) {
 | 
|---|
 | 740 |                         os << indent-1 << "else:" << endl;
 | 
|---|
 | 741 |                         node->orElse.stmt->accept( *this );
 | 
|---|
 | 742 | 
 | 
|---|
 | 743 |                         if ( node->orElse.cond ) {
 | 
|---|
 | 744 |                                 os << indent-1 << "... with condition:" << endl;
 | 
|---|
 | 745 |                                 node->orElse.cond->accept( *this );
 | 
|---|
 | 746 |                         }
 | 
|---|
 | 747 |                 }
 | 
|---|
 | 748 |                 indent -= 2;
 | 
|---|
 | 749 | 
 | 
|---|
| [461046f] | 750 |                 return node;
 | 
|---|
 | 751 |         }
 | 
|---|
 | 752 | 
 | 
|---|
| [e67991f] | 753 |         virtual const ast::Decl * visit( const ast::WithStmt * node ) override final {
 | 
|---|
| [6f4b7f2] | 754 |                 os << "With statement" << endl;
 | 
|---|
 | 755 |                 os << indent << "... with expressions:" << endl;
 | 
|---|
 | 756 |                 ++indent;
 | 
|---|
 | 757 |                 printAll( node->exprs );
 | 
|---|
 | 758 |                 os << indent-1 << "... with statement:" << endl << indent;
 | 
|---|
 | 759 |                 safe_print( node->stmt );
 | 
|---|
 | 760 |                 --indent;
 | 
|---|
 | 761 | 
 | 
|---|
| [461046f] | 762 |                 return node;
 | 
|---|
 | 763 |         }
 | 
|---|
 | 764 | 
 | 
|---|
| [e67991f] | 765 |         virtual const ast::NullStmt * visit( const ast::NullStmt * node ) override final {
 | 
|---|
| [94b1f718] | 766 |                 os << "Null Statement" << endl;
 | 
|---|
 | 767 |                 print( node->labels );
 | 
|---|
 | 768 | 
 | 
|---|
| [461046f] | 769 |                 return node;
 | 
|---|
 | 770 |         }
 | 
|---|
 | 771 | 
 | 
|---|
| [e67991f] | 772 |         virtual const ast::Stmt * visit( const ast::DeclStmt * node ) override final {
 | 
|---|
| [6f4b7f2] | 773 |                 os << "Declaration of ";
 | 
|---|
 | 774 |                 safe_print( node->decl );
 | 
|---|
 | 775 | 
 | 
|---|
| [461046f] | 776 |                 return node;
 | 
|---|
 | 777 |         }
 | 
|---|
 | 778 | 
 | 
|---|
| [e67991f] | 779 |         virtual const ast::Stmt * visit( const ast::ImplicitCtorDtorStmt * node ) override final {
 | 
|---|
| [6f4b7f2] | 780 |                 os << "Implicit Ctor Dtor Statement" << endl;
 | 
|---|
 | 781 |                 os << indent << "... with Ctor/Dtor: ";
 | 
|---|
 | 782 |                 ++indent;
 | 
|---|
 | 783 |                 safe_print( node->callStmt );
 | 
|---|
 | 784 |                 --indent;
 | 
|---|
 | 785 |                 os << endl;
 | 
|---|
 | 786 | 
 | 
|---|
| [461046f] | 787 |                 return node;
 | 
|---|
 | 788 |         }
 | 
|---|
 | 789 | 
 | 
|---|
| [e67991f] | 790 |         virtual const ast::Expr * visit( const ast::ApplicationExpr * node ) override final {
 | 
|---|
| [20a5977] | 791 |                 ++indent;
 | 
|---|
| [94b1f718] | 792 |                 os << "Application of" << endl << indent;
 | 
|---|
| [20a5977] | 793 |                 safe_print( node->func );
 | 
|---|
| [94b1f718] | 794 |                 os << endl;
 | 
|---|
| [20a5977] | 795 |                 if ( ! node->args.empty() ) {
 | 
|---|
| [94b1f718] | 796 |                         os << indent << "... to arguments" << endl;
 | 
|---|
| [20a5977] | 797 |                         printAll( node->args );
 | 
|---|
 | 798 |                 }
 | 
|---|
 | 799 |                 --indent;
 | 
|---|
 | 800 |                 postprint( node );
 | 
|---|
 | 801 | 
 | 
|---|
| [461046f] | 802 |                 return node;
 | 
|---|
 | 803 |         }
 | 
|---|
 | 804 | 
 | 
|---|
| [e67991f] | 805 |         virtual const ast::Expr * visit( const ast::UntypedExpr * node ) override final {
 | 
|---|
| [20a5977] | 806 |                 ++indent;
 | 
|---|
| [94b1f718] | 807 |                 os << "Applying untyped:" << endl;
 | 
|---|
| [20a5977] | 808 |                 os << indent;
 | 
|---|
 | 809 |                 safe_print( node->func );
 | 
|---|
| [94b1f718] | 810 |                 os << endl << indent-1 << "...to:" << endl;
 | 
|---|
| [20a5977] | 811 |                 printAll( node->args );
 | 
|---|
 | 812 |                 --indent;
 | 
|---|
 | 813 |                 postprint( node );
 | 
|---|
 | 814 | 
 | 
|---|
| [461046f] | 815 |                 return node;
 | 
|---|
 | 816 |         }
 | 
|---|
 | 817 | 
 | 
|---|
| [e67991f] | 818 |         virtual const ast::Expr * visit( const ast::NameExpr * node ) override final {
 | 
|---|
| [20a5977] | 819 |                 os << "Name: " << node->name;
 | 
|---|
 | 820 |                 postprint( node );
 | 
|---|
| [d908563] | 821 | 
 | 
|---|
| [461046f] | 822 |                 return node;
 | 
|---|
 | 823 |         }
 | 
|---|
 | 824 | 
 | 
|---|
| [e67991f] | 825 |         virtual const ast::Expr * visit( const ast::AddressExpr * node ) override final {
 | 
|---|
| [94b1f718] | 826 |                 os << "Address of:" << endl;
 | 
|---|
| [20a5977] | 827 |                 ++indent;
 | 
|---|
 | 828 |                 os << indent;
 | 
|---|
 | 829 |                 safe_print( node->arg );
 | 
|---|
 | 830 | 
 | 
|---|
 | 831 |                 --indent;
 | 
|---|
 | 832 | 
 | 
|---|
| [461046f] | 833 |                 return node;
 | 
|---|
 | 834 |         }
 | 
|---|
 | 835 | 
 | 
|---|
| [e67991f] | 836 |         virtual const ast::Expr * visit( const ast::LabelAddressExpr * node ) override final {
 | 
|---|
| [20a5977] | 837 |                 os << "Address of label:" << node->arg;
 | 
|---|
 | 838 | 
 | 
|---|
| [461046f] | 839 |                 return node;
 | 
|---|
 | 840 |         }
 | 
|---|
 | 841 | 
 | 
|---|
| [e67991f] | 842 |         virtual const ast::Expr * visit( const ast::CastExpr * node ) override final {
 | 
|---|
| [20a5977] | 843 |                 ++indent;
 | 
|---|
| [94b1f718] | 844 |                 os << (node->isGenerated ? "Generated" : "Explicit") << " cast of:" << endl << indent;
 | 
|---|
| [20a5977] | 845 |                 safe_print( node->arg );
 | 
|---|
| [94b1f718] | 846 |                 os << endl << indent-1 << "... to:";
 | 
|---|
| [20a5977] | 847 |                 if ( ! node->result ) {
 | 
|---|
 | 848 |                         os << " ";
 | 
|---|
 | 849 |                         undefined();
 | 
|---|
 | 850 |                 } else if ( node->result->isVoid() ) {
 | 
|---|
 | 851 |                         os << " nothing";
 | 
|---|
 | 852 |                 } else {
 | 
|---|
| [94b1f718] | 853 |                         os << endl << indent;
 | 
|---|
| [20a5977] | 854 |                         node->result->accept( *this );
 | 
|---|
 | 855 |                 } // if
 | 
|---|
 | 856 |                 --indent;
 | 
|---|
 | 857 |                 postprint( node );
 | 
|---|
 | 858 | 
 | 
|---|
| [461046f] | 859 |                 return node;
 | 
|---|
 | 860 |         }
 | 
|---|
 | 861 | 
 | 
|---|
| [e67991f] | 862 |         virtual const ast::Expr * visit( const ast::KeywordCastExpr * node ) override final {
 | 
|---|
| [20a5977] | 863 |                 ++indent;
 | 
|---|
| [94b1f718] | 864 |                 os << "Keyword Cast of:" << endl << indent;
 | 
|---|
| [20a5977] | 865 |                 safe_print( node->arg );
 | 
|---|
 | 866 |                 --indent;
 | 
|---|
| [94b1f718] | 867 |                 os << endl << indent << "... to: " << node->targetString();
 | 
|---|
| [20a5977] | 868 |                 postprint( node );
 | 
|---|
 | 869 | 
 | 
|---|
| [461046f] | 870 |                 return node;
 | 
|---|
 | 871 |         }
 | 
|---|
 | 872 | 
 | 
|---|
| [e67991f] | 873 |         virtual const ast::Expr * visit( const ast::VirtualCastExpr * node ) override final {
 | 
|---|
| [20a5977] | 874 |                 ++indent;
 | 
|---|
| [94b1f718] | 875 |                 os << "Virtual Cast of:" << endl << indent;
 | 
|---|
| [20a5977] | 876 |                 safe_print( node->arg );
 | 
|---|
| [94b1f718] | 877 |                 os << endl << indent-1 << "... to:";
 | 
|---|
| [20a5977] | 878 |                 if ( ! node->result ) {
 | 
|---|
 | 879 |                         os << " unknown";
 | 
|---|
 | 880 |                 } else {
 | 
|---|
| [94b1f718] | 881 |                         os << endl << indent;
 | 
|---|
| [20a5977] | 882 |                         node->result->accept( *this );
 | 
|---|
 | 883 |                 }
 | 
|---|
 | 884 |                 --indent;
 | 
|---|
 | 885 |                 postprint( node );
 | 
|---|
 | 886 | 
 | 
|---|
| [461046f] | 887 |                 return node;
 | 
|---|
 | 888 |         }
 | 
|---|
 | 889 | 
 | 
|---|
| [e67991f] | 890 |         virtual const ast::Expr * visit( const ast::UntypedMemberExpr * node ) override final {
 | 
|---|
| [20a5977] | 891 |                 ++indent;
 | 
|---|
| [94b1f718] | 892 |                 os << "Untyped Member Expression, with field: " << endl << indent;
 | 
|---|
| [20a5977] | 893 |                 safe_print( node->member );
 | 
|---|
| [94b1f718] | 894 |                 os << indent-1 << "... from aggregate:" << endl << indent;
 | 
|---|
| [20a5977] | 895 |                 safe_print( node->aggregate );
 | 
|---|
 | 896 |                 --indent;
 | 
|---|
 | 897 |                 postprint( node );
 | 
|---|
 | 898 | 
 | 
|---|
| [461046f] | 899 |                 return node;
 | 
|---|
 | 900 |         }
 | 
|---|
 | 901 | 
 | 
|---|
| [e67991f] | 902 |         virtual const ast::Expr * visit( const ast::MemberExpr * node ) override final {
 | 
|---|
| [20a5977] | 903 |                 ++indent;
 | 
|---|
| [94b1f718] | 904 |                 os << "Member Expression, with field:" << endl << indent;
 | 
|---|
| [20a5977] | 905 |                 safe_print( node->member );
 | 
|---|
| [94b1f718] | 906 |                 os << endl << indent-1 << "... from aggregate:" << endl << indent;
 | 
|---|
| [20a5977] | 907 |                 safe_print( node->aggregate );
 | 
|---|
 | 908 |                 --indent;
 | 
|---|
 | 909 |                 postprint( node );
 | 
|---|
 | 910 | 
 | 
|---|
| [461046f] | 911 |                 return node;
 | 
|---|
 | 912 |         }
 | 
|---|
 | 913 | 
 | 
|---|
| [e67991f] | 914 |         virtual const ast::Expr * visit( const ast::VariableExpr * node ) override final {
 | 
|---|
| [20a5977] | 915 |                 os << "Variable Expression: ";
 | 
|---|
 | 916 |                 short_print( node->var );
 | 
|---|
 | 917 |                 postprint( node );
 | 
|---|
 | 918 | 
 | 
|---|
| [461046f] | 919 |                 return node;
 | 
|---|
 | 920 |         }
 | 
|---|
 | 921 | 
 | 
|---|
| [e67991f] | 922 |         virtual const ast::Expr * visit( const ast::ConstantExpr * node ) override final {
 | 
|---|
| [20a5977] | 923 |                 os << "Constant Expression (" << node->rep;
 | 
|---|
 | 924 |                 if ( node->result ) {
 | 
|---|
 | 925 |                         os << ": ";
 | 
|---|
 | 926 |                         node->result->accept( *this );
 | 
|---|
 | 927 |                 }
 | 
|---|
 | 928 |                 os << ")";
 | 
|---|
 | 929 |                 postprint( node );
 | 
|---|
 | 930 | 
 | 
|---|
| [461046f] | 931 |                 return node;
 | 
|---|
 | 932 |         }
 | 
|---|
 | 933 | 
 | 
|---|
| [e67991f] | 934 |         virtual const ast::Expr * visit( const ast::SizeofExpr * node ) override final {
 | 
|---|
| [a16e246] | 935 |                 os << "Sizeof Expression on: ";
 | 
|---|
 | 936 |                 ++indent;
 | 
|---|
 | 937 |                 if ( node->type ) node->type->accept( *this );
 | 
|---|
 | 938 |                 else safe_print( node->expr );
 | 
|---|
 | 939 |                 --indent;
 | 
|---|
 | 940 |                 postprint( node );
 | 
|---|
 | 941 | 
 | 
|---|
| [461046f] | 942 |                 return node;
 | 
|---|
 | 943 |         }
 | 
|---|
 | 944 | 
 | 
|---|
| [e67991f] | 945 |         virtual const ast::Expr * visit( const ast::AlignofExpr * node ) override final {
 | 
|---|
| [a16e246] | 946 |                 os << "Alignof Expression on: ";
 | 
|---|
 | 947 |                 ++indent;
 | 
|---|
 | 948 |                 if ( node->type ) node->type->accept( *this );
 | 
|---|
 | 949 |                 else safe_print( node->expr );
 | 
|---|
 | 950 |                 --indent;
 | 
|---|
 | 951 |                 postprint( node );
 | 
|---|
| [d908563] | 952 | 
 | 
|---|
| [461046f] | 953 |                 return node;
 | 
|---|
 | 954 |         }
 | 
|---|
 | 955 | 
 | 
|---|
| [e67991f] | 956 |         virtual const ast::Expr * visit( const ast::UntypedOffsetofExpr * node ) override final {
 | 
|---|
| [a16e246] | 957 |                 os << "Untyped Offsetof Expression on member " << node->member << " of ";
 | 
|---|
 | 958 |                 ++indent;
 | 
|---|
 | 959 |                 safe_print( node->type );
 | 
|---|
 | 960 |                 --indent;
 | 
|---|
 | 961 |                 postprint( node );
 | 
|---|
 | 962 | 
 | 
|---|
| [461046f] | 963 |                 return node;
 | 
|---|
 | 964 |         }
 | 
|---|
 | 965 | 
 | 
|---|
| [e67991f] | 966 |         virtual const ast::Expr * visit( const ast::OffsetofExpr * node ) override final {
 | 
|---|
| [a16e246] | 967 |                 os << "Offsetof Expression on member " << node->member->name << " of ";
 | 
|---|
 | 968 |                 ++indent;
 | 
|---|
 | 969 |                 safe_print( node->type );
 | 
|---|
 | 970 |                 --indent;
 | 
|---|
 | 971 |                 postprint( node );
 | 
|---|
 | 972 | 
 | 
|---|
| [461046f] | 973 |                 return node;
 | 
|---|
 | 974 |         }
 | 
|---|
 | 975 | 
 | 
|---|
| [e67991f] | 976 |         virtual const ast::Expr * visit( const ast::OffsetPackExpr * node ) override final {
 | 
|---|
| [a16e246] | 977 |                 os << "Offset Pack Expression on: ";
 | 
|---|
 | 978 |                 ++indent;
 | 
|---|
 | 979 |                 safe_print( node->type );
 | 
|---|
 | 980 |                 --indent;
 | 
|---|
 | 981 |                 postprint( node );
 | 
|---|
 | 982 | 
 | 
|---|
| [461046f] | 983 |                 return node;
 | 
|---|
 | 984 |         }
 | 
|---|
 | 985 | 
 | 
|---|
| [e67991f] | 986 |         virtual const ast::Expr * visit( const ast::LogicalExpr * node ) override final {
 | 
|---|
| [a16e246] | 987 |                 os << "Short-circuited operation (" << (node->isAnd ? "and" : "or") << ") on: ";
 | 
|---|
 | 988 |                 safe_print( node->arg1 );
 | 
|---|
 | 989 |                 os << " and ";
 | 
|---|
 | 990 |                 safe_print( node->arg2 );
 | 
|---|
 | 991 |                 postprint( node );
 | 
|---|
 | 992 | 
 | 
|---|
| [461046f] | 993 |                 return node;
 | 
|---|
 | 994 |         }
 | 
|---|
 | 995 | 
 | 
|---|
| [e67991f] | 996 |         virtual const ast::Expr * visit( const ast::ConditionalExpr * node ) override final {
 | 
|---|
| [a16e246] | 997 |                 ++indent;
 | 
|---|
| [94b1f718] | 998 |                 os << "Conditional expression on:" << endl << indent;
 | 
|---|
| [a16e246] | 999 |                 safe_print( node->arg1 );
 | 
|---|
| [94b1f718] | 1000 |                 os << indent-1 << "First alternative:" << endl << indent;
 | 
|---|
| [a16e246] | 1001 |                 safe_print( node->arg2 );
 | 
|---|
| [94b1f718] | 1002 |                 os << indent-1 << "Second alternative:" << endl << indent;
 | 
|---|
| [a16e246] | 1003 |                 safe_print( node->arg3 );
 | 
|---|
 | 1004 |                 --indent;
 | 
|---|
 | 1005 |                 postprint( node );
 | 
|---|
 | 1006 | 
 | 
|---|
| [461046f] | 1007 |                 return node;
 | 
|---|
 | 1008 |         }
 | 
|---|
 | 1009 | 
 | 
|---|
| [e67991f] | 1010 |         virtual const ast::Expr * visit( const ast::CommaExpr * node ) override final {
 | 
|---|
| [a16e246] | 1011 |                 ++indent;
 | 
|---|
| [94b1f718] | 1012 |                 os << "Comma Expression:" << endl << indent;
 | 
|---|
| [a16e246] | 1013 |                 safe_print( node->arg1 );
 | 
|---|
| [94b1f718] | 1014 |                 os << endl << indent;
 | 
|---|
| [a16e246] | 1015 |                 safe_print( node->arg2 );
 | 
|---|
 | 1016 |                 --indent;
 | 
|---|
 | 1017 |                 postprint( node );
 | 
|---|
 | 1018 | 
 | 
|---|
| [461046f] | 1019 |                 return node;
 | 
|---|
 | 1020 |         }
 | 
|---|
 | 1021 | 
 | 
|---|
| [e67991f] | 1022 |         virtual const ast::Expr * visit( const ast::TypeExpr * node ) override final {
 | 
|---|
| [a16e246] | 1023 |                 safe_print( node->type );
 | 
|---|
 | 1024 |                 postprint( node );
 | 
|---|
 | 1025 | 
 | 
|---|
| [461046f] | 1026 |                 return node;
 | 
|---|
 | 1027 |         }
 | 
|---|
 | 1028 | 
 | 
|---|
| [e67991f] | 1029 |         virtual const ast::Expr * visit( const ast::AsmExpr * node ) override final {
 | 
|---|
| [94b1f718] | 1030 |                 os << "Asm Expression:" << endl;
 | 
|---|
| [a16e246] | 1031 |                 ++indent;
 | 
|---|
| [665f432] | 1032 |                 if ( !node->inout.empty() ) os << "[" << node->inout << "] ";
 | 
|---|
| [a16e246] | 1033 |                 if ( node->constraint ) node->constraint->accept( *this );
 | 
|---|
 | 1034 |                 if ( node->operand ) node->operand->accept( *this );
 | 
|---|
 | 1035 |                 --indent;
 | 
|---|
| [d908563] | 1036 | 
 | 
|---|
| [461046f] | 1037 |                 return node;
 | 
|---|
 | 1038 |         }
 | 
|---|
 | 1039 | 
 | 
|---|
| [e67991f] | 1040 |         virtual const ast::Expr * visit( const ast::ImplicitCopyCtorExpr * node ) override final {
 | 
|---|
| [a16e246] | 1041 |                 ++indent;
 | 
|---|
| [94b1f718] | 1042 |                 os << "Implicit Copy Constructor Expression:" << endl << indent;
 | 
|---|
| [a16e246] | 1043 |                 safe_print( node->callExpr );
 | 
|---|
 | 1044 |                 --indent;
 | 
|---|
 | 1045 |                 postprint( node );
 | 
|---|
 | 1046 | 
 | 
|---|
| [461046f] | 1047 |                 return node;
 | 
|---|
 | 1048 |         }
 | 
|---|
 | 1049 | 
 | 
|---|
| [e67991f] | 1050 |         virtual const ast::Expr * visit( const ast::ConstructorExpr * node ) override final {
 | 
|---|
| [94b1f718] | 1051 |                 os <<  "Constructor Expression:" << endl << indent+1;
 | 
|---|
| [a16e246] | 1052 |                 indent += 2;
 | 
|---|
 | 1053 |                 safe_print( node->callExpr );
 | 
|---|
 | 1054 |                 indent -= 2;
 | 
|---|
 | 1055 |                 postprint( node );
 | 
|---|
 | 1056 | 
 | 
|---|
| [461046f] | 1057 |                 return node;
 | 
|---|
 | 1058 |         }
 | 
|---|
 | 1059 | 
 | 
|---|
| [e67991f] | 1060 |         virtual const ast::Expr * visit( const ast::CompoundLiteralExpr * node ) override final {
 | 
|---|
| [a16e246] | 1061 |                 ++indent;
 | 
|---|
| [94b1f718] | 1062 |                 os << "Compound Literal Expression: " << endl << indent;
 | 
|---|
| [a16e246] | 1063 |                 safe_print( node->result );
 | 
|---|
 | 1064 |                 os << indent;
 | 
|---|
 | 1065 |                 safe_print( node->init );
 | 
|---|
 | 1066 |                 --indent;
 | 
|---|
 | 1067 |                 postprint( node );
 | 
|---|
 | 1068 | 
 | 
|---|
| [461046f] | 1069 |                 return node;
 | 
|---|
 | 1070 |         }
 | 
|---|
 | 1071 | 
 | 
|---|
| [e67991f] | 1072 |         virtual const ast::Expr * visit( const ast::RangeExpr * node ) override final {
 | 
|---|
| [a16e246] | 1073 |                 os << "Range Expression: ";
 | 
|---|
 | 1074 |                 safe_print( node->low );
 | 
|---|
 | 1075 |                 os << " ... ";
 | 
|---|
 | 1076 |                 safe_print( node->high );
 | 
|---|
 | 1077 |                 postprint( node );
 | 
|---|
 | 1078 | 
 | 
|---|
| [461046f] | 1079 |                 return node;
 | 
|---|
 | 1080 |         }
 | 
|---|
 | 1081 | 
 | 
|---|
| [e67991f] | 1082 |         virtual const ast::Expr * visit( const ast::UntypedTupleExpr * node ) override final {
 | 
|---|
| [94b1f718] | 1083 |                 os << "Untyped Tuple:" << endl;
 | 
|---|
| [a16e246] | 1084 |                 ++indent;
 | 
|---|
 | 1085 |                 printAll( node->exprs );
 | 
|---|
 | 1086 |                 --indent;
 | 
|---|
 | 1087 |                 postprint( node );
 | 
|---|
 | 1088 | 
 | 
|---|
| [461046f] | 1089 |                 return node;
 | 
|---|
 | 1090 |         }
 | 
|---|
 | 1091 | 
 | 
|---|
| [e67991f] | 1092 |         virtual const ast::Expr * visit( const ast::TupleExpr * node ) override final {
 | 
|---|
| [94b1f718] | 1093 |                 os << "Tuple:" << endl;
 | 
|---|
| [a16e246] | 1094 |                 ++indent;
 | 
|---|
 | 1095 |                 printAll( node->exprs );
 | 
|---|
 | 1096 |                 --indent;
 | 
|---|
 | 1097 |                 postprint( node );
 | 
|---|
 | 1098 | 
 | 
|---|
| [461046f] | 1099 |                 return node;
 | 
|---|
 | 1100 |         }
 | 
|---|
 | 1101 | 
 | 
|---|
| [e67991f] | 1102 |         virtual const ast::Expr * visit( const ast::TupleIndexExpr * node ) override final {
 | 
|---|
| [94b1f718] | 1103 |                 os << "Tuple Index Expression, with tuple:" << endl;
 | 
|---|
| [a16e246] | 1104 |                 ++indent;
 | 
|---|
 | 1105 |                 os << indent;
 | 
|---|
 | 1106 |                 safe_print( node->tuple );
 | 
|---|
| [94b1f718] | 1107 |                 os << indent << "with index: " << node->index << endl;
 | 
|---|
| [a16e246] | 1108 |                 --indent;
 | 
|---|
 | 1109 |                 postprint( node );
 | 
|---|
| [d908563] | 1110 | 
 | 
|---|
| [461046f] | 1111 |                 return node;
 | 
|---|
 | 1112 |         }
 | 
|---|
 | 1113 | 
 | 
|---|
| [e67991f] | 1114 |         virtual const ast::Expr * visit( const ast::TupleAssignExpr * node ) override final {
 | 
|---|
| [94b1f718] | 1115 |                 os << "Tuple Assignment Expression, with stmt expr:" << endl;
 | 
|---|
| [a16e246] | 1116 |                 ++indent;
 | 
|---|
 | 1117 |                 os << indent;
 | 
|---|
 | 1118 |                 safe_print( node->stmtExpr );
 | 
|---|
 | 1119 |                 --indent;
 | 
|---|
 | 1120 |                 postprint( node );
 | 
|---|
 | 1121 | 
 | 
|---|
| [461046f] | 1122 |                 return node;
 | 
|---|
 | 1123 |         }
 | 
|---|
 | 1124 | 
 | 
|---|
| [e67991f] | 1125 |         virtual const ast::Expr * visit( const ast::StmtExpr * node ) override final {
 | 
|---|
| [a16e246] | 1126 |                 ++indent;
 | 
|---|
| [94b1f718] | 1127 |                 os << "Statement Expression:" << endl << indent;
 | 
|---|
| [a16e246] | 1128 |                 safe_print( node->stmts );
 | 
|---|
 | 1129 |                 if ( ! node->returnDecls.empty() ) {
 | 
|---|
 | 1130 |                         os << indent << "... with returnDecls: ";
 | 
|---|
 | 1131 |                         printAll( node->returnDecls );
 | 
|---|
 | 1132 |                 }
 | 
|---|
 | 1133 |                 if ( ! node->dtors.empty() ) {
 | 
|---|
 | 1134 |                         os << indent << "... with dtors: ";
 | 
|---|
 | 1135 |                         printAll( node->dtors );
 | 
|---|
 | 1136 |                 }
 | 
|---|
 | 1137 |                 --indent;
 | 
|---|
 | 1138 |                 postprint( node );
 | 
|---|
 | 1139 | 
 | 
|---|
| [461046f] | 1140 |                 return node;
 | 
|---|
 | 1141 |         }
 | 
|---|
 | 1142 | 
 | 
|---|
| [e67991f] | 1143 |         virtual const ast::Expr * visit( const ast::UniqueExpr * node ) override final {
 | 
|---|
| [a16e246] | 1144 |                 ++indent;
 | 
|---|
| [94b1f718] | 1145 |                 os << "Unique Expression with id: " << node->id << endl << indent;
 | 
|---|
| [a16e246] | 1146 |                 safe_print( node->expr );
 | 
|---|
 | 1147 |                 if ( node->object ) {
 | 
|---|
 | 1148 |                         os << indent-1 << "... with decl: ";
 | 
|---|
 | 1149 |                         short_print( node->object );
 | 
|---|
 | 1150 |                 }
 | 
|---|
 | 1151 |                 --indent;
 | 
|---|
 | 1152 |                 postprint( node );
 | 
|---|
 | 1153 | 
 | 
|---|
| [461046f] | 1154 |                 return node;
 | 
|---|
 | 1155 |         }
 | 
|---|
 | 1156 | 
 | 
|---|
| [e67991f] | 1157 |         virtual const ast::Expr * visit( const ast::UntypedInitExpr * node ) override final {
 | 
|---|
| [a16e246] | 1158 |                 ++indent;
 | 
|---|
| [94b1f718] | 1159 |                 os << "Untyped Init Expression" << endl << indent;
 | 
|---|
| [a16e246] | 1160 |                 safe_print( node->expr );
 | 
|---|
 | 1161 |                 if ( ! node->initAlts.empty() ) {
 | 
|---|
 | 1162 |                         for ( const InitAlternative & alt : node->initAlts ) {
 | 
|---|
 | 1163 |                                 os << indent <<  "InitAlternative: ";
 | 
|---|
 | 1164 |                                 safe_print( alt.type );
 | 
|---|
 | 1165 |                                 safe_print( alt.designation );
 | 
|---|
 | 1166 |                         }
 | 
|---|
 | 1167 |                 }
 | 
|---|
 | 1168 |                 --indent;
 | 
|---|
 | 1169 | 
 | 
|---|
| [461046f] | 1170 |                 return node;
 | 
|---|
 | 1171 |         }
 | 
|---|
 | 1172 | 
 | 
|---|
| [e67991f] | 1173 |         virtual const ast::Expr * visit( const ast::InitExpr * node ) override final {
 | 
|---|
| [a16e246] | 1174 |                 ++indent;
 | 
|---|
| [94b1f718] | 1175 |                 os << "Init Expression" << endl << indent;
 | 
|---|
| [a16e246] | 1176 |                 safe_print( node->expr );
 | 
|---|
 | 1177 |                 os << indent << "... with designation: ";
 | 
|---|
 | 1178 |                 safe_print( node->designation );
 | 
|---|
 | 1179 |                 --indent;
 | 
|---|
 | 1180 | 
 | 
|---|
| [461046f] | 1181 |                 return node;
 | 
|---|
 | 1182 |         }
 | 
|---|
 | 1183 | 
 | 
|---|
| [e67991f] | 1184 |         virtual const ast::Expr * visit( const ast::DeletedExpr * node ) override final {
 | 
|---|
| [a16e246] | 1185 |                 ++indent;
 | 
|---|
| [94b1f718] | 1186 |                 os << "Deleted Expression" << endl << indent;
 | 
|---|
| [a16e246] | 1187 |                 safe_print( node->expr );
 | 
|---|
| [94b1f718] | 1188 |                 os << endl << indent << "... deleted by: ";
 | 
|---|
| [a16e246] | 1189 |                 safe_print( node->deleteStmt );
 | 
|---|
 | 1190 |                 --indent;
 | 
|---|
 | 1191 | 
 | 
|---|
| [461046f] | 1192 |                 return node;
 | 
|---|
 | 1193 |         }
 | 
|---|
 | 1194 | 
 | 
|---|
| [e67991f] | 1195 |         virtual const ast::Expr * visit( const ast::DefaultArgExpr * node ) override final {
 | 
|---|
| [a16e246] | 1196 |                 ++indent;
 | 
|---|
| [94b1f718] | 1197 |                 os << "Default Argument Expression" << endl << indent;
 | 
|---|
| [a16e246] | 1198 |                 safe_print( node->expr );
 | 
|---|
 | 1199 |                 --indent;
 | 
|---|
 | 1200 | 
 | 
|---|
| [461046f] | 1201 |                 return node;
 | 
|---|
 | 1202 |         }
 | 
|---|
 | 1203 | 
 | 
|---|
| [e67991f] | 1204 |         virtual const ast::Expr * visit( const ast::GenericExpr * node ) override final {
 | 
|---|
| [a16e246] | 1205 |                 ++indent;
 | 
|---|
| [94b1f718] | 1206 |                 os << "C11 _Generic Expression" << endl << indent;
 | 
|---|
| [a16e246] | 1207 |                 safe_print( node->control );
 | 
|---|
| [94b1f718] | 1208 |                 os << endl << indent << "... with associations:" << endl;
 | 
|---|
| [a16e246] | 1209 |                 for ( const auto & assoc : node->associations ) {
 | 
|---|
 | 1210 |                         os << indent;
 | 
|---|
 | 1211 |                         if ( assoc.type ) {
 | 
|---|
 | 1212 |                                 os << "... type: ";
 | 
|---|
 | 1213 |                                 assoc.type->accept( *this );
 | 
|---|
| [94b1f718] | 1214 |                                 os << endl << indent << "... expression: ";
 | 
|---|
| [a16e246] | 1215 |                                 safe_print( assoc.expr );
 | 
|---|
 | 1216 |                         } else {
 | 
|---|
 | 1217 |                                 os << "... default: ";
 | 
|---|
 | 1218 |                                 safe_print( assoc.expr );
 | 
|---|
 | 1219 |                         }
 | 
|---|
| [94b1f718] | 1220 |                         os << endl;
 | 
|---|
| [a16e246] | 1221 |                 }
 | 
|---|
 | 1222 |                 --indent;
 | 
|---|
 | 1223 | 
 | 
|---|
| [461046f] | 1224 |                 return node;
 | 
|---|
 | 1225 |         }
 | 
|---|
 | 1226 | 
 | 
|---|
| [e67991f] | 1227 |         virtual const ast::Type * visit( const ast::VoidType * node ) override final {
 | 
|---|
| [b0ec971] | 1228 |                 preprint( node );
 | 
|---|
 | 1229 |                 os << "void";
 | 
|---|
| [461046f] | 1230 |                 return node;
 | 
|---|
 | 1231 |         }
 | 
|---|
 | 1232 | 
 | 
|---|
| [e67991f] | 1233 |         virtual const ast::Type * visit( const ast::BasicType * node ) override final {
 | 
|---|
| [b0ec971] | 1234 |                 preprint( node );
 | 
|---|
 | 1235 |                 os << ast::BasicType::typeNames[ node->kind ];
 | 
|---|
| [461046f] | 1236 |                 return node;
 | 
|---|
 | 1237 |         }
 | 
|---|
 | 1238 | 
 | 
|---|
| [e67991f] | 1239 |         virtual const ast::Type * visit( const ast::PointerType * node ) override final {
 | 
|---|
| [b0ec971] | 1240 |                 preprint( node );
 | 
|---|
 | 1241 |                 if ( ! node->isArray() ) {
 | 
|---|
 | 1242 |                         os << "pointer to ";
 | 
|---|
 | 1243 |                 } else {
 | 
|---|
 | 1244 |                         os << "decayed ";
 | 
|---|
 | 1245 |                         if ( node->isStatic ) {
 | 
|---|
 | 1246 |                                 os << "static ";
 | 
|---|
 | 1247 |                         }
 | 
|---|
 | 1248 | 
 | 
|---|
 | 1249 |                         if ( node->isVarLen ) {
 | 
|---|
 | 1250 |                                 os << "variable length array of ";
 | 
|---|
 | 1251 |                         } else if ( node->dimension ) {
 | 
|---|
 | 1252 |                                 os << "array of ";
 | 
|---|
 | 1253 |                                 node->dimension->accept( *this );
 | 
|---|
 | 1254 |                                 os << " ";
 | 
|---|
 | 1255 |                         }
 | 
|---|
 | 1256 |                 }
 | 
|---|
| [20a5977] | 1257 |                 safe_print( node->base );
 | 
|---|
| [b0ec971] | 1258 | 
 | 
|---|
| [461046f] | 1259 |                 return node;
 | 
|---|
 | 1260 |         }
 | 
|---|
 | 1261 | 
 | 
|---|
| [e67991f] | 1262 |         virtual const ast::Type * visit( const ast::ArrayType * node ) override final {
 | 
|---|
| [b0ec971] | 1263 |                 preprint( node );
 | 
|---|
 | 1264 |                 if ( node->isStatic ) {
 | 
|---|
 | 1265 |                         os << "static ";
 | 
|---|
 | 1266 |                 }
 | 
|---|
 | 1267 | 
 | 
|---|
 | 1268 |                 if ( node->isVarLen ) {
 | 
|---|
 | 1269 |                         os << "variable length array of ";
 | 
|---|
 | 1270 |                 } else if ( node->dimension ) {
 | 
|---|
 | 1271 |                         os << "array of ";
 | 
|---|
 | 1272 |                 } else {
 | 
|---|
 | 1273 |                         os << "open array of ";
 | 
|---|
 | 1274 |                 }
 | 
|---|
 | 1275 | 
 | 
|---|
| [20a5977] | 1276 |                 safe_print( node->base );
 | 
|---|
| [b0ec971] | 1277 | 
 | 
|---|
 | 1278 |                 if ( node->dimension ) {
 | 
|---|
 | 1279 |                         os << " with dimension of ";
 | 
|---|
 | 1280 |                         node->dimension->accept( *this );
 | 
|---|
 | 1281 |                 }
 | 
|---|
 | 1282 | 
 | 
|---|
| [461046f] | 1283 |                 return node;
 | 
|---|
 | 1284 |         }
 | 
|---|
 | 1285 | 
 | 
|---|
| [e67991f] | 1286 |         virtual const ast::Type * visit( const ast::ReferenceType * node ) override final {
 | 
|---|
| [b0ec971] | 1287 |                 preprint( node );
 | 
|---|
 | 1288 |                 os << "reference to ";
 | 
|---|
| [20a5977] | 1289 |                 safe_print( node->base );
 | 
|---|
| [b0ec971] | 1290 | 
 | 
|---|
| [461046f] | 1291 |                 return node;
 | 
|---|
 | 1292 |         }
 | 
|---|
 | 1293 | 
 | 
|---|
| [e67991f] | 1294 |         virtual const ast::Type * visit( const ast::QualifiedType * node ) override final {
 | 
|---|
| [b0ec971] | 1295 |                 preprint( node );
 | 
|---|
 | 1296 |                 ++indent;
 | 
|---|
| [94b1f718] | 1297 |                 os << "Qualified Type:" << endl << indent;
 | 
|---|
| [20a5977] | 1298 |                 safe_print( node->parent );
 | 
|---|
| [94b1f718] | 1299 |                 os << endl << indent;
 | 
|---|
| [20a5977] | 1300 |                 safe_print( node->child );
 | 
|---|
| [94b1f718] | 1301 |                 os << endl;
 | 
|---|
| [b0ec971] | 1302 |                 --indent;
 | 
|---|
 | 1303 | 
 | 
|---|
| [461046f] | 1304 |                 return node;
 | 
|---|
 | 1305 |         }
 | 
|---|
 | 1306 | 
 | 
|---|
| [e67991f] | 1307 |         virtual const ast::Type * visit( const ast::FunctionType * node ) override final {
 | 
|---|
| [b0ec971] | 1308 |                 preprint( node );
 | 
|---|
| [d908563] | 1309 | 
 | 
|---|
| [94b1f718] | 1310 |                 os << "function" << endl;
 | 
|---|
| [b0ec971] | 1311 |                 if ( ! node->params.empty() ) {
 | 
|---|
| [94b1f718] | 1312 |                         os << indent << "... with parameters" << endl;
 | 
|---|
| [b0ec971] | 1313 |                         ++indent;
 | 
|---|
 | 1314 |                         printAll( node->params );
 | 
|---|
 | 1315 |                         if ( node->isVarArgs ) {
 | 
|---|
| [94b1f718] | 1316 |                                 os << indent << "and a variable number of other arguments" << endl;
 | 
|---|
| [b0ec971] | 1317 |                         }
 | 
|---|
 | 1318 |                         --indent;
 | 
|---|
 | 1319 |                 } else if ( node->isVarArgs ) {
 | 
|---|
| [94b1f718] | 1320 |                         os << indent+1 << "accepting unspecified arguments" << endl;
 | 
|---|
| [b0ec971] | 1321 |                 }
 | 
|---|
 | 1322 | 
 | 
|---|
 | 1323 |                 os << indent << "... returning";
 | 
|---|
 | 1324 |                 if ( node->returns.empty() ) {
 | 
|---|
| [94b1f718] | 1325 |                         os << " nothing" << endl;
 | 
|---|
| [b0ec971] | 1326 |                 } else {
 | 
|---|
| [94b1f718] | 1327 |                         os << endl;
 | 
|---|
| [b0ec971] | 1328 |                         ++indent;
 | 
|---|
 | 1329 |                         printAll( node->returns );
 | 
|---|
 | 1330 |                         --indent;
 | 
|---|
 | 1331 |                 }
 | 
|---|
 | 1332 | 
 | 
|---|
| [461046f] | 1333 |                 return node;
 | 
|---|
 | 1334 |         }
 | 
|---|
 | 1335 | 
 | 
|---|
| [e67991f] | 1336 |         virtual const ast::Type * visit( const ast::StructInstType * node ) override final {
 | 
|---|
| [b0ec971] | 1337 |                 preprint( node );
 | 
|---|
 | 1338 |                 os << "instance of struct " << node->name;
 | 
|---|
 | 1339 |                 if ( node->base ) {
 | 
|---|
 | 1340 |                         os << " " << ( node->base->body ? "with" : "without" ) << " body";
 | 
|---|
 | 1341 |                 }
 | 
|---|
 | 1342 |                 print( node->params );
 | 
|---|
 | 1343 | 
 | 
|---|
| [461046f] | 1344 |                 return node;
 | 
|---|
 | 1345 |         }
 | 
|---|
 | 1346 | 
 | 
|---|
| [e67991f] | 1347 |         virtual const ast::Type * visit( const ast::UnionInstType * node ) override final {
 | 
|---|
| [b0ec971] | 1348 |                 preprint( node );
 | 
|---|
 | 1349 |                 os << "instance of union " << node->name;
 | 
|---|
 | 1350 |                 if ( node->base ) {
 | 
|---|
 | 1351 |                         os << " " << ( node->base->body ? "with" : "without" ) << " body";
 | 
|---|
 | 1352 |                 }
 | 
|---|
 | 1353 |                 print( node->params );
 | 
|---|
 | 1354 | 
 | 
|---|
| [461046f] | 1355 |                 return node;
 | 
|---|
 | 1356 |         }
 | 
|---|
 | 1357 | 
 | 
|---|
| [e67991f] | 1358 |         virtual const ast::Type * visit( const ast::EnumInstType * node ) override final {
 | 
|---|
| [b0ec971] | 1359 |                 preprint( node );
 | 
|---|
 | 1360 |                 os << "instance of enum " << node->name;
 | 
|---|
 | 1361 |                 if ( node->base ) {
 | 
|---|
 | 1362 |                         os << " " << ( node->base->body ? "with" : "without" ) << " body";
 | 
|---|
 | 1363 |                 }
 | 
|---|
 | 1364 |                 print( node->params );
 | 
|---|
 | 1365 | 
 | 
|---|
| [461046f] | 1366 |                 return node;
 | 
|---|
 | 1367 |         }
 | 
|---|
 | 1368 | 
 | 
|---|
| [e67991f] | 1369 |         virtual const ast::Type * visit( const ast::TraitInstType * node ) override final {
 | 
|---|
| [b0ec971] | 1370 |                 preprint( node );
 | 
|---|
 | 1371 |                 os << "instance of trait " << node->name;
 | 
|---|
 | 1372 |                 print( node->params );
 | 
|---|
 | 1373 | 
 | 
|---|
| [461046f] | 1374 |                 return node;
 | 
|---|
 | 1375 |         }
 | 
|---|
 | 1376 | 
 | 
|---|
| [e67991f] | 1377 |         virtual const ast::Type * visit( const ast::TypeInstType * node ) override final {
 | 
|---|
| [b0ec971] | 1378 |                 preprint( node );
 | 
|---|
| [d908563] | 1379 |                 os << "instance of type " << node->name
 | 
|---|
| [07de76b] | 1380 |                    << " (" << (node->kind == ast::TypeDecl::Ftype ? "" : "not ") << "function type)";
 | 
|---|
| [b0ec971] | 1381 |                 print( node->params );
 | 
|---|
 | 1382 | 
 | 
|---|
| [461046f] | 1383 |                 return node;
 | 
|---|
 | 1384 |         }
 | 
|---|
 | 1385 | 
 | 
|---|
| [e67991f] | 1386 |         virtual const ast::Type * visit( const ast::TupleType * node ) override final {
 | 
|---|
| [b0ec971] | 1387 |                 preprint( node );
 | 
|---|
| [94b1f718] | 1388 |                 os << "tuple of types" << endl;
 | 
|---|
| [b0ec971] | 1389 |                 ++indent;
 | 
|---|
 | 1390 |                 printAll( node->types );
 | 
|---|
 | 1391 |                 --indent;
 | 
|---|
 | 1392 | 
 | 
|---|
| [461046f] | 1393 |                 return node;
 | 
|---|
 | 1394 |         }
 | 
|---|
 | 1395 | 
 | 
|---|
| [e67991f] | 1396 |         virtual const ast::Type * visit( const ast::TypeofType * node ) override final {
 | 
|---|
| [b0ec971] | 1397 |                 preprint( node );
 | 
|---|
 | 1398 |                 if ( node->kind == ast::TypeofType::Basetypeof ) { os << "base-"; }
 | 
|---|
 | 1399 |                 os << "type-of expression ";
 | 
|---|
| [20a5977] | 1400 |                 safe_print( node->expr );
 | 
|---|
| [b0ec971] | 1401 | 
 | 
|---|
| [461046f] | 1402 |                 return node;
 | 
|---|
 | 1403 |         }
 | 
|---|
 | 1404 | 
 | 
|---|
| [e67991f] | 1405 |         virtual const ast::Type * visit( const ast::VarArgsType * node ) override final {
 | 
|---|
| [b0ec971] | 1406 |                 preprint( node );
 | 
|---|
 | 1407 |                 os << "builtin var args pack";
 | 
|---|
| [461046f] | 1408 |                 return node;
 | 
|---|
 | 1409 |         }
 | 
|---|
 | 1410 | 
 | 
|---|
| [e67991f] | 1411 |         virtual const ast::Type * visit( const ast::ZeroType * node ) override final {
 | 
|---|
| [b0ec971] | 1412 |                 preprint( node );
 | 
|---|
 | 1413 |                 os << "zero_t";
 | 
|---|
| [461046f] | 1414 |                 return node;
 | 
|---|
 | 1415 |         }
 | 
|---|
 | 1416 | 
 | 
|---|
| [e67991f] | 1417 |         virtual const ast::Type * visit( const ast::OneType * node ) override final {
 | 
|---|
| [b0ec971] | 1418 |                 preprint( node );
 | 
|---|
 | 1419 |                 os << "one_t";
 | 
|---|
| [461046f] | 1420 |                 return node;
 | 
|---|
 | 1421 |         }
 | 
|---|
 | 1422 | 
 | 
|---|
| [e67991f] | 1423 |         virtual const ast::Type * visit( const ast::GlobalScopeType * node ) override final {
 | 
|---|
| [b0ec971] | 1424 |                 preprint( node );
 | 
|---|
 | 1425 |                 os << "Global Scope Type";
 | 
|---|
| [461046f] | 1426 |                 return node;
 | 
|---|
 | 1427 |         }
 | 
|---|
 | 1428 | 
 | 
|---|
| [e67991f] | 1429 |         virtual const ast::Designation * visit( const ast::Designation * node ) override final {
 | 
|---|
| [c957e7f] | 1430 |                 if ( node->designators.empty() ) return node;
 | 
|---|
| [94b1f718] | 1431 |                 os << "... designated by: " << endl;
 | 
|---|
| [c957e7f] | 1432 |                 ++indent;
 | 
|---|
 | 1433 |                 for ( const ast::Expr * d : node->designators ) {
 | 
|---|
 | 1434 |                         os << indent;
 | 
|---|
 | 1435 |                         d->accept( *this );
 | 
|---|
| [94b1f718] | 1436 |                         os << endl;
 | 
|---|
| [c957e7f] | 1437 |                 }
 | 
|---|
 | 1438 |                 --indent;
 | 
|---|
| [461046f] | 1439 |                 return node;
 | 
|---|
 | 1440 |         }
 | 
|---|
 | 1441 | 
 | 
|---|
| [e67991f] | 1442 |         virtual const ast::Init * visit( const ast::SingleInit * node ) override final {
 | 
|---|
| [c957e7f] | 1443 |                 os << "Simple Initializer: ";
 | 
|---|
| [20a5977] | 1444 |                 safe_print( node->value );
 | 
|---|
| [461046f] | 1445 |                 return node;
 | 
|---|
 | 1446 |         }
 | 
|---|
 | 1447 | 
 | 
|---|
| [e67991f] | 1448 |         virtual const ast::Init * visit( const ast::ListInit * node ) override final {
 | 
|---|
| [94b1f718] | 1449 |                 os << "Compound initializer: " << endl;
 | 
|---|
| [c957e7f] | 1450 |                 ++indent;
 | 
|---|
 | 1451 |                 for ( auto p : group_iterate( node->designations, node->initializers ) ) {
 | 
|---|
 | 1452 |                         const ast::Designation * d = std::get<0>(p);
 | 
|---|
 | 1453 |                         const ast::Init * init = std::get<1>(p);
 | 
|---|
 | 1454 |                         os << indent;
 | 
|---|
 | 1455 |                         init->accept( *this );
 | 
|---|
| [94b1f718] | 1456 |                         os << endl;
 | 
|---|
| [c957e7f] | 1457 |                         if ( ! d->designators.empty() ) {
 | 
|---|
 | 1458 |                                 os << indent;
 | 
|---|
 | 1459 |                                 d->accept( *this );
 | 
|---|
 | 1460 |                         }
 | 
|---|
 | 1461 |                 }
 | 
|---|
 | 1462 |                 --indent;
 | 
|---|
| [461046f] | 1463 |                 return node;
 | 
|---|
 | 1464 |         }
 | 
|---|
 | 1465 | 
 | 
|---|
| [e67991f] | 1466 |         virtual const ast::Init * visit( const ast::ConstructorInit * node ) override final {
 | 
|---|
| [94b1f718] | 1467 |                 os << "Constructor initializer: " << endl;
 | 
|---|
| [c957e7f] | 1468 |                 if ( node->ctor ) {
 | 
|---|
 | 1469 |                         os << indent << "... initially constructed with ";
 | 
|---|
 | 1470 |                         ++indent;
 | 
|---|
 | 1471 |                         node->ctor->accept( *this );
 | 
|---|
 | 1472 |                         --indent;
 | 
|---|
 | 1473 |                 }
 | 
|---|
 | 1474 | 
 | 
|---|
 | 1475 |                 if ( node->dtor ) {
 | 
|---|
 | 1476 |                         os << indent << "... destructed with ";
 | 
|---|
 | 1477 |                         ++indent;
 | 
|---|
 | 1478 |                         node->dtor->accept( *this );
 | 
|---|
 | 1479 |                         --indent;
 | 
|---|
 | 1480 |                 }
 | 
|---|
 | 1481 | 
 | 
|---|
 | 1482 |                 if ( node->init ) {
 | 
|---|
 | 1483 |                         os << indent << "... with fallback C-style initializer: ";
 | 
|---|
 | 1484 |                         ++indent;
 | 
|---|
 | 1485 |                         node->init->accept( *this );
 | 
|---|
 | 1486 |                         --indent;
 | 
|---|
 | 1487 |                 }
 | 
|---|
| [461046f] | 1488 |                 return node;
 | 
|---|
 | 1489 |         }
 | 
|---|
 | 1490 | 
 | 
|---|
| [e67991f] | 1491 |         virtual const ast::Attribute * visit( const ast::Attribute * node ) override final {
 | 
|---|
| [489bacf] | 1492 |                 if ( node->empty() ) return node;
 | 
|---|
 | 1493 |                 os << "Attribute with name: " << node->name;
 | 
|---|
 | 1494 |                 if ( node->params.empty() ) return node;
 | 
|---|
| [94b1f718] | 1495 |                 os << " with parameters: " << endl;
 | 
|---|
| [489bacf] | 1496 |                 ++indent;
 | 
|---|
 | 1497 |                 printAll( node->params );
 | 
|---|
 | 1498 |                 --indent;
 | 
|---|
| [461046f] | 1499 |                 return node;
 | 
|---|
 | 1500 |         }
 | 
|---|
 | 1501 | 
 | 
|---|
| [e67991f] | 1502 |         virtual const ast::TypeSubstitution * visit( const ast::TypeSubstitution * node ) override final {
 | 
|---|
| [94b1f718] | 1503 |                 os << indent << "Types:" << endl;
 | 
|---|
| [76ed81f] | 1504 |                 for ( const auto& i : *node ) {
 | 
|---|
 | 1505 |                         os << indent+1 << i.first << " -> ";
 | 
|---|
 | 1506 |                         indent += 2;
 | 
|---|
| [20a5977] | 1507 |                         safe_print( i.second );
 | 
|---|
| [76ed81f] | 1508 |                         indent -= 2;
 | 
|---|
| [94b1f718] | 1509 |                         os << endl;
 | 
|---|
| [76ed81f] | 1510 |                 }
 | 
|---|
| [94b1f718] | 1511 |                 os << indent << "Non-types:" << endl;
 | 
|---|
| [76ed81f] | 1512 |                 for ( auto i = node->beginVar(); i != node->endVar(); ++i ) {
 | 
|---|
 | 1513 |                         os << indent+1 << i->first << " -> ";
 | 
|---|
 | 1514 |                         indent += 2;
 | 
|---|
| [20a5977] | 1515 |                         safe_print( i->second );
 | 
|---|
| [76ed81f] | 1516 |                         indent -= 2;
 | 
|---|
| [94b1f718] | 1517 |                         os << endl;
 | 
|---|
| [76ed81f] | 1518 |                 }
 | 
|---|
| [461046f] | 1519 |                 return node;
 | 
|---|
 | 1520 |         }
 | 
|---|
 | 1521 | 
 | 
|---|
 | 1522 | };
 | 
|---|
 | 1523 | 
 | 
|---|
| [5902625] | 1524 | void print( ostream & os, const ast::Node * node, Indenter indent ) {
 | 
|---|
 | 1525 |         Printer printer { os, indent, false };
 | 
|---|
 | 1526 |         node->accept(printer);
 | 
|---|
 | 1527 | }
 | 
|---|
 | 1528 | 
 | 
|---|
| [6f4b7f2] | 1529 | void printShort( ostream & os, const ast::Decl * node, Indenter indent ) {
 | 
|---|
| [5902625] | 1530 |         Printer printer { os, indent, true };
 | 
|---|
| [461046f] | 1531 |         node->accept(printer);
 | 
|---|
 | 1532 | }
 | 
|---|
 | 1533 | 
 | 
|---|
 | 1534 | // Annoyingly these needed to be defined out of line to avoid undefined references.
 | 
|---|
 | 1535 | // The size here needs to be explicit but at least the compiler will produce an error
 | 
|---|
 | 1536 | // if the wrong size is specified
 | 
|---|
| [5902625] | 1537 | constexpr array<const char*, 3> Printer::Names::FuncSpecifiers;
 | 
|---|
 | 1538 | constexpr array<const char*, 5> Printer::Names::StorageClasses;
 | 
|---|
 | 1539 | constexpr array<const char*, 6> Printer::Names::Qualifiers;
 | 
|---|
| [461046f] | 1540 | }
 | 
|---|