- Timestamp:
- Aug 3, 2020, 2:23:17 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 1a39a5a
- Parents:
- 3e2b9c9 (diff), 6dba8755 (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:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Common/ScopedMap.h
r3e2b9c9 r95789be 93 93 94 94 reference operator* () { return *it; } 95 pointer operator-> () { return it.operator->(); }95 pointer operator-> () const { return it.operator->(); } 96 96 97 97 iterator& operator++ () { -
src/Concurrency/Keywords.cc
r3e2b9c9 r95789be 510 510 new CastExpr( 511 511 new VariableExpr( func->get_functionType()->get_parameters().front() ), 512 func->get_functionType()->get_parameters().front()->get_type()->stripReferences()->clone() 512 func->get_functionType()->get_parameters().front()->get_type()->stripReferences()->clone(), 513 false 513 514 ) 514 515 ) … … 888 889 new SingleInit( new UntypedExpr( 889 890 new NameExpr( "get_monitor" ), 890 { new CastExpr( new VariableExpr( args.front() ), arg_type ) }891 { new CastExpr( new VariableExpr( args.front() ), arg_type, false ) } 891 892 )) 892 893 ); … … 909 910 { 910 911 new SingleInit( new AddressExpr( new VariableExpr( monitors ) ) ), 911 new SingleInit( new CastExpr( new VariableExpr( func ), generic_func->clone() ) )912 new SingleInit( new CastExpr( new VariableExpr( func ), generic_func->clone(), false ) ) 912 913 }, 913 914 noDesignators, … … 946 947 return new SingleInit( new UntypedExpr( 947 948 new NameExpr( "get_monitor" ), 948 { new CastExpr( new VariableExpr( var ), type ) }949 { new CastExpr( new VariableExpr( var ), type, false ) } 949 950 ) ); 950 951 }) … … 970 971 new SingleInit( new VariableExpr( monitors ) ), 971 972 new SingleInit( new ConstantExpr( Constant::from_ulong( args.size() ) ) ), 972 new SingleInit( new CastExpr( new VariableExpr( func ), generic_func->clone() ) )973 new SingleInit( new CastExpr( new VariableExpr( func ), generic_func->clone(), false ) ) 973 974 }, 974 975 noDesignators, -
src/Concurrency/Waitfor.cc
r3e2b9c9 r95789be 384 384 decl_monitor 385 385 ) 386 ) 386 ), 387 false 387 388 ); 388 389 … … 408 409 new CompoundStmt({ 409 410 makeAccStatement( acceptables, index, "is_dtor", detectIsDtor( clause.target.function ) , indexer ), 410 makeAccStatement( acceptables, index, "func" , new CastExpr( clause.target.function, fptr_t ), indexer ),411 makeAccStatement( acceptables, index, "func" , new CastExpr( clause.target.function, fptr_t, false ) , indexer ), 411 412 makeAccStatement( acceptables, index, "data" , new VariableExpr( monitors ) , indexer ), 412 413 makeAccStatement( acceptables, index, "size" , new ConstantExpr( Constant::from_ulong( clause.target.arguments.size() ) ), indexer ), … … 531 532 decl_mask 532 533 ) 533 ) 534 ), 535 false 534 536 ), 535 537 timeout -
src/Parser/ExpressionNode.cc
r3e2b9c9 r95789be 427 427 if ( str[1] == '8' ) goto Default; // utf-8 characters => array of char 428 428 // lookup type of associated typedef 429 strtype = new TypeInstType( Type::Qualifiers( Type::Const), "char16_t", false );429 strtype = new TypeInstType( Type::Qualifiers( ), "char16_t", false ); 430 430 break; 431 431 case 'U': 432 strtype = new TypeInstType( Type::Qualifiers( Type::Const), "char32_t", false );432 strtype = new TypeInstType( Type::Qualifiers( ), "char32_t", false ); 433 433 break; 434 434 case 'L': 435 strtype = new TypeInstType( Type::Qualifiers( Type::Const), "wchar_t", false );435 strtype = new TypeInstType( Type::Qualifiers( ), "wchar_t", false ); 436 436 break; 437 437 Default: // char default string type 438 438 default: 439 strtype = new BasicType( Type::Qualifiers( Type::Const), BasicType::Char );439 strtype = new BasicType( Type::Qualifiers( ), BasicType::Char ); 440 440 } // switch 441 441 ArrayType * at = new ArrayType( noQualifiers, strtype, -
src/ResolvExpr/AlternativeFinder.cc
r3e2b9c9 r95789be 1216 1216 unify( castExpr->result, alt.expr->result, alt.env, needAssertions, 1217 1217 haveAssertions, openVars, indexer ); 1218 Cost thisCost = castCost( alt.expr->result, castExpr->result, alt.expr->get_lvalue(), 1219 indexer, alt.env ); 1218 Cost thisCost = 1219 castExpr->isGenerated 1220 ? conversionCost( alt.expr->result, castExpr->result, alt.expr->get_lvalue(), indexer, alt.env ) 1221 : castCost( alt.expr->result, castExpr->result, alt.expr->get_lvalue(), indexer, alt.env ); 1220 1222 PRINT( 1221 1223 std::cerr << "working on cast with result: " << castExpr->result << std::endl; … … 1698 1700 1699 1701 // unification run for side-effects 1700 unify( toType, alt.expr->result, newEnv, need, have, openVars, indexer ); 1702 bool canUnify = unify( toType, alt.expr->result, newEnv, need, have, openVars, indexer ); 1703 (void) canUnify; 1701 1704 // xxx - do some inspecting on this line... why isn't result bound to initAlt.type? 1702 1705 1703 Cost thisCost = c astCost( alt.expr->result, toType, alt.expr->get_lvalue(),1706 Cost thisCost = computeConversionCost( alt.expr->result, toType, alt.expr->get_lvalue(), 1704 1707 indexer, newEnv ); 1708 1709 PRINT( 1710 Cost legacyCost = castCost( alt.expr->result, toType, alt.expr->get_lvalue(), 1711 indexer, newEnv ); 1712 std::cerr << "Considering initialization:"; 1713 std::cerr << std::endl << " FROM: "; alt.expr->result->print(std::cerr); 1714 std::cerr << std::endl << " TO: "; toType ->print(std::cerr); 1715 std::cerr << std::endl << " Unification " << (canUnify ? "succeeded" : "failed"); 1716 std::cerr << std::endl << " Legacy cost " << legacyCost; 1717 std::cerr << std::endl << " New cost " << thisCost; 1718 std::cerr << std::endl; 1719 ) 1720 1705 1721 if ( thisCost != Cost::infinity ) { 1706 1722 // count one safe conversion for each value that is thrown away -
src/ResolvExpr/ConversionCost.cc
r3e2b9c9 r95789be 10 10 // Created On : Sun May 17 07:06:19 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Mon Aug 12 10:21:00 201913 // Update Count : 2 712 // Last Modified On : Wed Jul 29 16:11:00 2020 13 // Update Count : 28 14 14 // 15 15 … … 392 392 void ConversionCost::postvisit( const FunctionType * ) {} 393 393 394 void ConversionCost::postvisit( const StructInstType * inst ) {395 if ( const StructInstType * destAsInst = dynamic_cast< const StructInstType * >( dest ) ) {396 if ( inst->name == destAsInst->name ) {397 cost = Cost::zero;398 } // if399 } // if400 }401 402 void ConversionCost::postvisit( const UnionInstType * inst ) {403 if ( const UnionInstType * destAsInst = dynamic_cast< const UnionInstType * >( dest ) ) {404 if ( inst->name == destAsInst->name ) {405 cost = Cost::zero;406 } // if407 } // if408 }409 410 394 void ConversionCost::postvisit( const EnumInstType * ) { 411 395 static Type::Qualifiers q; … … 681 665 } 682 666 683 void ConversionCost_new::postvisit( const ast::StructInstType * structInstType ) {684 if ( const ast::StructInstType * dstAsInst =685 dynamic_cast< const ast::StructInstType * >( dst ) ) {686 if ( structInstType->name == dstAsInst->name ) {687 cost = Cost::zero;688 }689 }690 }691 692 void ConversionCost_new::postvisit( const ast::UnionInstType * unionInstType ) {693 if ( const ast::UnionInstType * dstAsInst =694 dynamic_cast< const ast::UnionInstType * >( dst ) ) {695 if ( unionInstType->name == dstAsInst->name ) {696 cost = Cost::zero;697 }698 }699 }700 701 667 void ConversionCost_new::postvisit( const ast::EnumInstType * enumInstType ) { 702 668 (void)enumInstType; -
src/ResolvExpr/ConversionCost.h
r3e2b9c9 r95789be 10 10 // Created On : Sun May 17 09:37:28 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu Aug 8 16:13:00 201913 // Update Count : 612 // Last Modified On : Wed Jul 29 16:12:00 2020 13 // Update Count : 7 14 14 // 15 15 … … 51 51 void postvisit( const ReferenceType * refType ); 52 52 void postvisit( const FunctionType * functionType ); 53 void postvisit( const StructInstType * aggregateUseType );54 void postvisit( const UnionInstType * aggregateUseType );55 53 void postvisit( const EnumInstType * aggregateUseType ); 56 54 void postvisit( const TraitInstType * aggregateUseType ); … … 102 100 void postvisit( const ast::ReferenceType * refType ); 103 101 void postvisit( const ast::FunctionType * functionType ); 104 void postvisit( const ast::StructInstType * structInstType );105 void postvisit( const ast::UnionInstType * unionInstType );106 102 void postvisit( const ast::EnumInstType * enumInstType ); 107 103 void postvisit( const ast::TraitInstType * traitInstType ); -
src/SynTree/Expression.h
r3e2b9c9 r95789be 206 206 public: 207 207 Expression * arg; 208 bool isGenerated = true; // cast generated implicitly by code generation or explicit in program 208 209 // Inidicates cast is introduced by the CFA type system. 210 // true for casts that the resolver introduces to force a return type 211 // false for casts from user code 212 // false for casts from desugaring advanced CFA features into simpler CFA 213 // example 214 // int * p; // declaration 215 // (float *) p; // use, with subject cast 216 // subject cast isGenerated means we are considering an interpretation with a type mismatch 217 // subject cast not isGenerated means someone in charge wants it that way 218 bool isGenerated = true; 209 219 210 220 CastExpr( Expression * arg, bool isGenerated = true ); -
src/Virtual/ExpandCasts.cc
r3e2b9c9 r95789be 10 10 // Created On : Mon Jul 24 13:59:00 2017 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Tue Jul 22 10:04:00 202013 // Update Count : 312 // Last Modified On : Fri Jul 31 10:29:00 2020 13 // Update Count : 4 14 14 // 15 15 … … 18 18 #include <cassert> // for assert, assertf 19 19 #include <iterator> // for back_inserter, inserter 20 #include <map> // for map, _Rb_tree_iterator, map<>::ite...21 20 #include <string> // for string, allocator, operator==, ope... 22 #include <utility> // for pair23 21 24 22 #include "Common/PassVisitor.h" // for PassVisitor 23 #include "Common/ScopedMap.h" // for ScopedMap 25 24 #include "Common/SemanticError.h" // for SemanticError 26 25 #include "SymTab/Mangler.h" // for mangleType … … 37 36 /// Maps virtual table types the instance for that type. 38 37 class VirtualTableMap final { 39 std::unordered_map<std::string, ObjectDecl *> vtable_instances;38 ScopedMap<std::string, ObjectDecl *> vtable_instances; 40 39 public: 40 void enterScope() { 41 vtable_instances.beginScope(); 42 } 43 void leaveScope() { 44 vtable_instances.endScope(); 45 } 46 41 47 ObjectDecl * insert( ObjectDecl * vtableDecl ) { 42 48 std::string const & mangledName = SymTab::Mangler::mangleType( vtableDecl->type ); … … 93 99 94 100 class VirtualCastCore { 95 VirtualTableMap vtable_instances;96 FunctionDecl *vcast_decl;97 StructDecl *pvt_decl;98 99 101 Type * pointer_to_pvt(int level_of_indirection) { 100 102 Type * type = new StructInstType( … … 108 110 public: 109 111 VirtualCastCore() : 110 vtable_instances(), vcast_decl( nullptr ), pvt_decl( nullptr )112 indexer(), vcast_decl( nullptr ), pvt_decl( nullptr ) 111 113 {} 112 114 … … 116 118 117 119 Expression * postmutate( VirtualCastExpr * castExpr ); 120 121 VirtualTableMap indexer; 122 private: 123 FunctionDecl *vcast_decl; 124 StructDecl *pvt_decl; 118 125 }; 119 126 … … 135 142 void VirtualCastCore::premutate( ObjectDecl * objectDecl ) { 136 143 if ( is_vtable_inst_name( objectDecl->get_name() ) ) { 137 if ( ObjectDecl * existing = vtable_instances.insert( objectDecl ) ) {144 if ( ObjectDecl * existing = indexer.insert( objectDecl ) ) { 138 145 std::string msg = "Repeated instance of virtual table, original found at: "; 139 146 msg += existing->location.filename; … … 222 229 223 230 const Type * vtable_type = getVirtualTableType( castExpr ); 224 ObjectDecl * table = vtable_instances.lookup( vtable_type );231 ObjectDecl * table = indexer.lookup( vtable_type ); 225 232 if ( nullptr == table ) { 226 233 SemanticError( castLocation( castExpr ),
Note: See TracChangeset
for help on using the changeset viewer.