- Timestamp:
- Oct 11, 2018, 2:48:06 PM (7 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:
- 90cfc16, 9507ce3
- Parents:
- 2b3d6ff (diff), 7b61ce8 (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. - Location:
- src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeTools/ResolvProtoDump.cc
r2b3d6ff r1f690b3 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; // ?&&? -
src/SynTree/Constant.cc
r2b3d6ff r1f690b3 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Jul 14 14:50:00 201713 // Update Count : 2912 // Last Modified On : Fri Spt 28 14:49:00 2018 13 // Update Count : 30 14 14 // 15 15 … … 19 19 20 20 #include "Constant.h" 21 #include "Expression.h" // for ConstantExpr 21 22 #include "Type.h" // for BasicType, Type, Type::Qualifiers, PointerType 22 23 … … 48 49 Constant Constant::from_double( double d ) { 49 50 return Constant( new BasicType( Type::Qualifiers(), BasicType::Double ), std::to_string( d ), d ); 51 } 52 53 Constant Constant::from_string( std::string const & str ) { 54 return Constant( 55 new ArrayType( 56 noQualifiers, 57 new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ), 58 new ConstantExpr( Constant::from_int( str.size() + 1 /* \0 */ )), 59 false, false ), 60 std::string("\"") + str + "\"", (unsigned long long int)0 ); 50 61 } 51 62 -
src/SynTree/Constant.h
r2b3d6ff r1f690b3 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Sat Jul 22 09:54:46 201713 // Update Count : 1 711 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Spt 28 14:48:00 2018 13 // Update Count : 18 14 14 // 15 15 … … 51 51 /// generates a floating point constant of the given double 52 52 static Constant from_double( double d ); 53 /// generates an array of chars constant of the given string 54 static Constant from_string( std::string const & s ); 53 55 54 56 /// generates a null pointer value for the given type. void * if omitted.
Note:
See TracChangeset
for help on using the changeset viewer.