Changeset bb0f974 for src/CodeTools
- Timestamp:
- Sep 28, 2018, 5:34:42 PM (6 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- d0bacde
- Parents:
- 096a2ff
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeTools/ResolvProtoDump.cc
r096a2ff rbb0f974 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 types 207 if ( name == "char16_t" || name == "char32_t" || name == "wchar_t" ) { 208 ss << "#" << name; 209 return; 210 } 211 212 // strip leading underscore 206 213 unsigned i = 0; 207 214 while ( i < name.size() && name[i] == '_' ) { ++i; } … … 210 217 return; 211 218 } 212 ss << (char)std::toupper( static_cast<unsigned char>(name[i]) ) 213 << (name.c_str() + i + 1); 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); 214 231 } 215 232 … … 397 414 } 398 415 416 /// Handle already-resolved variables as type constants 417 void previsit( VariableExpr* expr ) { 418 PassVisitor<TypePrinter> tyPrinter{ closed, ss }; 419 expr->var->get_type()->accept( tyPrinter ); 420 visit_children = false; 421 } 422 399 423 /// Calls handled as calls 400 424 void previsit( UntypedExpr* expr ) { … … 426 450 } 427 451 428 /// Already-resolved calls skipped 429 void previsit( ApplicationExpr* ) { 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 ); 430 456 visit_children = false; 431 457 } … … 532 558 for ( Initializer* it : li->initializers ) { 533 559 build( it, ss ); 534 ss << ' ';535 560 } 536 561 } … … 539 564 /// Adds an object initializer to the list of expressions 540 565 void build( const std::string& name, Initializer* init, std::stringstream& ss ) { 541 ss << "$constructor( ";566 ss << "$constructor( &"; 542 567 rp_name( name, ss ); 543 ss << "() ";568 ss << ' '; 544 569 build( init, ss ); 545 570 ss << ')'; … … 676 701 } 677 702 703 void previsit( AsmStmt* ) { 704 // skip asm statements 705 visit_children = false; 706 } 707 678 708 void previsit( Expression* expr ) { 679 709 std::stringstream ss; … … 686 716 /// Print non-prelude global declarations for resolv proto 687 717 void printGlobals() const { 688 std::cout << "# ptr<T> $addr T" << std::endl; // &?718 std::cout << "#$ptr<T> $addr T" << std::endl; // &? 689 719 int i = (int)BasicType::SignedInt; 690 720 std::cout << i << " $and " << i << ' ' << i << std::endl; // ?&&?
Note: See TracChangeset
for help on using the changeset viewer.