Changeset fc12f05 for src/BasicTypes-gen.cc
- Timestamp:
- Nov 13, 2023, 3:43:43 AM (23 months ago)
- Branches:
- master
- Children:
- 25f2798
- Parents:
- 0030b508 (diff), 2174191 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/BasicTypes-gen.cc
r0030b508 rfc12f05 117 117 // { LongDoubleImaginary, "LongDoubleImaginary", "LDI", "long double _Imaginary", "Ie", false, LongDoubleComplex, -1, -1, 17 }, 118 118 119 { uFloat128x, "uFloat128x", "_FBX", "_Float128x", "DF128x_", Floating, uFloat128xComplex, -1, -1, 18 }, 119 { uFloat128x, "uFloat128x", "_FBX", "_Float128x", "DF128x_", Floating, uFloat128xComplex, -1, -1, 18 }, 120 120 { uFloat128xComplex, "uFloat128xComplex", "_FLDXC", "_Float128x _Complex", "CDF128x_", Floating, -1, -1, -1, 18 } 121 121 }; // graph … … 127 127 void generateCosts( int row ) { 128 128 bool seen[NUMBER_OF_BASIC_TYPES] = { false /*, ... */ }; 129 129 130 130 struct el_cost { 131 131 int i; 132 132 int path; 133 133 int sign; 134 134 135 135 el_cost( int i = 0, int p = 0, int s = 0 ) : i(i), path(p), sign(s) {} 136 136 137 137 // reverse the sense for use in largest-on-top priority queue 138 138 bool operator< (const el_cost& o) const { … … 195 195 return; 196 196 } // if 197 197 198 198 i = graph[col].middle; 199 199 if ( i == -1 ) assert("invalid ancestor assumption"); … … 272 272 size_t start, end; 273 273 274 275 #define TypeH TOP_SRCDIR "src/SynTree/Type.h" 276 resetInput( file, TypeH, buffer, code, str ); 277 278 if ( (start = str.find( STARTMK )) == string::npos ) Abort( "start", TypeH ); 274 #define TypeH_AST TOP_SRCDIR "src/AST/Type.hpp" 275 resetInput( file, TypeH_AST, buffer, code, str ); 276 277 if ( (start = str.find( STARTMK )) == string::npos ) Abort( "start", TypeH_AST ); 279 278 start += sizeof( STARTMK ); // includes newline 280 279 code << str.substr( 0, start ); … … 284 283 for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) { 285 284 code << "\t\t" << graph[r].name << "," << endl; 286 } // for 285 } // for 287 286 code << "\t\tNUMBER_OF_BASIC_TYPES" << endl; 288 287 code << "\t} kind;" << endl; 289 288 code << "\t"; // indentation for end marker 290 289 291 if ( (start = str.find( ENDMK, start + 1 )) == string::npos ) Abort( "end", TypeH );290 if ( (start = str.find( ENDMK, start + 1 )) == string::npos ) Abort( "end", TypeH_AST ); 292 291 code << str.substr( start ); 293 292 294 output( file, TypeH , code );293 output( file, TypeH_AST, code ); 295 294 // cout << code.str(); 296 295 297 296 298 #define TypeC TOP_SRCDIR "src/SynTree/Type.cc"299 resetInput( file, TypeC , buffer, code, str );300 301 if ( (start = str.find( STARTMK )) == string::npos ) Abort( "start", TypeC );297 #define TypeC_AST TOP_SRCDIR "src/AST/Type.cpp" 298 resetInput( file, TypeC_AST, buffer, code, str ); 299 300 if ( (start = str.find( STARTMK )) == string::npos ) Abort( "start", TypeC_AST ); 302 301 start += sizeof( STARTMK ); // includes newline 303 302 code << str.substr( 0, start ); … … 307 306 for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) { 308 307 code << "\t\"" << graph[r].type << "\"," << endl; 309 } // for 310 code << "};" << endl; 311 312 if ( (start = str.find( ENDMK, start + 1 )) == string::npos ) Abort( "end", TypeC ); 313 code << str.substr( start ); 314 315 output( file, TypeC, code ); 316 // cout << code.str(); 317 318 319 // TEMPORARY DURING CHANGE OVER 320 #define TypeH_AST TOP_SRCDIR "src/AST/Type.hpp" 321 resetInput( file, TypeH_AST, buffer, code, str ); 322 323 if ( (start = str.find( STARTMK )) == string::npos ) Abort( "start", TypeH_AST ); 324 start += sizeof( STARTMK ); // includes newline 325 code << str.substr( 0, start ); 326 327 code << "\t" << BYMK << endl; 328 code << "\tenum Kind {" << endl; 329 for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) { 330 code << "\t\t" << graph[r].name << "," << endl; 331 } // for 332 code << "\t\tNUMBER_OF_BASIC_TYPES" << endl; 333 code << "\t} kind;" << endl; 334 code << "\t"; // indentation for end marker 335 336 if ( (start = str.find( ENDMK, start + 1 )) == string::npos ) Abort( "end", TypeH_AST ); 337 code << str.substr( start ); 338 339 output( file, TypeH_AST, code ); 340 // cout << code.str(); 341 342 343 #define TypeC_AST TOP_SRCDIR "src/AST/Type.cpp" 344 resetInput( file, TypeC_AST, buffer, code, str ); 345 346 if ( (start = str.find( STARTMK )) == string::npos ) Abort( "start", TypeC_AST ); 347 start += sizeof( STARTMK ); // includes newline 348 code << str.substr( 0, start ); 349 350 code << BYMK << endl; 351 code << "const char * BasicType::typeNames[] = {" << endl; 352 for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) { 353 code << "\t\"" << graph[r].type << "\"," << endl; 354 } // for 308 } // for 355 309 code << "};" << endl; 356 310 … … 391 345 end += sizeof( STARTMK ); 392 346 code << str.substr( start, end - start ); 393 347 394 348 code << "\t" << BYMK << endl; 395 code << "\tstatic const int costMatrix[ BasicType::NUMBER_OF_BASIC_TYPES][BasicType::NUMBER_OF_BASIC_TYPES] = { // path length from root to node" << endl349 code << "\tstatic const int costMatrix[ast::BasicType::NUMBER_OF_BASIC_TYPES][ast::BasicType::NUMBER_OF_BASIC_TYPES] = { // path length from root to node" << endl 396 350 << "\t\t/* "; 397 351 for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) { // titles … … 411 365 code << "\tstatic const int maxIntCost = " << *max_element(costMatrix[SignedInt], costMatrix[SignedInt] + NUMBER_OF_BASIC_TYPES) << ";" << endl; 412 366 code << "\t"; // indentation for end marker 413 367 414 368 if ( (start = str.find( ENDMK, start + 1 )) == string::npos ) Abort( "end", ConversionCost ); 415 369 if ( (end = str.find( STARTMK, start + 1 )) == string::npos ) Abort( "start", ConversionCost ); … … 418 372 419 373 code << "\t" << BYMK << endl; 420 code << "\tstatic const int signMatrix[ BasicType::NUMBER_OF_BASIC_TYPES][BasicType::NUMBER_OF_BASIC_TYPES] = { // number of sign changes in safe conversion" << endl374 code << "\tstatic const int signMatrix[ast::BasicType::NUMBER_OF_BASIC_TYPES][ast::BasicType::NUMBER_OF_BASIC_TYPES] = { // number of sign changes in safe conversion" << endl 421 375 << "\t\t/* "; 422 376 for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) { // titles … … 450 404 enum { PER_ROW = 6 }; 451 405 code << "\t" << BYMK << endl; 452 code << "\t#define BT BasicType::" << endl;453 code << "\tstatic const B asicType::Kind commonTypes[BasicType::NUMBER_OF_BASIC_TYPES][BasicType::NUMBER_OF_BASIC_TYPES] = { // nearest common ancestor" << endl406 code << "\t#define BT ast::BasicType::" << endl; 407 code << "\tstatic const BT Kind commonTypes[BT NUMBER_OF_BASIC_TYPES][BT NUMBER_OF_BASIC_TYPES] = { // nearest common ancestor" << endl 454 408 << "\t\t/*\t\t "; 455 409 for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) { // titles … … 505 459 "\t\t\t// - \"Di\" char32_t\n" 506 460 "\t\t\t// - \"Ds\" char16_t\n"; 507 508 code << "\t\t\tconst std::string basicTypes[ BasicType::NUMBER_OF_BASIC_TYPES] = {" << endl;461 462 code << "\t\t\tconst std::string basicTypes[ast::BasicType::NUMBER_OF_BASIC_TYPES] = {" << endl; 509 463 for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) { 510 464 code << "\t\t\t\t\"" << graph[r].mangled << "\"," << setw(9 - strlen(graph[r].mangled)) << ' ' << "// " << graph[r].type << endl; 511 } // for 465 } // for 512 466 code << "\t\t\t}; // basicTypes" << endl; 513 467 code << "\t\t\t"; // indentation for end marker
Note:
See TracChangeset
for help on using the changeset viewer.