- Timestamp:
- Sep 19, 2017, 1:22:51 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- a9a4771
- Parents:
- 4e8949f
- Location:
- src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
r4e8949f rd48e529 89 89 } else if ( currentLocation.followedBy( to, 1 ) ) { 90 90 output << "\n" << indent; 91 currentLocation. linenumber+= 1;91 currentLocation.first_line += 1; 92 92 } else if ( currentLocation.followedBy( to, 2 ) ) { 93 93 output << "\n\n" << indent; 94 currentLocation. linenumber+= 2;95 } else { 96 output << "\n# " << to. linenumber<< " \"" << to.filename94 currentLocation.first_line += 2; 95 } else { 96 output << "\n# " << to.first_line << " \"" << to.filename 97 97 << "\"\n" << indent; 98 98 currentLocation = to; -
src/Common/CodeLocation.h
r4e8949f rd48e529 20 20 21 21 struct CodeLocation { 22 int linenumber;23 std::string filename ;22 int first_line = -1, first_column = -1, last_line = -1, last_column = -1; 23 std::string filename = ""; 24 24 25 25 /// Create a new unset CodeLocation. 26 CodeLocation() 27 : linenumber( -1 ) 28 , filename("") 29 {} 26 CodeLocation() = default; 30 27 31 28 /// Create a new CodeLocation with the given values. 32 29 CodeLocation( const char* filename, int lineno ) 33 : linenumber( lineno )30 : first_line( lineno ) 34 31 , filename(filename ? filename : "") 35 32 {} … … 38 35 39 36 bool isSet () const { 40 return -1 != linenumber;37 return -1 != first_line; 41 38 } 42 39 … … 46 43 47 44 bool followedBy( CodeLocation const & other, int seperation ) { 48 return ( linenumber + seperation == other.linenumber&&45 return (first_line + seperation == other.first_line && 49 46 filename == other.filename); 50 47 } … … 61 58 inline std::ostream & operator<<( std::ostream & out, const CodeLocation & location ) { 62 59 // Column number ":1" allows IDEs to parse the error message and position the cursor in the source text. 63 return location.isSet() ? out << location.filename << ":" << location. linenumber<< ":1 " : out;60 return location.isSet() ? out << location.filename << ":" << location.first_line << ":1 " : out; 64 61 } -
src/Common/SemanticError.h
r4e8949f rd48e529 32 32 33 33 void maybeSet( const CodeLocation & location ) { 34 if( this->location. linenumber < 0) {34 if( this->location.isUnset() ) { 35 35 this->location = location; 36 36 } -
src/ControlStruct/ExceptTranslate.cc
r4e8949f rd48e529 622 622 assertf(false, "Invalid throw in %s at %i\n", 623 623 throwStmt->location.filename.c_str(), 624 throwStmt->location. linenumber);624 throwStmt->location.first_line); 625 625 return nullptr; 626 626 } … … 633 633 assertf(false, "Invalid throwResume in %s at %i\n", 634 634 throwStmt->location.filename.c_str(), 635 throwStmt->location. linenumber);635 throwStmt->location.first_line); 636 636 return nullptr; 637 637 } -
src/Parser/ParseNode.h
r4e8949f rd48e529 44 44 //############################################################################## 45 45 46 typedef CodeLocation YYLTYPE; 47 #define YYLTYPE_IS_DECLARED 1 /* alert the parser that we have our own definition */ 48 46 49 extern char * yyfilename; 47 50 extern int yylineno; 51 extern YYLTYPE yylloc; 48 52 49 53 class ParseNode { … … 73 77 ParseNode * next = nullptr; 74 78 std::string * name = nullptr; 75 CodeLocation location = { yyfilename, yylineno };79 CodeLocation location = yylloc; 76 80 }; // ParseNode 77 81 -
src/Parser/lex.ll
r4e8949f rd48e529 26 26 27 27 unsigned int column = 0; // position of the end of the last token parsed 28 #define YY_USER_ACTION column += yyleng; // trigger before each matching rule's action28 #define YY_USER_ACTION yylloc.first_line = yylineno; yylloc.first_column = column; column += yyleng; yylloc.last_column = column; yylloc.last_line = yylineno; yylloc.filename = yyfilename ? yyfilename : ""; // trigger before each matching rule's action 29 29 30 30 #include <string> -
src/Parser/parser.yy
r4e8949f rd48e529 116 116 117 117 bool forall = false; // aggregate have one or more forall qualifiers ? 118 119 # define YYLLOC_DEFAULT(Cur, Rhs, N) \ 120 do \ 121 if (N) { \ 122 (Cur).first_line = YYRHSLOC(Rhs, 1).first_line; \ 123 (Cur).first_column = YYRHSLOC(Rhs, 1).first_column; \ 124 (Cur).last_line = YYRHSLOC(Rhs, N).last_line; \ 125 (Cur).last_column = YYRHSLOC(Rhs, N).last_column; \ 126 (Cur).filename = YYRHSLOC(Rhs, 1).filename; \ 127 } else { \ 128 (Cur).first_line = (Cur).last_line = \ 129 YYRHSLOC(Rhs, 0).last_line; \ 130 (Cur).first_column = (Cur).last_column = \ 131 YYRHSLOC(Rhs, 0).last_column; \ 132 (Cur).filename = YYRHSLOC(Rhs, 0).filename; \ 133 } \ 134 while (0) 118 135 %} 119 136 … … 346 363 %precedence ELSE // token precedence for start of else clause in IF/WAITFOR statement 347 364 365 %locations 348 366 349 367 %start translation_unit // parse-tree root
Note: See TracChangeset
for help on using the changeset viewer.