source: src/main.cc @ 79eaeb7

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprpersistent-indexerpthread-emulationqualifiedEnum
Last change on this file since 79eaeb7 was 79eaeb7, checked in by tdelisle <tdelisle@…>, 5 years ago

Improved printing, parent printing still incorrect

  • Property mode set to 100644
File size: 20.6 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// main.cc --
8//
9// Author           : Richard C. Bilson
10// Created On       : Fri May 15 23:12:02 2015
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Sat Feb 16 09:14:04 2019
13// Update Count     : 500
14//
15
16#include <cxxabi.h>                         // for __cxa_demangle
17#include <execinfo.h>                       // for backtrace, backtrace_symbols
18#include <getopt.h>                         // for no_argument, optind, geto...
19#include <signal.h>                         // for signal, SIGABRT, SIGSEGV
20#include <cassert>                          // for assertf
21#include <cstdio>                           // for fopen, FILE, fclose, stdin
22#include <cstdlib>                          // for exit, free, abort, EXIT_F...
23#include <cstring>                          // for index
24#include <fstream>                          // for ofstream
25#include <iostream>                         // for operator<<, basic_ostream
26#include <iterator>                         // for back_inserter
27#include <list>                             // for list
28#include <string>                           // for char_traits, operator<<
29
30#include "CompilationState.h"
31#include "../config.h"                      // for CFA_LIBDIR
32#include "CodeGen/FixMain.h"                // for FixMain
33#include "CodeGen/FixNames.h"               // for fixNames
34#include "CodeGen/Generate.h"               // for generate
35#include "CodeTools/DeclStats.h"            // for printDeclStats
36#include "CodeTools/ResolvProtoDump.h"      // for dumpAsResolvProto
37#include "CodeTools/TrackLoc.h"             // for fillLocations
38#include "Common/CompilerError.h"           // for CompilerError
39#include "Common/Stats.h"
40#include "Common/PassVisitor.h"
41#include "Common/SemanticError.h"           // for SemanticError
42#include "Common/UnimplementedError.h"      // for UnimplementedError
43#include "Common/utility.h"                 // for deleteAll, filter, printAll
44#include "Concurrency/Waitfor.h"            // for generateWaitfor
45#include "ControlStruct/ExceptTranslate.h"  // for translateEHM
46#include "ControlStruct/Mutate.h"           // for mutate
47#include "GenPoly/Box.h"                    // for box
48#include "GenPoly/InstantiateGeneric.h"     // for instantiateGeneric
49#include "GenPoly/Lvalue.h"                 // for convertLvalue
50#include "GenPoly/Specialize.h"             // for convertSpecializations
51#include "InitTweak/FixInit.h"              // for fix
52#include "InitTweak/GenInit.h"              // for genInit
53#include "MakeLibCfa.h"                     // for makeLibCfa
54#include "Parser/LinkageSpec.h"             // for Spec, Cforall, Intrinsic
55#include "Parser/ParseNode.h"               // for DeclarationNode, buildList
56#include "Parser/TypedefTable.h"            // for TypedefTable
57#include "ResolvExpr/AlternativePrinter.h"  // for AlternativePrinter
58#include "ResolvExpr/Resolver.h"            // for resolve
59#include "SymTab/Validate.h"                // for validate
60#include "SynTree/Declaration.h"            // for Declaration
61#include "SynTree/Visitor.h"                // for acceptAll
62#include "Tuples/Tuples.h"                  // for expandMemberTuples, expan...
63#include "Virtual/ExpandCasts.h"            // for expandCasts
64
65using namespace std;
66
67
68void NewPass(const char * const name) {
69        Stats::Heap::newPass(name);
70        using namespace Stats::Counters;
71        static auto pass_visitor_group = build<CounterGroup>("Pass Visitor");
72        auto pass = build<CounterGroup>(name, pass_visitor_group);
73        pass_visitor_stats.depth = 0;
74        pass_visitor_stats.avg = build<AverageCounter<double>>("Average Depth", pass);
75        pass_visitor_stats.max = build<MaxCounter<double>>("Max Depth", pass);
76}
77
78#define PASS(name, pass)                  \
79        if ( errorp ) { cerr << name << endl; } \
80        NewPass(name);                          \
81        Stats::Time::StartBlock(name);          \
82        pass;                                   \
83        Stats::Time::StopBlock();
84
85LinkageSpec::Spec linkage = LinkageSpec::Cforall;
86TypedefTable typedefTable;
87DeclarationNode * parseTree = nullptr;                                  // program parse tree
88
89std::string PreludeDirector = "";
90
91static void parse_cmdline( int argc, char *argv[], const char *& filename );
92static void parse( FILE * input, LinkageSpec::Spec linkage, bool shouldExit = false );
93static void dump( list< Declaration * > & translationUnit, ostream & out = cout );
94
95static void backtrace( int start ) {                                    // skip first N stack frames
96        enum { Frames = 50 };
97        void * array[Frames];
98        int size = ::backtrace( array, Frames );
99        char ** messages = ::backtrace_symbols( array, size ); // does not demangle names
100
101        *index( messages[0], '(' ) = '\0';                                      // find executable name
102        cerr << "Stack back trace for: " << messages[0] << endl;
103
104        // skip last 2 stack frames after main
105        for ( int i = start; i < size - 2 && messages != nullptr; i += 1 ) {
106                char * mangled_name = nullptr, * offset_begin = nullptr, * offset_end = nullptr;
107                for ( char *p = messages[i]; *p; ++p ) {        // find parantheses and +offset
108                        if ( *p == '(' ) {
109                                mangled_name = p;
110                        } else if ( *p == '+' ) {
111                                offset_begin = p;
112                        } else if ( *p == ')' ) {
113                                offset_end = p;
114                                break;
115                        } // if
116                } // for
117
118                // if line contains symbol, attempt to demangle
119                int frameNo = i - start;
120                if ( mangled_name && offset_begin && offset_end && mangled_name < offset_begin ) {
121                        *mangled_name++ = '\0';                                         // delimit strings
122                        *offset_begin++ = '\0';
123                        *offset_end++ = '\0';
124
125                        int status;
126                        char * real_name = __cxxabiv1::__cxa_demangle( mangled_name, 0, 0, &status );
127                        // bug in __cxa_demangle for single-character lower-case non-mangled names
128                        if ( status == 0 ) {                                            // demangling successful ?
129                                cerr << "(" << frameNo << ") " << messages[i] << " : "
130                                         << real_name << "+" << offset_begin << offset_end << endl;
131                        } else {                                                                        // otherwise, output mangled name
132                                cerr << "(" << frameNo << ") " << messages[i] << " : "
133                                         << mangled_name << "(/*unknown*/)+" << offset_begin << offset_end << endl;
134                        } // if
135
136                        free( real_name );
137                } else {                                                                                // otherwise, print the whole line
138                        cerr << "(" << frameNo << ") " << messages[i] << endl;
139                } // if
140        } // for
141
142        free( messages );
143} // backtrace
144
145void sigSegvBusHandler( int sig_num ) {
146        cerr << "*CFA runtime error* program cfa-cpp terminated with "
147                 <<     (sig_num == SIGSEGV ? "segment fault" : "bus error")
148                 << "." << endl;
149        backtrace( 2 );                                                                         // skip first 2 stack frames
150        //_exit( EXIT_FAILURE );
151        abort();
152} // sigSegvBusHandler
153
154void sigAbortHandler( __attribute__((unused)) int sig_num ) {
155        backtrace( 6 );                                                                         // skip first 6 stack frames
156        signal( SIGABRT, SIG_DFL);                                                      // reset default signal handler
157                raise( SIGABRT );                                                                       // reraise SIGABRT
158} // sigAbortHandler
159
160
161int main( int argc, char * argv[] ) {
162        FILE * input;                                                                           // use FILE rather than istream because yyin is FILE
163        ostream * output = & cout;
164        const char * filename = nullptr;
165        list< Declaration * > translationUnit;
166
167        signal( SIGSEGV, sigSegvBusHandler );
168        signal( SIGBUS, sigSegvBusHandler );
169        signal( SIGABRT, sigAbortHandler );
170
171        // std::cout << "main" << std::endl;
172        // for ( int i = 0; i < argc; i += 1 ) {
173        //      std::cout << '\t' << argv[i] << std::endl;
174        // } // for
175
176        parse_cmdline( argc, argv, filename );                          // process command-line arguments
177        CodeGen::FixMain::setReplaceMain( !nomainp );
178
179        try {
180                // choose to read the program from a file or stdin
181                if ( optind < argc ) {                                                  // any commands after the flags ? => input file name
182                        input = fopen( argv[ optind ], "r" );
183                        assertf( input, "cannot open %s\n", argv[ optind ] );
184                        // if running cfa-cpp directly, might forget to pass -F option (and really shouldn't have to)
185                        if ( filename == nullptr ) filename = argv[ optind ];
186                        // prelude filename comes in differently
187                        if ( libcfap ) filename = "prelude.cfa";
188                        optind += 1;
189                } else {                                                                                // no input file name
190                        input = stdin;
191                        // if running cfa-cpp directly, might forget to pass -F option. Since this takes from stdin, pass
192                        // a fake name along
193                        if ( filename == nullptr ) filename = "stdin";
194                } // if
195
196                NewPass("Parse");
197                Stats::Time::StartGlobal();
198
199                // read in the builtins, extras, and the prelude
200                if ( ! nopreludep ) {                                                   // include gcc builtins
201                        // -l is for initial build ONLY and builtins.cf is not in the lib directory so access it here.
202
203                        assertf( !PreludeDirector.empty(), "Can't find prelude without option --prelude-dir must be used." );
204
205                        // Read to gcc builtins, if not generating the cfa library
206                        FILE * gcc_builtins = fopen( (PreludeDirector + "/gcc-builtins.cf").c_str(), "r" );
207                        assertf( gcc_builtins, "cannot open gcc-builtins.cf\n" );
208                        parse( gcc_builtins, LinkageSpec::Compiler );
209
210                        // read the extra prelude in, if not generating the cfa library
211                        FILE * extras = fopen( (PreludeDirector + "/extras.cf").c_str(), "r" );
212                        assertf( extras, "cannot open extras.cf\n" );
213                        parse( extras, LinkageSpec::BuiltinC );
214
215                        if ( ! libcfap ) {
216                                // read the prelude in, if not generating the cfa library
217                                FILE * prelude = fopen( (PreludeDirector + "/prelude.cfa").c_str(), "r" );
218                                assertf( prelude, "cannot open prelude.cfa\n" );
219                                parse( prelude, LinkageSpec::Intrinsic );
220
221                                // Read to cfa builtins, if not generating the cfa library
222                                FILE * builtins = fopen( (PreludeDirector + "/builtins.cf").c_str(), "r" );
223                                assertf( builtins, "cannot open builtins.cf\n" );
224                                parse( builtins, LinkageSpec::BuiltinCFA );
225                        } // if
226                } // if
227
228                parse( input, libcfap ? LinkageSpec::Intrinsic : LinkageSpec::Cforall, yydebug );
229
230                if ( parsep ) {
231                        parseTree->printList( cout );
232                        delete parseTree;
233                        return 0;
234                } // if
235
236                buildList( parseTree, translationUnit );
237                delete parseTree;
238                parseTree = nullptr;
239
240                if ( astp ) {
241                        dump( translationUnit );
242                        return 0;
243                } // if
244
245                // Temporary: fill locations after parsing so that every node has a location, for early error messages.
246                // Eventually we should pass the locations from the parser to every node, but this quick and dirty solution
247                // works okay for now.
248                CodeTools::fillLocations( translationUnit );
249
250                // add the assignment statement after the initialization of a type parameter
251                PASS( "Validate", SymTab::validate( translationUnit, symtabp ) );
252                if ( symtabp ) {
253                        deleteAll( translationUnit );
254                        return 0;
255                } // if
256
257                if ( expraltp ) {
258                        PassVisitor<ResolvExpr::AlternativePrinter> printer( cout );
259                        acceptAll( translationUnit, printer );
260                        return 0;
261                } // if
262
263                if ( validp ) {
264                        dump( translationUnit );
265                        return 0;
266                } // if
267
268                PASS( "Fix Labels", ControlStruct::fixLabels( translationUnit ) );
269                PASS( "Fix Names", CodeGen::fixNames( translationUnit ) );
270                PASS( "Gen Init", InitTweak::genInit( translationUnit ) );
271                PASS( "Expand Member Tuples" , Tuples::expandMemberTuples( translationUnit ) );
272                if ( libcfap ) {
273                        // generate the bodies of cfa library functions
274                        LibCfa::makeLibCfa( translationUnit );
275                } // if
276
277                if ( declstatsp ) {
278                        CodeTools::printDeclStats( translationUnit );
279                        deleteAll( translationUnit );
280                        return 0;
281                }
282
283                if ( bresolvep ) {
284                        dump( translationUnit );
285                        return 0;
286                } // if
287
288                CodeTools::fillLocations( translationUnit );
289
290                if ( resolvprotop ) {
291                        CodeTools::dumpAsResolvProto( translationUnit );
292                        return 0;
293                }
294
295                PASS( "Resolve", ResolvExpr::resolve( translationUnit ) );
296                if ( exprp ) {
297                        dump( translationUnit );
298                        return 0;
299                } // if
300
301                // fix ObjectDecl - replaces ConstructorInit nodes
302                PASS( "Fix Init", InitTweak::fix( translationUnit, buildingLibrary() ) );
303                if ( ctorinitp ) {
304                        dump ( translationUnit );
305                        return 0;
306                } // if
307
308                PASS( "Expand Unique Expr", Tuples::expandUniqueExpr( translationUnit ) ); // xxx - is this the right place for this? want to expand ASAP so tha, sequent passes don't need to worry about double-visiting a unique expr - needs to go after InitTweak::fix so that copy constructed return declarations are reused
309
310                PASS( "Translate EHM" , ControlStruct::translateEHM( translationUnit ) );
311
312                PASS( "Gen Waitfor" , Concurrency::generateWaitFor( translationUnit ) );
313
314                PASS( "Convert Specializations",  GenPoly::convertSpecializations( translationUnit ) ); // needs to happen before tuple types are expanded
315
316                PASS( "Expand Tuples", Tuples::expandTuples( translationUnit ) ); // xxx - is this the right place for this?
317
318                if ( tuplep ) {
319                        dump( translationUnit );
320                        return 0;
321                }
322
323                PASS( "Virtual Expand Casts", Virtual::expandCasts( translationUnit ) ); // Must come after translateEHM
324
325                PASS( "Instantiate Generics", GenPoly::instantiateGeneric( translationUnit ) );
326                if ( genericsp ) {
327                        dump( translationUnit );
328                        return 0;
329                }
330                PASS( "Convert L-Value", GenPoly::convertLvalue( translationUnit ) );
331
332
333                if ( bboxp ) {
334                        dump( translationUnit );
335                        return 0;
336                } // if
337                PASS( "Box", GenPoly::box( translationUnit ) );
338
339                if ( bcodegenp ) {
340                        dump( translationUnit );
341                        return 0;
342                }
343
344                if ( optind < argc ) {                                                  // any commands after the flags and input file ? => output file name
345                        output = new ofstream( argv[ optind ] );
346                } // if
347
348                CodeTools::fillLocations( translationUnit );
349                PASS( "Code Gen", CodeGen::generate( translationUnit, *output, ! noprotop, prettycodegenp, true, linemarks ) );
350
351                CodeGen::FixMain::fix( *output, (PreludeDirector + "/bootloader.c").c_str() );
352                if ( output != &cout ) {
353                        delete output;
354                } // if
355        } catch ( SemanticErrorException &e ) {
356                if ( errorp ) {
357                        cerr << "---AST at error:---" << endl;
358                        dump( translationUnit, cerr );
359                        cerr << endl << "---End of AST, begin error message:---\n" << endl;
360                } // if
361                e.print();
362                if ( output != &cout ) {
363                        delete output;
364                } // if
365                return 1;
366        } catch ( UnimplementedError &e ) {
367                cout << "Sorry, " << e.get_what() << " is not currently implemented" << endl;
368                if ( output != &cout ) {
369                        delete output;
370                } // if
371                return 1;
372        } catch ( CompilerError &e ) {
373                cerr << "Compiler Error: " << e.get_what() << endl;
374                cerr << "(please report bugs to [REDACTED])" << endl;
375                if ( output != &cout ) {
376                        delete output;
377                } // if
378                return 1;
379        } catch(...) {
380                std::exception_ptr eptr = std::current_exception();
381                try {
382                        if (eptr) {
383                                std::rethrow_exception(eptr);
384                        }
385                        else {
386                                std::cerr << "Exception Uncaught and Unkown" << std::endl;
387                        }
388                } catch(const std::exception& e) {
389                        std::cerr << "Uncaught Exception \"" << e.what() << "\"\n";
390                }
391                return 1;
392        }// try
393
394        deleteAll( translationUnit );
395        Stats::print();
396
397        return 0;
398} // main
399
400void parse_cmdline( int argc, char * argv[], const char *& filename ) {
401        enum { Ast, Bbox, Bresolver, CtorInitFix, DeclStats, Expr, ExprAlt, Grammar, LibCFA, Linemarks, Nolinemarks, Nopreamble, Parse, PreludeDir, Prototypes, Resolver, ResolvProto, Stats, Symbol, Tree, TupleExpansion, Validate};
402
403        static struct option long_opts[] = {
404                { "ast", no_argument, 0, Ast },
405                { "before-box", no_argument, 0, Bbox },
406                { "before-resolver", no_argument, 0, Bresolver },
407                { "ctorinitfix", no_argument, 0, CtorInitFix },
408                { "decl-stats", no_argument, 0, DeclStats },
409                { "expr", no_argument, 0, Expr },
410                { "expralt", no_argument, 0, ExprAlt },
411                { "grammar", no_argument, 0, Grammar },
412                { "libcfa", no_argument, 0, LibCFA },
413                { "line-marks", no_argument, 0, Linemarks },
414                { "no-line-marks", no_argument, 0, Nolinemarks },
415                { "no-preamble", no_argument, 0, Nopreamble },
416                { "parse", no_argument, 0, Parse },
417                { "prelude-dir", required_argument, 0, PreludeDir },
418                { "no-prototypes", no_argument, 0, Prototypes },
419                { "resolver", no_argument, 0, Resolver },
420                { "resolv-proto", no_argument, 0, ResolvProto },
421                { "stats", required_argument, 0, Stats },
422                { "symbol", no_argument, 0, Symbol },
423                { "tree", no_argument, 0, Tree },
424                { "tuple-expansion", no_argument, 0, TupleExpansion },
425                { "validate", no_argument, 0, Validate },
426                { 0, 0, 0, 0 }
427        }; // long_opts
428        int long_index;
429
430        opterr = 0;                                                                                     // (global) prevent getopt from printing error messages
431
432        bool Wsuppress = false, Werror = false;
433        int c;
434        while ( (c = getopt_long( argc, argv, "abBcCdefgGlLmnNpqrRstTvwW:yzZD:F:", long_opts, &long_index )) != -1 ) {
435                switch ( c ) {
436                        case Ast:
437                        case 'a':                                                                               // dump AST
438                        astp = true;
439                        break;
440                        case Bresolver:
441                        case 'b':                                                                               // print before resolver steps
442                        bresolvep = true;
443                        break;
444                        case 'B':                                                                               // print before box steps
445                        bboxp = true;
446                        break;
447                        case CtorInitFix:
448                        case 'c':                                                                               // print after constructors and destructors are replaced
449                        ctorinitp = true;
450                        break;
451                        case 'C':                                                                               // print before code generation
452                        bcodegenp = true;
453                        break;
454                        case DeclStats:
455                        case 'd':
456                                declstatsp = true;
457                        break;
458                        case Expr:
459                        case 'e':                                                                               // dump AST after expression analysis
460                        exprp = true;
461                        break;
462                        case ExprAlt:
463                        case 'f':                                                                               // print alternatives for expressions
464                        expraltp = true;
465                        break;
466                        case Grammar:
467                        case 'g':                                                                               // bison debugging info (grammar rules)
468                        yydebug = true;
469                        break;
470                        case 'G':                                                                               // dump AST after instantiate generics
471                        genericsp = true;
472                        break;
473                        case LibCFA:
474                        case 'l':                                                                               // generate libcfa.c
475                        libcfap = true;
476                        break;
477                        case Linemarks:
478                        case 'L':                                                                               // print lines marks
479                        linemarks = true;
480                        break;
481                        case Nopreamble:
482                        case 'n':                                                                               // do not read preamble
483                        nopreludep = true;
484                        break;
485                        case Nolinemarks:
486                        case 'N':                                                                               // suppress line marks
487                        linemarks = false;
488                        break;
489                        case Prototypes:
490                        case 'p':                                                                               // generate prototypes for preamble functions
491                        noprotop = true;
492                        break;
493                        case PreludeDir:
494                                PreludeDirector = optarg;
495                        break;
496                        case 'm':                                                                               // don't replace the main
497                                nomainp = true;
498                        break;
499                        case Parse:
500                        case 'q':                                                                               // dump parse tree
501                        parsep = true;
502                        break;
503                        case Resolver:
504                        case 'r':                                                                               // print resolver steps
505                        resolvep = true;
506                        break;
507                        case 'R':                                                                               // dump resolv-proto instance
508                        resolvprotop = true;
509                        break;
510                        case Stats:
511                                Stats::parse_params(optarg);
512                        break;
513                        case Symbol:
514                        case 's':                                                                               // print symbol table events
515                        symtabp = true;
516                        break;
517                        case Tree:
518                        case 't':                                                                               // build in tree
519                        treep = true;
520                        break;
521                        case TupleExpansion:
522                        case 'T':                                                                               // print after tuple expansion
523                        tuplep = true;
524                        break;
525                        case 'v':                                                                               // dump AST after decl validation pass
526                        validp = true;
527                        break;
528                        case 'w':
529                        Wsuppress = true;
530                        break;
531                        case 'W':
532                        if ( strcmp( optarg, "all" ) == 0 ) {
533                                SemanticWarning_EnableAll();
534                        } else if ( strcmp( optarg, "error" ) == 0 ) {
535                                Werror = true;
536                        } else {
537                                char * warning = optarg;
538                                Severity s;
539                                if ( strncmp( optarg, "no-", 3 ) == 0 ) {
540                                        warning += 3;
541                                        s = Severity::Suppress;
542                                } else {
543                                        s = Severity::Warn;
544                                } // if
545                                SemanticWarning_Set( warning, s );
546                        } // if
547                        break;
548                        case 'y':                                                                               // dump AST on error
549                        errorp = true;
550                        break;
551                        case 'z':                                                                               // dump as codegen rather than AST
552                        codegenp = true;
553                        break;
554                        case 'Z':                                                                       // prettyprint during codegen (i.e. print unmangled names, etc.)
555                        prettycodegenp = true;
556                        break;
557                        case 'D':                                                                               // ignore -Dxxx
558                        break;
559                        case 'F':                                                                               // source file-name without suffix
560                        filename = optarg;
561                        break;
562                        case '?':
563                        if ( optopt ) {                                                         // short option ?
564                                assertf( false, "Unknown option: -%c\n", (char)optopt );
565                        } else {
566                                assertf( false, "Unknown option: %s\n", argv[optind - 1] );
567                        } // if
568                        #if defined(__GNUC__) && __GNUC__ >= 7
569                                __attribute__((fallthrough));
570                        #endif
571                        default:
572                        abort();
573                } // switch
574        } // while
575
576        if ( Werror ) {
577                SemanticWarning_WarningAsError();
578        } // if
579        if ( Wsuppress ) {
580                SemanticWarning_SuppressAll();
581        } // if
582        // for ( const auto w : WarningFormats ) {
583        //      cout << w.name << ' ' << (int)w.severity << endl;
584        // } // for
585} // parse_cmdline
586
587static void parse( FILE * input, LinkageSpec::Spec linkage, bool shouldExit ) {
588        extern int yyparse( void );
589        extern FILE * yyin;
590        extern int yylineno;
591
592        ::linkage = linkage;                                                            // set globals
593        yyin = input;
594        yylineno = 1;
595        int parseStatus = yyparse();
596
597        fclose( input );
598        if ( shouldExit || parseStatus != 0 ) {
599                exit( parseStatus );
600        } // if
601} // parse
602
603static bool notPrelude( Declaration * decl ) {
604        return ! LinkageSpec::isBuiltin( decl->get_linkage() );
605} // notPrelude
606
607static void dump( list< Declaration * > & translationUnit, ostream & out ) {
608        list< Declaration * > decls;
609
610        if ( noprotop ) {
611                filter( translationUnit.begin(), translationUnit.end(), back_inserter( decls ), notPrelude );
612        } else {
613                decls = translationUnit;
614        } // if
615
616        // depending on commandline options, either generate code or dump the AST
617        if ( codegenp ) {
618                CodeGen::generate( decls, out, ! noprotop, prettycodegenp );
619        } else {
620                printAll( decls, out );
621        }
622        deleteAll( translationUnit );
623} // dump
624
625// Local Variables: //
626// tab-width: 4 //
627// mode: c++ //
628// compile-command: "make install" //
629// End:  //
Note: See TracBrowser for help on using the repository browser.