Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main.cc

    r05e6eb5 r37fe352  
    2828#include <string>                           // for char_traits, operator<<
    2929
    30 #include "CompilationState.h"
    3130#include "../config.h"                      // for CFA_LIBDIR
    3231#include "CodeGen/FixMain.h"                // for FixMain
     
    7372DeclarationNode * parseTree = nullptr;                                  // program parse tree
    7473
     74extern int yydebug;                                                                             // set for -g flag (Grammar)
     75bool
     76        astp = false,
     77        bresolvep = false,
     78        bboxp = false,
     79        bcodegenp = false,
     80        ctorinitp = false,
     81        declstatsp = false,
     82        exprp = false,
     83        expraltp = false,
     84        genericsp = false,
     85        libcfap = false,
     86        nopreludep = false,
     87        noprotop = false,
     88        nomainp = false,
     89        parsep = false,
     90        resolvep = false,                                                                       // used in AlternativeFinder
     91        symtabp = false,
     92        treep = false,
     93        tuplep = false,
     94        validp = false,
     95        errorp = false,
     96        codegenp = false,
     97        prettycodegenp = false,
     98        linemarks = false;
     99
     100std::string PreludeDirector = "";
     101
    75102static void parse_cmdline( int argc, char *argv[], const char *& filename );
    76103static void parse( FILE * input, LinkageSpec::Spec linkage, bool shouldExit = false );
     
    182209                        // -l is for initial build ONLY and builtins.cf is not in the lib directory so access it here.
    183210
     211                        assertf( !PreludeDirector.empty(), "Can't find prelude without option --prelude-dir must be used." );
     212
    184213                        // Read to gcc builtins, if not generating the cfa library
    185                         FILE * gcc_builtins = fopen( buildingLibrary() ? "../prelude/gcc-builtins.cf" : CFA_LIBDIR "/gcc-builtins.cf", "r" );
     214                        FILE * gcc_builtins = fopen( (PreludeDirector + "/gcc-builtins.cf").c_str(), "r" );
    186215                        assertf( gcc_builtins, "cannot open gcc-builtins.cf\n" );
    187216                        parse( gcc_builtins, LinkageSpec::Compiler );
    188217
    189218                        // read the extra prelude in, if not generating the cfa library
    190                         FILE * extras = fopen( buildingLibrary() ? "../prelude/extras.cf" : CFA_LIBDIR "/extras.cf", "r" );
     219                        FILE * extras = fopen( (PreludeDirector + "/extras.cf").c_str(), "r" );
    191220                        assertf( extras, "cannot open extras.cf\n" );
    192221                        parse( extras, LinkageSpec::BuiltinC );
     
    194223                        if ( ! libcfap ) {
    195224                                // read the prelude in, if not generating the cfa library
    196                                 FILE * prelude = fopen( buildingLibrary() ? "../prelude/prelude.cf" : CFA_LIBDIR "/prelude.cf", "r" );
     225                                FILE * prelude = fopen( (PreludeDirector + "/prelude.cf").c_str(), "r" );
    197226                                assertf( prelude, "cannot open prelude.cf\n" );
    198227                                parse( prelude, LinkageSpec::Intrinsic );
    199228
    200229                                // Read to cfa builtins, if not generating the cfa library
    201                                 FILE * builtins = fopen( buildingLibrary() ? "../prelude/builtins.cf" : CFA_LIBDIR "/builtins.cf", "r" );
     230                                FILE * builtins = fopen( (PreludeDirector + "/builtins.cf").c_str(), "r" );
    202231                                assertf( builtins, "cannot open builtins.cf\n" );
    203232                                parse( builtins, LinkageSpec::BuiltinCFA );
     
    274303
    275304                // fix ObjectDecl - replaces ConstructorInit nodes
    276                 PASS( "fixInit", InitTweak::fix( translationUnit, buildingLibrary() ) );
     305                PASS( "fixInit", InitTweak::fix( translationUnit, filename, libcfap || treep ) );
    277306                if ( ctorinitp ) {
    278307                        dump ( translationUnit );
     
    323352                PASS( "codegen", CodeGen::generate( translationUnit, *output, ! noprotop, prettycodegenp, true, linemarks ) );
    324353
    325                 CodeGen::FixMain::fix( *output, treep ? "../prelude/bootloader.c" : CFA_LIBDIR "/bootloader.c" );
     354                CodeGen::FixMain::fix( *output, (PreludeDirector + "/bootloader.c").c_str() );
    326355                if ( output != &cout ) {
    327356                        delete output;
     
    372401
    373402void parse_cmdline( int argc, char * argv[], const char *& filename ) {
    374         enum { Ast, Bbox, Bresolver, CtorInitFix, DeclStats, Expr, ExprAlt, Grammar, LibCFA, Linemarks, Nolinemarks, Nopreamble, Parse, Prototypes, Resolver, Symbol, Tree, TupleExpansion, Validate, };
     403        enum { Ast, Bbox, Bresolver, CtorInitFix, DeclStats, Expr, ExprAlt, Grammar, LibCFA, Linemarks, Nolinemarks, Nopreamble, Parse, PreludeDir, Prototypes, Resolver, Symbol, Tree, TupleExpansion, Validate, };
    375404
    376405        static struct option long_opts[] = {
     
    388417                { "no-preamble", no_argument, 0, Nopreamble },
    389418                { "parse", no_argument, 0, Parse },
     419                { "prelude-dir", required_argument, 0, PreludeDir },
    390420                { "no-prototypes", no_argument, 0, Prototypes },
    391421                { "resolver", no_argument, 0, Resolver },
     
    460490                  case 'p':                                                                             // generate prototypes for preamble functions
    461491                        noprotop = true;
     492                        break;
     493                  case PreludeDir:
     494                        PreludeDirector = optarg;
    462495                        break;
    463496                  case 'm':                                                                             // don't replace the main
Note: See TracChangeset for help on using the changeset viewer.