Changeset b1a6d6b for translator/main.cc


Ignore:
Timestamp:
May 14, 2015, 12:19:46 PM (9 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
4bf5298
Parents:
d4778a6
Message:

removed duplicate adapters, switch to c99 for initializer declarations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • translator/main.cc

    rd4778a6 rb1a6d6b  
    4949    bool debugp = false, treep = false, astp = false, manglep = false, symtabp = false, validp = false;
    5050    bool preludep = true, protop = false, libp = false;
    51     bool exprp = false, codegenp = false;
     51    bool exprp = false, codegenp = false, errorp = false;
    5252    int c;
    5353    FILE *input, *prelude, *builtins;
     
    5656    opterr = 0;
    5757
    58     while ( (c = getopt( argc, argv, "dtsgmvxcenprlDz:" )) != -1 ) {
     58    std::list< Declaration* > translationUnit;
     59   
     60    while ( (c = getopt( argc, argv, "dtsgmvxcenprlDyz:" )) != -1 ) {
    5961        switch (c) {
    6062          case 'd':
    61             /* bison debugging info */
     63            // bison debugging info
    6264            debugp = true;
    6365            break;
    6466          case 't':
    65             /* dump parse tree */
     67            // dump parse tree
    6668            treep = true;
    6769            break;
    6870          case 's':
    69             /* dump AST */
     71            // dump AST
    7072            astp = true;
    7173            break;
    7274          case 'g':
    73             /* print alternatives for expressions */
     75            // print alternatives for expressions
    7476            manglep = true;
    7577            break;
    7678          case 'm':
    77             /* print symbol table events */
     79            // print symbol table events
    7880            symtabp = true;
    7981            break;
    8082          case 'r':
    81             /* print resolver steps */
     83            // print resolver steps
    8284            resolveVerbose = true;
    8385            break;
    8486          case 'x':
    85             /* dump AST after decl validation pass */
     87            // dump AST after decl validation pass
    8688            validp = true;
    8789            break;
    8890          case 'e':
    89             /* dump AST after expression analysis */
     91            // dump AST after expression analysis
    9092            exprp = true;
    9193            break;
     
    9395            codegenp = true;
    9496            break;
     97          case 'y':
     98            errorp = true;
     99            break;
    95100          case 'n':
    96             /* don't read preamble */
     101            // don't read preamble
    97102            preludep = false;
    98103            break;
    99104          case 'p':
    100             /* generate prototypes for preamble functions */
     105            // generate prototypes for preamble functions
    101106            protop = true;
    102107            break;
    103108          case 'l':
    104             /* generate libcfa.c */
     109            // generate libcfa.c
    105110            libp = true;
    106111            break;
    107112          case 'v':
    108             /* verbose */
     113            // verbose
    109114            beVerbose = true;
    110115            break;
    111116          case 'D':
    112             /* ignore -Dxxx */
     117            // ignore -Dxxx
    113118            break;
    114119          case '?':
     
    205210        } // if
    206211
    207         std::list< Declaration* > translationUnit;
    208212        buildList( Parser::get_parser().get_parseTree(), translationUnit );
    209213
     
    233237
    234238        if ( exprp ) {
     239            InitTweak::tweak( translationUnit );
    235240            SymTab::validate( translationUnit, false );
    236             ResolvExpr::resolve( translationUnit );
    237             printAll( translationUnit, std::cout );
    238             return 0;
    239         } // if
    240 
    241         if ( codegenp ) {
    242             // print the tree right before code generation...
    243                         // InitTweak::mutate( translationUnit );
    244             //            InitTweak::tweak( translationUnit );
    245             //printAll( translationUnit, std::cout );
    246 
    247             // std::cerr << "finished tweaking" << std::endl;
    248             SymTab::validate( translationUnit, false );
    249241            ControlStruct::mutate( translationUnit );
    250242            CodeGen::fixNames( translationUnit );
     243            ResolvExpr::resolve( translationUnit );
     244            printAll( translationUnit, std::cout );
     245            return 0;
     246        } // if
     247
     248        if ( codegenp ) {
     249            // print the tree right before code generation
     250            cerr << "tweak" << endl;
     251            InitTweak::tweak( translationUnit );
     252            cerr << "validate" << endl;
     253            SymTab::validate( translationUnit, false );
     254            cerr << "mutate" << endl;
     255            ControlStruct::mutate( translationUnit );
     256            cerr << "fixNames" << endl;
     257            CodeGen::fixNames( translationUnit );
     258            cerr << "resolve" << endl;
    251259            ResolvExpr::resolve( translationUnit );
     260            cerr << "copyParams" << endl;
    252261            GenPoly::copyParams( translationUnit );
     262            cerr << "convertSpecializations" << endl;
    253263            GenPoly::convertSpecializations( translationUnit );
     264            cerr << "convertLvalue" << endl;
    254265            GenPoly::convertLvalue( translationUnit );
     266            cerr << "box" << endl;
    255267            GenPoly::box( translationUnit );
    256             printAll( translationUnit, std::cout );
     268            if ( errorp ) {
     269                printAll( translationUnit, std::cout );
     270            }
    257271            return 0;
    258272        } // if
     
    293307
    294308    } catch ( SemanticError &e ) {
     309        if ( errorp ) {
     310           printAll( translationUnit, std::cout );
     311        }
    295312        e.print( cout );
    296313        if ( output != &std::cout ) {
Note: See TracChangeset for help on using the changeset viewer.