- Timestamp:
- Dec 10, 2019, 4:24:49 PM (6 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:
- 2a3d446
- Parents:
- b798713 (diff), e307e12 (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:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Concurrency/Keywords.cc
rb798713 rf80f840 309 309 if( !type_decl ) SemanticError( cast, context_error ); 310 310 if( !dtor_decl ) SemanticError( cast, context_error ); 311 Expression * arg = cast->arg; 312 cast->arg = nullptr; 313 delete cast; 314 return new CastExpr( 315 UntypedExpr::createDeref( 316 new UntypedExpr( new NameExpr( getter_name ), { arg } ) 317 ), 318 new ReferenceType( 319 noQualifiers, 320 new StructInstType( noQualifiers, type_decl ) ) 321 ); 311 assert( cast->result == nullptr ); 312 cast->set_result( new ReferenceType( noQualifiers, new StructInstType( noQualifiers, type_decl ) ) ); 313 cast->concrete_target.field = field_name; 314 cast->concrete_target.getter = getter_name; 322 315 } 323 316 return cast; -
src/Parser/parser.yy
rb798713 rf80f840 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : S un Aug 4 21:48:23201913 // Update Count : 43 6412 // Last Modified On : Sat Dec 7 10:43:44 2019 13 // Update Count : 4394 14 14 // 15 15 … … 211 211 } // forCtrl 212 212 213 KeywordCastExpr::Target Aggregate2Target( DeclarationNode::Aggregate aggr ) { 214 KeywordCastExpr::Target target; 215 switch ( aggr ) { 216 case DeclarationNode::Coroutine: target = KeywordCastExpr::Coroutine; break; 217 case DeclarationNode::Monitor: target = KeywordCastExpr::Monitor; break; 218 case DeclarationNode::Thread: target = KeywordCastExpr::Thread; break; 219 default: abort(); 220 } // switch 221 return target; 222 } // Aggregate2Target 223 213 224 214 225 bool forall = false, yyy = false; // aggregate have one or more forall qualifiers ? … … 365 376 %type<decl> abstract_parameter_declaration 366 377 367 %type<aggKey> aggregate_key 378 %type<aggKey> aggregate_key aggregate_data aggregate_control 368 379 %type<decl> aggregate_type aggregate_type_nobody 369 380 … … 650 661 | postfix_expression '.' '[' field_name_list ']' // CFA, tuple field selector 651 662 { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $4 ) ) ); } 663 | postfix_expression '.' aggregate_control 664 { $$ = new ExpressionNode( build_keyword_cast( Aggregate2Target( $3 ), $1 ) ); } 652 665 | postfix_expression ARROW identifier 653 666 { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); } … … 793 806 | '(' type_no_function ')' cast_expression 794 807 { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 795 // keyword cast cannot be grouped because of reduction in aggregate_key 796 | '(' GENERATOR '&' ')' cast_expression // CFA 797 { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Coroutine, $5 ) ); } 798 | '(' COROUTINE '&' ')' cast_expression // CFA 799 { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Coroutine, $5 ) ); } 800 | '(' THREAD '&' ')' cast_expression // CFA 801 { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Thread, $5 ) ); } 802 | '(' MONITOR '&' ')' cast_expression // CFA 803 { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Monitor, $5 ) ); } 808 | '(' aggregate_control '&' ')' cast_expression // CFA 809 { $$ = new ExpressionNode( build_keyword_cast( Aggregate2Target( $2 ), $5 ) ); } 804 810 // VIRTUAL cannot be opt because of look ahead issues 805 811 | '(' VIRTUAL ')' cast_expression // CFA … … 2059 2065 2060 2066 aggregate_key: 2067 aggregate_data 2068 | aggregate_control 2069 ; 2070 2071 aggregate_data: 2061 2072 STRUCT 2062 2073 { yyy = true; $$ = DeclarationNode::Struct; } 2063 2074 | UNION 2064 2075 { yyy = true; $$ = DeclarationNode::Union; } 2065 | EXCEPTION 2076 | EXCEPTION // CFA 2066 2077 { yyy = true; $$ = DeclarationNode::Exception; } 2067 | GENERATOR 2078 ; 2079 2080 aggregate_control: // CFA 2081 GENERATOR 2068 2082 { yyy = true; $$ = DeclarationNode::Coroutine; } 2069 2083 | COROUTINE … … 2096 2110 distInl( $3 ); 2097 2111 } 2112 | INLINE aggregate_control ';' // CFA 2113 { SemanticError( yylloc, "INLINE aggregate control currently unimplemented." ); $$ = nullptr; } 2098 2114 | typedef_declaration ';' // CFA 2099 2115 | cfa_field_declaring_list ';' // CFA, new style field declaration -
src/ResolvExpr/AlternativeFinder.cc
rb798713 rf80f840 69 69 void postvisit( CastExpr * castExpr ); 70 70 void postvisit( VirtualCastExpr * castExpr ); 71 void postvisit( KeywordCastExpr * castExpr ); 71 72 void postvisit( UntypedMemberExpr * memberExpr ); 72 73 void postvisit( MemberExpr * memberExpr ); … … 1255 1256 } 1256 1257 1258 void AlternativeFinder::Finder::postvisit( KeywordCastExpr * castExpr ) { 1259 assertf( castExpr->get_result(), "Cast target should have been set in Validate." ); 1260 auto ref = dynamic_cast<ReferenceType*>(castExpr->get_result()); 1261 assert(ref); 1262 auto inst = dynamic_cast<StructInstType*>(ref->base); 1263 assert(inst); 1264 auto target = inst->baseStruct; 1265 1266 AlternativeFinder finder( indexer, env ); 1267 1268 auto pick_alternatives = [target, this](AltList & found, bool expect_ref) { 1269 for(auto & alt : found) { 1270 Type * expr = alt.expr->get_result(); 1271 if(expect_ref) { 1272 auto res = dynamic_cast<ReferenceType*>(expr); 1273 if(!res) { continue; } 1274 expr = res->base; 1275 } 1276 1277 if(auto insttype = dynamic_cast<TypeInstType*>(expr)) { 1278 auto td = alt.env.lookup(insttype->name); 1279 if(!td) { continue; } 1280 expr = td->type; 1281 } 1282 1283 if(auto base = dynamic_cast<StructInstType*>(expr)) { 1284 if(base->baseStruct == target) { 1285 alternatives.push_back( 1286 std::move(alt) 1287 ); 1288 } 1289 } 1290 } 1291 }; 1292 1293 try { 1294 // Attempt 1 : turn (thread&)X into (thread_desc&)X.__thrd 1295 // Clone is purely for memory management 1296 std::unique_ptr<Expression> tech1 { new UntypedMemberExpr(new NameExpr(castExpr->concrete_target.field), castExpr->arg->clone()) }; 1297 1298 // don't prune here, since it's guaranteed all alternatives will have the same type 1299 finder.findWithoutPrune( tech1.get() ); 1300 pick_alternatives(finder.alternatives, false); 1301 1302 return; 1303 } catch(SemanticErrorException & ) {} 1304 1305 // Fallback : turn (thread&)X into (thread_desc&)get_thread(X) 1306 std::unique_ptr<Expression> fallback { UntypedExpr::createDeref( new UntypedExpr(new NameExpr(castExpr->concrete_target.getter), { castExpr->arg->clone() })) }; 1307 // don't prune here, since it's guaranteed all alternatives will have the same type 1308 finder.findWithoutPrune( fallback.get() ); 1309 1310 pick_alternatives(finder.alternatives, true); 1311 1312 // Whatever happens here, we have no more fallbacks 1313 } 1314 1257 1315 namespace { 1258 1316 /// Gets name from untyped member expression (member must be NameExpr) -
src/SynTree/Expression.h
rb798713 rf80f840 231 231 enum Target { 232 232 Coroutine, Thread, Monitor, NUMBER_OF_TARGETS 233 } target; 233 }; 234 struct Concrete { 235 std::string field; 236 std::string getter; 237 }; 238 Target target; 239 Concrete concrete_target; 234 240 235 241 KeywordCastExpr( Expression * arg, Target target ); -
src/cfa.make
rb798713 rf80f840 4 4 LTCFACOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ 5 5 $(LIBTOOLFLAGS) --mode=compile $(CFACC) $(DEFS) \ 6 $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(CFAFLAGS) \ 7 $(AM_CFLAGS) $(CFLAGS) 6 $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(AM_CFLAGS) $(CFAFLAGS) $(CFLAGS) 8 7 9 8 AM_V_CFA = $(am__v_CFA_@AM_V@)
Note:
See TracChangeset
for help on using the changeset viewer.