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