Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main.cc

    r626dbc10 r3fe34ae  
    1414//
    1515
     16#include <memory>
    1617#include <iostream>
    1718#include <fstream>
     
    6566        nopreludep = false,
    6667        noprotop = false,
     68        nomainp = false,
    6769        parsep = false,
    6870        resolvep = false,                                                                       // used in AlternativeFinder
     
    7779static void parse( FILE * input, LinkageSpec::Spec linkage, bool shouldExit = false );
    7880static void dump( list< Declaration * > & translationUnit, ostream & out = cout );
     81
     82bool translation_unit_nomain = true;
     83std::unique_ptr<FunctionDecl> translation_unit_main_signature = nullptr;
    7984
    8085static void backtrace( int start ) {                                    // skip first N stack frames
     
    154159
    155160        parse_cmdline( argc, argv, filename );                          // process command-line arguments
     161        translation_unit_nomain = nomainp;
    156162
    157163        try {
     
    299305
    300306                CodeGen::generate( translationUnit, *output, ! noprotop );
     307
     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                }
    301319
    302320                if ( output != &cout ) {
     
    360378
    361379        int c;
    362         while ( (c = getopt_long( argc, argv, "abBcefglnpqrstTvyzD:F:", long_opts, &long_index )) != -1 ) {
     380        while ( (c = getopt_long( argc, argv, "abBcefglmnpqrstTvyzD:F:", long_opts, &long_index )) != -1 ) {
    363381                switch ( c ) {
    364382                  case Ast:
     
    400418                  case 'p':                                                                             // generate prototypes for preamble functions
    401419                        noprotop = true;
     420                        break;
     421                  case 'm':                                                                             // don't replace the main
     422                        nomainp = true;
    402423                        break;
    403424                  case Parse:
Note: See TracChangeset for help on using the changeset viewer.