Changeset 0270824 for src/main.cc


Ignore:
Timestamp:
Jan 12, 2017, 11:31:57 AM (7 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:
3fe34ae
Parents:
075734f
Message:

Replace user main with custom main, prototype

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main.cc

    r075734f r0270824  
    1414//
    1515
     16#include <memory>
    1617#include <iostream>
    1718#include <fstream>
     
    7879static void dump( list< Declaration * > & translationUnit, ostream & out = cout );
    7980
     81std::unique_ptr<FunctionDecl> translation_unit_main_signature = nullptr;
     82
    8083static void backtrace( int start ) {                                    // skip first N stack frames
    8184        enum { Frames = 50 };
     
    299302
    300303                CodeGen::generate( translationUnit, *output, ! noprotop );
     304
     305                if( translation_unit_main_signature ) {
     306                        *output << "int main(int argc, char** argv) { return ";
     307
     308                        *output << translation_unit_main_signature->get_scopedMangleName() << "(";
     309                        if(translation_unit_main_signature->get_functionType()->get_parameters().size() != 0){
     310                                *output << "argc, argv";
     311                        }
     312                        *output << ");";
     313
     314                        *output << " }\n";
     315                }
    301316
    302317                if ( output != &cout ) {
Note: See TracChangeset for help on using the changeset viewer.