Changes in / [d0bacde:6c89ecc]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeTools/ResolvProtoDump.cc
rd0bacde r6c89ecc 204 204 /// ensures type inst names are uppercase 205 205 static void ti_name( const std::string& name, std::stringstream& ss ) { 206 // replace built-in wide character types with named types207 if ( name == "char16_t" || name == "char32_t" || name == "wchar_t" ) {208 ss << "#" << name;209 return;210 }211 212 // strip leading underscore213 206 unsigned i = 0; 214 207 while ( i < name.size() && name[i] == '_' ) { ++i; } … … 217 210 return; 218 211 } 219 220 std::string stripped = name.substr(i); 221 // strip trailing "_generic_" from autogen names (avoids some user-generation issues) 222 char generic[] = "_generic_"; size_t n_generic = sizeof(generic) - 1; 223 if ( stripped.size() >= n_generic 224 && stripped.substr( stripped.size() - n_generic ) == generic ) { 225 stripped.resize( stripped.size() - n_generic ); 226 } 227 228 // uppercase first character 229 ss << (char)std::toupper( static_cast<unsigned char>(stripped[0]) ) 230 << (stripped.c_str() + 1); 212 ss << (char)std::toupper( static_cast<unsigned char>(name[i]) ) 213 << (name.c_str() + i + 1); 231 214 } 232 215 … … 414 397 } 415 398 416 /// Handle already-resolved variables as type constants417 void previsit( VariableExpr* expr ) {418 PassVisitor<TypePrinter> tyPrinter{ closed, ss };419 expr->var->get_type()->accept( tyPrinter );420 visit_children = false;421 }422 423 399 /// Calls handled as calls 424 400 void previsit( UntypedExpr* expr ) { … … 450 426 } 451 427 452 /// Already-resolved calls reduced to their type constant 453 void previsit( ApplicationExpr* expr ) { 454 PassVisitor<TypePrinter> tyPrinter{ closed, ss }; 455 expr->result->accept( tyPrinter ); 428 /// Already-resolved calls skipped 429 void previsit( ApplicationExpr* ) { 456 430 visit_children = false; 457 431 } … … 558 532 for ( Initializer* it : li->initializers ) { 559 533 build( it, ss ); 534 ss << ' '; 560 535 } 561 536 } … … 564 539 /// Adds an object initializer to the list of expressions 565 540 void build( const std::string& name, Initializer* init, std::stringstream& ss ) { 566 ss << "$constructor( &";541 ss << "$constructor( "; 567 542 rp_name( name, ss ); 568 ss << ' ';543 ss << "() "; 569 544 build( init, ss ); 570 545 ss << ')'; … … 701 676 } 702 677 703 void previsit( AsmStmt* ) {704 // skip asm statements705 visit_children = false;706 }707 708 678 void previsit( Expression* expr ) { 709 679 std::stringstream ss; … … 716 686 /// Print non-prelude global declarations for resolv proto 717 687 void printGlobals() const { 718 std::cout << "# $ptr<T> $addr T" << std::endl; // &?688 std::cout << "#ptr<T> $addr T" << std::endl; // &? 719 689 int i = (int)BasicType::SignedInt; 720 690 std::cout << i << " $and " << i << ' ' << i << std::endl; // ?&&?
Note: See TracChangeset
for help on using the changeset viewer.