Changeset 62ce290
- Timestamp:
- May 3, 2019, 6:05:36 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- c4b072c, c6a90bf
- Parents:
- 76f7fc7
- Location:
- src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CompilationState.cc
r76f7fc7 r62ce290 10 10 // Created On : Mon Ju1 30 10:47:01 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu May 2 07:46:12201913 // Update Count : 312 // Last Modified On : Fri May 3 13:45:23 2019 13 // Update Count : 4 14 14 // 15 15 … … 26 26 libcfap = false, 27 27 nopreludep = false, 28 noprotop= false,28 genproto = false, 29 29 nomainp = false, 30 30 parsep = false, -
src/CompilationState.h
r76f7fc7 r62ce290 10 10 // Created On : Mon Ju1 30 10:47:01 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu May 2 07:46:12201913 // Update Count : 312 // Last Modified On : Fri May 3 13:43:21 2019 13 // Update Count : 4 14 14 // 15 15 … … 27 27 libcfap, 28 28 nopreludep, 29 noprotop,29 genproto, 30 30 nomainp, 31 31 parsep, -
src/main.cc
r76f7fc7 r62ce290 10 10 // Created On : Fri May 15 23:12:02 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu May 2 11:09:37201913 // Update Count : 5 2312 // Last Modified On : Fri May 3 16:10:52 2019 13 // Update Count : 599 14 14 // 15 15 … … 24 24 #include <fstream> // for ofstream 25 25 #include <iostream> // for operator<<, basic_ostream 26 #include <iomanip> 26 27 #include <iterator> // for back_inserter 27 28 #include <list> // for list … … 355 356 356 357 CodeTools::fillLocations( translationUnit ); 357 PASS( "Code Gen", CodeGen::generate( translationUnit, *output, ! noprotop, prettycodegenp, true, linemarks ) );358 PASS( "Code Gen", CodeGen::generate( translationUnit, *output, ! genproto, prettycodegenp, true, linemarks ) ); 358 359 359 360 CodeGen::FixMain::fix( *output, (PreludeDirector + "/bootloader.c").c_str() ); … … 405 406 406 407 407 static const char optstring[] = ":abBcCdeEGghlLmNnpP:qrRS:stTvwW:yzZD:F:"; 408 408 static const char optstring[] = ":hlLmNn:pP:S:twW:D:F:"; 409 410 enum { PreludeDir = 128 }; 409 411 static struct option long_opts[] = { 410 { "ast", no_argument, nullptr, 'a' },411 { "before-resolver", no_argument, nullptr, 'b' },412 { "box", no_argument, nullptr, 'B' },413 { "ctorinitfix", no_argument, nullptr, 'c' },414 { "code", no_argument, nullptr, 'C' },415 { "decl-stmts", no_argument, nullptr, 'd' },416 { "expr", no_argument, nullptr, 'e' },417 { "expralt", no_argument, nullptr, 'E' },418 { "generics", no_argument, nullptr, 'G' },419 { "grammar", no_argument, nullptr, 'g' },420 412 { "help", no_argument, nullptr, 'h' }, 421 413 { "libcfa", no_argument, nullptr, 'l' }, 422 { "line -marks", no_argument, nullptr, 'L' },414 { "linemarks", no_argument, nullptr, 'L' }, 423 415 { "no-main", no_argument, 0, 'm' }, 424 { "no-line -marks", no_argument, nullptr, 'N' },425 { "no-pre amble", no_argument, nullptr, 'n' },416 { "no-linemarks", no_argument, nullptr, 'N' }, 417 { "no-prelude", no_argument, nullptr, 'n' }, 426 418 { "prototypes", no_argument, nullptr, 'p' }, 427 { "prelude-dir <directory>", required_argument, nullptr, 'P' }, 428 { "parse-tree", no_argument, nullptr, 'q' }, 429 { "resolver", no_argument, nullptr, 'r' }, 430 { "resolver-proto", no_argument, nullptr, 'R' }, 431 { "statistics <option-list>", required_argument, nullptr, 'S' }, 432 { "symbol", no_argument, nullptr, 's' }, 419 { "print", required_argument, nullptr, 'P' }, 420 { "prelude-dir", required_argument, nullptr, PreludeDir }, 421 { "statistics", required_argument, nullptr, 'S' }, 433 422 { "tree", no_argument, nullptr, 't' }, 434 { "tuple", no_argument, nullptr, 'T' },435 { "validate", no_argument, nullptr, 'v' },436 423 { "", no_argument, nullptr, 0 }, // -w 437 424 { "", no_argument, nullptr, 0 }, // -W 438 { "dump-ast-on-error", no_argument, nullptr, 'y' },439 { "dump-ast-code", no_argument, nullptr, 'z' },440 { "prettyprint-codegen", no_argument, nullptr, 'Z' },441 425 { "", no_argument, nullptr, 0 }, // -D 442 426 { "", no_argument, nullptr, 0 }, // -F … … 445 429 446 430 static const char * description[] = { 447 "dump AST", // -a 448 "print before resolver step", // -b 449 "print before box step", // -B 450 "print after ctor/dtor are replaced", // -c 451 "print before code generation", // -C 452 "print declaration statements", // -d 453 "dump AST after expression analysis", // -e 454 "print alternatives for expressions", // -E 455 "dump AST after instantiate generics", // -G 456 "print bison (parsing) debugging information", // -g 457 "help message", // -h 431 "print help message", // -h 458 432 "generate libcfa.c", // -l 459 " print line marks",// -L433 "generate line marks", // -L 460 434 "do not replace main", // -m 461 "suppress line marks", // -N 462 "do not read preamble", // -n 463 "generate prototypes for preamble functions", // -p 464 "prelude directory for debug/nodebug", // -P 465 "dump parse tree", // -q 466 "print resolver steps", // -r 467 "dump resolver-proto instance", // -R 468 "enable profiling information: counters,heap,time", // -S 469 "print symbol table events", // -s 435 "do not generate line marks", // -N 436 "do not read prelude", // -n 437 "generate prototypes for prelude functions", // -p 438 "print", // -P 439 "<directory> prelude directory for debug/nodebug", // no flag 440 "<option-list> enable profiling information:\n counters,heap,time,all,none", // -S 470 441 "build in tree", // -t 471 "print after tuple expansion", // -T472 "dump AST after declaration validation pass", // -v473 442 "", // -w 474 443 "", // -W 475 "dump AST on error", // -y476 "dump as codegen rather than AST", // -z477 "prettyprint during codegen", // -Z478 444 "", // -D 479 445 "", // -F 480 446 }; // description 447 448 static_assert( sizeof( long_opts ) / sizeof( long_opts[0] ) - 1 == sizeof( description ) / sizeof( description[0] ) ); 449 450 static struct Printopts { 451 const char * name; 452 int & flag; 453 int val; 454 const char * descript; 455 } printopts[] = { 456 { "altexpr", expraltp, true, "alternatives for expressions" }, 457 { "ascodegen", codegenp, true, "as codegen rather than AST" }, 458 { "ast", astp, true, "AST after parsing" }, 459 { "astdecl", validp, true, "AST after declaration validation pass" }, 460 { "asterr", errorp, true, "AST on error" }, 461 { "astexpr", exprp, true, "AST after expression analysis" }, 462 { "astgen", genericsp, true, "AST after instantiate generics" }, 463 { "box", bboxp, true, "before box step" }, 464 { "ctordtor", ctorinitp, true, "after ctor/dtor are replaced" }, 465 { "codegen", bcodegenp, true, "before code generation" }, 466 { "declstats", declstatsp, true, "code property statistics" }, 467 { "parse", yydebug, true, "yacc (parsing) debug information" }, 468 { "pretty", prettycodegenp, true, "prettyprint for ascodegen flag" }, 469 { "resolver", bresolvep, true, "before resolver step" }, 470 { "rproto", resolvprotop, true, "resolver-proto instance" }, 471 { "rsteps", resolvep, true, "resolver steps" }, 472 { "symevt", symtabp, true, "symbol table events" }, 473 { "tree", parsep, true, "parse tree" }, 474 { "tuple", tuplep, true, "after tuple expansion" }, 475 }; 476 enum { printoptsSize = sizeof( printopts ) / sizeof( printopts[0] ) }; 481 477 482 478 static void usage( char *argv[] ) { … … 485 481 for ( ; long_opts[i].name != 0 && optstring[j] != '\0'; i += 1, j += 1 ) { 486 482 if ( long_opts[i].name[0] != '\0' ) { // hidden option, internal usage only 487 cout << " -" << optstring[j] << ", --" << long_opts[i].name << " " << description[i] << endl; 488 } // if 489 if ( optstring[j+1] == ':' ) j += 1; 483 if ( strcmp( long_opts[i].name, "prelude-dir" ) != 0 ) { // flag 484 cout << " -" << optstring[j] << ","; 485 } else { // no flag 486 j -= 1; // compensate 487 cout << " "; 488 } // if 489 cout << " --" << left << setw(12) << long_opts[i].name << " "; 490 if ( strcmp( long_opts[i].name, "print" ) == 0 ) { 491 cout << "one of: " << endl; 492 for ( int i = 0; i < printoptsSize; i += 1 ) { 493 cout << setw(10) << " " << left << setw(10) << printopts[i].name << " " << printopts[i].descript << endl; 494 } // for 495 } else { 496 cout << description[i] << endl; 497 } // if 498 } // if 499 if ( optstring[j + 1] == ':' ) j += 1; 490 500 } // for 491 501 if ( long_opts[i].name != 0 || optstring[j] != '\0' ) assertf( false, "internal error, mismatch of option flags and names\n" ); … … 500 510 while ( (c = getopt_long( argc, argv, optstring, long_opts, nullptr )) != -1 ) { 501 511 switch ( c ) { 502 case 'a': // dump AST503 astp = true;504 break;505 case 'b': // print before resolver steps506 bresolvep = true;507 break;508 case 'B': // print before box steps509 bboxp = true;510 break;511 case 'c': // print after ctor/dtor are replaced512 ctorinitp = true;513 break;514 case 'C': // print before code generation515 bcodegenp = true;516 break;517 case 'd': // print declaration statements518 declstatsp = true;519 break;520 case 'e': // dump AST after expression analysis521 exprp = true;522 break;523 case 'E': // print alternatives for expressions524 expraltp = true;525 break;526 case 'G': // dump AST after instantiate generics527 genericsp = true;528 break;529 case 'g': // print bison (parsing) debugging information530 yydebug = true;531 break;532 512 case 'h': // help message 533 513 usage( argv ); // no return … … 536 516 libcfap = true; 537 517 break; 538 case 'L': // printline marks518 case 'L': // generate line marks 539 519 linemarks = true; 540 520 break; … … 542 522 nomainp = true; 543 523 break; 544 case 'N': // suppressline marks524 case 'N': // do not generate line marks 545 525 linemarks = false; 546 526 break; 547 case 'n': // do not read pre amble527 case 'n': // do not read prelude 548 528 nopreludep = true; 549 529 break; 550 case 'p': // generate prototypes for preamble functions 551 noprotop = true; 552 break; 553 case 'P': // prelude directory for debug/nodebug, hidden 530 case 'p': // generate prototypes for prelude functions 531 genproto = true; 532 break; 533 case 'P': // print options 534 for ( int i = 0;; i += 1 ) { 535 if ( i == printoptsSize ) { 536 cout << "Unknown --print option " << optarg << endl; 537 goto Default; 538 } // if 539 if ( strcmp( optarg, printopts[i].name ) == 0 ) { 540 printopts[i].flag = printopts[i].val; 541 break; 542 } // if 543 } // for 544 break; 545 case PreludeDir: // prelude directory for debug/nodebug, hidden 554 546 PreludeDirector = optarg; 555 break;556 case 'q': // dump parse tree557 parsep = true;558 break;559 case 'r': // print resolver steps560 resolvep = true;561 break;562 case 'R': // dump resolver-proto instance563 resolvprotop = true;564 547 break; 565 548 case 'S': // enable profiling information, argument comma separated list of names 566 549 Stats::parse_params( optarg ); 567 550 break; 568 case 's': // print symbol table events569 symtabp = true;570 break;571 551 case 't': // build in tree 572 552 treep = true; 573 break;574 case 'T': // print after tuple expansion575 tuplep = true;576 break;577 case 'v': // dump AST after declaration validation pass578 validp = true;579 553 break; 580 554 case 'w': // suppress all warnings, hidden … … 598 572 } // if 599 573 break; 600 case 'y': // dump AST on error601 errorp = true;602 break;603 case 'z': // dump as codegen rather than AST604 codegenp = true;605 break;606 case 'Z': // prettyprint during codegen (i.e. print unmangled names, etc.)607 prettycodegenp = true;608 break;609 574 case 'D': // ignore -Dxxx, forwarded by cpp, hidden 610 575 break; … … 666 631 list< Declaration * > decls; 667 632 668 if ( noprotop) {633 if ( genproto ) { 669 634 filter( translationUnit.begin(), translationUnit.end(), back_inserter( decls ), notPrelude ); 670 635 } else { … … 674 639 // depending on commandline options, either generate code or dump the AST 675 640 if ( codegenp ) { 676 CodeGen::generate( decls, out, ! noprotop, prettycodegenp );641 CodeGen::generate( decls, out, ! genproto, prettycodegenp ); 677 642 } else { 678 643 printAll( decls, out );
Note: See TracChangeset
for help on using the changeset viewer.