Changeset 13de47bc for src/main.cc


Ignore:
Timestamp:
Jan 12, 2017, 3:28:29 PM (8 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
aaa1a99a
Parents:
7cc2c8d
Message:

Proper bootloader boilerplate implemented

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main.cc

    r7cc2c8d r13de47bc  
    1414//
    1515
    16 #include <memory>
    1716#include <iostream>
    1817#include <fstream>
     
    3534#include "CodeGen/Generate.h"
    3635#include "CodeGen/FixNames.h"
     36#include "CodeGen/FixMain.h"
    3737#include "ControlStruct/Mutate.h"
    3838#include "SymTab/Validate.h"
     
    8080static void dump( list< Declaration * > & translationUnit, ostream & out = cout );
    8181
    82 bool translation_unit_nomain = true;
    83 std::unique_ptr<FunctionDecl> translation_unit_main_signature = nullptr;
    84 
    8582static void backtrace( int start ) {                                    // skip first N stack frames
    8683        enum { Frames = 50 };
     
    159156
    160157        parse_cmdline( argc, argv, filename );                          // process command-line arguments
    161         translation_unit_nomain = nomainp;
     158        CodeGen::FixMain::setReplaceMain( !nomainp );
    162159
    163160        try {
     
    178175                } // if
    179176
    180                 if ( optind < argc ) {                                                  // any commands after the flags and input file ? => output file name
    181                         output = new ofstream( argv[ optind ] );
    182                 } // if
    183 
    184177                // read in the builtins, extras, and the prelude
    185178                if ( ! nopreludep ) {                                                   // include gcc builtins
     
    304297                } // if
    305298
     299                if ( optind < argc ) {                                                  // any commands after the flags and input file ? => output file name
     300                        output = new ofstream( argv[ optind ] );
     301                } // if
     302
    306303                CodeGen::generate( translationUnit, *output, ! noprotop );
    307304
    308                 if( translation_unit_main_signature ) {
    309                         *output << "int main(int argc, char** argv) { return ";
    310 
    311                         *output << translation_unit_main_signature->get_scopedMangleName() << "(";
    312                         if(translation_unit_main_signature->get_functionType()->get_parameters().size() != 0){
    313                                 *output << "argc, argv";
    314                         }
    315                         *output << ");";
    316 
    317                         *output << " }\n";
    318                 }
     305                CodeGen::FixMain::fix( *output, treep ? "../prelude/bootloader.c" : CFA_LIBDIR "/bootloader.c" );
    319306
    320307                if ( output != &cout ) {
Note: See TracChangeset for help on using the changeset viewer.