Changes in src/main.cc [d3b7937:ca1c11f]
- File:
-
- 1 edited
-
src/main.cc (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/main.cc
rd3b7937 rca1c11f 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // main.cc -- 7 // main.cc -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Fri May 15 23:12:02 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed Jan 27 22:20:20201613 // Update Count : 19 911 // Last Modified By : Rob Schluntz 12 // Last Modified On : Tue Jan 19 16:28:13 2016 13 // Update Count : 194 14 14 // 15 15 … … 42 42 #include "InitTweak/Mutate.h" 43 43 #include "InitTweak/RemoveInit.h" 44 #include "InitTweak/FixInit.h" 44 45 //#include "Explain/GenProlog.h" 45 46 //#include "Try/Visit.h" 46 47 47 #include " Common/SemanticError.h"48 #include " Common/UnimplementedError.h"48 #include "SemanticError.h" 49 #include "UnimplementedError.h" 49 50 50 51 #include "../config.h" … … 61 62 astp = false, 62 63 bresolvep = false, 64 ctorinitp = false, 63 65 exprp = false, 64 66 expraltp = false, … … 70 72 resolvep = false, // used in AlternativeFinder 71 73 symtabp = false, 72 treep = false,73 74 validp = false, 74 75 errorp = false, 75 76 codegenp = false; 76 77 77 enum { Ast, Bresolver, Expr, ExprAlt, Grammar, LibCFA, Nopreamble, Parse, Prototypes, Resolver, Symbol, Tree, Validate, };78 enum { Ast, Bresolver, CtorInitFix, Expr, ExprAlt, Grammar, LibCFA, Nopreamble, Parse, Prototypes, Resolver, Symbol, Validate, }; 78 79 79 80 static struct option long_opts[] = { 80 81 { "ast", no_argument, 0, Ast }, 81 82 { "before-resolver", no_argument, 0, Bresolver }, 83 { "ctorinitfix", no_argument, 0, CtorInitFix }, 82 84 { "expr", no_argument, 0, Expr }, 83 85 { "expralt", no_argument, 0, ExprAlt }, … … 89 91 { "resolver", no_argument, 0, Resolver }, 90 92 { "symbol", no_argument, 0, Symbol }, 91 { "tree", no_argument, 0, Tree },92 93 { "validate", no_argument, 0, Validate }, 93 94 { 0, 0, 0, 0 } … … 101 102 102 103 opterr = 0; // prevent getopt from printing error messages 103 104 104 105 int c; 105 while ( (c = getopt_long( argc, argv, "ab efglnpqrstvyzD:", long_opts, &long_index )) != -1 ) {106 while ( (c = getopt_long( argc, argv, "abcefFglnpqrsvyzD:", long_opts, &long_index )) != -1 ) { 106 107 switch ( c ) { 107 108 case Ast: … … 113 114 bresolvep = true; 114 115 break; 116 case CtorInitFix: 117 case 'c': 118 ctorinitp = true; 119 break; 115 120 case Expr: 116 121 case 'e': // dump AST after expression analysis … … 148 153 case 's': // print symbol table events 149 154 symtabp = true; 150 break;151 case Tree:152 case 't': // build in tree153 treep = true;154 155 break; 155 156 case 'v': // dump AST after decl validation pass … … 188 189 output = new ofstream( argv[ optind ] ); 189 190 } // if 190 191 191 192 Parser::get_parser().set_debug( grammarp ); 192 193 … … 194 195 if ( ! nopreludep ) { // include gcc builtins 195 196 // -l is for initial build ONLY and builtins.cf is not in the lib directory so access it here. 196 FILE * builtins = fopen( libcfap | treep ? "builtins.cf" : CFA_LIBDIR "/builtins.cf", "r" );197 FILE * builtins = fopen( libcfap ? "./builtins.cf" : CFA_LIBDIR "/builtins.cf", "r" ); 197 198 if ( builtins == NULL ) { 198 std::cerr << "Error: can't open builtins .cf" << std::endl;199 std::cerr << "Error: can't open builtins" << std::endl; 199 200 exit( 1 ); 200 201 } // if … … 204 205 if ( ! libcfap ) { 205 206 // read the prelude in, if not generating the cfa library 206 FILE * prelude = fopen( treep ? "prelude.cf" :CFA_LIBDIR "/prelude.cf", "r" );207 FILE * prelude = fopen( CFA_LIBDIR "/prelude.cf", "r" ); 207 208 if ( prelude == NULL ) { 208 std::cerr << "Error: can't open prelude .cf" << std::endl;209 std::cerr << "Error: can't open prelude" << std::endl; 209 210 exit( 1 ); 210 211 } // if 211 212 212 213 parse( prelude, LinkageSpec::Intrinsic ); 213 214 } // if 214 215 } // if 215 216 216 parse( input, libcfap ? LinkageSpec::Intrinsic : LinkageSpec::Cforall, grammarp ); 217 217 parse( input, libcfap ? LinkageSpec::Intrinsic : LinkageSpec::Cforall, grammarp ); 218 218 219 if ( parsep ) { 219 220 Parser::get_parser().get_parseTree()->printList( std::cout ); … … 250 251 OPTPRINT( "mutate" ) 251 252 ControlStruct::mutate( translationUnit ); 252 OPTPRINT( "fixNames" ) 253 OPTPRINT( "fixNames" ) 253 254 CodeGen::fixNames( translationUnit ); 254 OPTPRINT( "tweak " )255 OPTPRINT( "tweakInit" ) 255 256 InitTweak::tweak( translationUnit ); 256 257 … … 269 270 if ( exprp ) { 270 271 dump( translationUnit ); 272 return 0; 273 } 274 275 OPTPRINT( "fixInit" ) 276 // fix ObjectDecl - replaces ConstructorInit nodes 277 InitTweak::fix( translationUnit ); 278 if ( ctorinitp ) { 279 dump ( translationUnit ); 280 return 0; 271 281 } 272 282 … … 337 347 std::list< Declaration * > decls; 338 348 if ( noprotop ) { 339 filter( translationUnit.begin(), translationUnit.end(), 349 filter( translationUnit.begin(), translationUnit.end(), 340 350 std::back_inserter( decls ), notPrelude ); 341 351 } else {
Note:
See TracChangeset
for help on using the changeset viewer.