Changes in src/main.cc [05e6eb5:37fe352]
- File:
-
- 1 edited
-
src/main.cc (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/main.cc
r05e6eb5 r37fe352 28 28 #include <string> // for char_traits, operator<< 29 29 30 #include "CompilationState.h"31 30 #include "../config.h" // for CFA_LIBDIR 32 31 #include "CodeGen/FixMain.h" // for FixMain … … 73 72 DeclarationNode * parseTree = nullptr; // program parse tree 74 73 74 extern int yydebug; // set for -g flag (Grammar) 75 bool 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 100 std::string PreludeDirector = ""; 101 75 102 static void parse_cmdline( int argc, char *argv[], const char *& filename ); 76 103 static void parse( FILE * input, LinkageSpec::Spec linkage, bool shouldExit = false ); … … 182 209 // -l is for initial build ONLY and builtins.cf is not in the lib directory so access it here. 183 210 211 assertf( !PreludeDirector.empty(), "Can't find prelude without option --prelude-dir must be used." ); 212 184 213 // 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" ); 186 215 assertf( gcc_builtins, "cannot open gcc-builtins.cf\n" ); 187 216 parse( gcc_builtins, LinkageSpec::Compiler ); 188 217 189 218 // 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" ); 191 220 assertf( extras, "cannot open extras.cf\n" ); 192 221 parse( extras, LinkageSpec::BuiltinC ); … … 194 223 if ( ! libcfap ) { 195 224 // 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" ); 197 226 assertf( prelude, "cannot open prelude.cf\n" ); 198 227 parse( prelude, LinkageSpec::Intrinsic ); 199 228 200 229 // 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" ); 202 231 assertf( builtins, "cannot open builtins.cf\n" ); 203 232 parse( builtins, LinkageSpec::BuiltinCFA ); … … 274 303 275 304 // fix ObjectDecl - replaces ConstructorInit nodes 276 PASS( "fixInit", InitTweak::fix( translationUnit, buildingLibrary()) );305 PASS( "fixInit", InitTweak::fix( translationUnit, filename, libcfap || treep ) ); 277 306 if ( ctorinitp ) { 278 307 dump ( translationUnit ); … … 323 352 PASS( "codegen", CodeGen::generate( translationUnit, *output, ! noprotop, prettycodegenp, true, linemarks ) ); 324 353 325 CodeGen::FixMain::fix( *output, treep ? "../prelude/bootloader.c" : CFA_LIBDIR "/bootloader.c");354 CodeGen::FixMain::fix( *output, (PreludeDirector + "/bootloader.c").c_str() ); 326 355 if ( output != &cout ) { 327 356 delete output; … … 372 401 373 402 void parse_cmdline( int argc, char * argv[], const char *& filename ) { 374 enum { Ast, Bbox, Bresolver, CtorInitFix, DeclStats, Expr, ExprAlt, Grammar, LibCFA, Linemarks, Nolinemarks, Nopreamble, Parse, Pr ototypes, 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, }; 375 404 376 405 static struct option long_opts[] = { … … 388 417 { "no-preamble", no_argument, 0, Nopreamble }, 389 418 { "parse", no_argument, 0, Parse }, 419 { "prelude-dir", required_argument, 0, PreludeDir }, 390 420 { "no-prototypes", no_argument, 0, Prototypes }, 391 421 { "resolver", no_argument, 0, Resolver }, … … 460 490 case 'p': // generate prototypes for preamble functions 461 491 noprotop = true; 492 break; 493 case PreludeDir: 494 PreludeDirector = optarg; 462 495 break; 463 496 case 'm': // don't replace the main
Note:
See TracChangeset
for help on using the changeset viewer.