- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeTools/ResolvProtoDump.cc
r04bdc26 r4c42a5f 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 … … 321 304 } 322 305 323 // TODO support variable args for functions 324 void previsit( VarArgsType* ) { 325 // only include varargs for top level (argument type) 326 if ( depth == 0 ) { ss << "#$varargs"; } 327 } 306 // TODO support VarArgsType 328 307 329 308 // replace 0 and 1 with int … … 418 397 } 419 398 420 /// Handle already-resolved variables as type constants421 void previsit( VariableExpr* expr ) {422 PassVisitor<TypePrinter> tyPrinter{ closed, ss };423 expr->var->get_type()->accept( tyPrinter );424 visit_children = false;425 }426 427 399 /// Calls handled as calls 428 400 void previsit( UntypedExpr* expr ) { … … 454 426 } 455 427 456 /// Already-resolved calls reduced to their type constant 457 void previsit( ApplicationExpr* expr ) { 458 PassVisitor<TypePrinter> tyPrinter{ closed, ss }; 459 expr->result->accept( tyPrinter ); 428 /// Already-resolved calls skipped 429 void previsit( ApplicationExpr* ) { 460 430 visit_children = false; 461 431 } … … 562 532 for ( Initializer* it : li->initializers ) { 563 533 build( it, ss ); 534 ss << ' '; 564 535 } 565 536 } … … 568 539 /// Adds an object initializer to the list of expressions 569 540 void build( const std::string& name, Initializer* init, std::stringstream& ss ) { 570 ss << "$constructor( &";541 ss << "$constructor( "; 571 542 rp_name( name, ss ); 572 ss << ' ';543 ss << "() "; 573 544 build( init, ss ); 574 545 ss << ')'; … … 705 676 } 706 677 707 void previsit( AsmStmt* ) {708 // skip asm statements709 visit_children = false;710 }711 712 678 void previsit( Expression* expr ) { 713 679 std::stringstream ss; … … 720 686 /// Print non-prelude global declarations for resolv proto 721 687 void printGlobals() const { 722 std::cout << "# $ptr<T> $addr T" << std::endl; // &?688 std::cout << "#ptr<T> $addr T" << std::endl; // &? 723 689 int i = (int)BasicType::SignedInt; 724 690 std::cout << i << " $and " << i << ' ' << i << std::endl; // ?&&?
Note: See TracChangeset
for help on using the changeset viewer.