source: src/AST/Print.cpp @ fa2c005

ADT
Last change on this file since fa2c005 was fa2c005, checked in by JiadaL <j82liang@…>, 12 months ago

Finish Adt POC

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