Changes in src/Concurrency/Keywords.cc [3b0c8cb:2bf7ef6]
- File:
-
- 1 edited
-
src/Concurrency/Keywords.cc (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Concurrency/Keywords.cc
r3b0c8cb r2bf7ef6 59 59 60 60 Declaration * postmutate( StructDecl * decl ); 61 DeclarationWithType * postmutate( FunctionDecl * decl );62 61 63 62 void handle( StructDecl * ); … … 78 77 KeywordCastExpr::Target cast_target; 79 78 80 StructDecl * type_decl = nullptr; 81 FunctionDecl * dtor_decl = nullptr; 79 StructDecl* type_decl = nullptr; 82 80 }; 83 81 … … 99 97 "__thrd", 100 98 "get_thread", 101 "thread keyword requires threads to be in scope, add #include <thread.hfa> \n",99 "thread keyword requires threads to be in scope, add #include <thread.hfa>", 102 100 true, 103 101 KeywordCastExpr::Thread … … 131 129 "__cor", 132 130 "get_coroutine", 133 "coroutine keyword requires coroutines to be in scope, add #include <coroutine.hfa> \n",131 "coroutine keyword requires coroutines to be in scope, add #include <coroutine.hfa>", 134 132 true, 135 133 KeywordCastExpr::Coroutine … … 163 161 "__mon", 164 162 "get_monitor", 165 "monitor keyword requires monitors to be in scope, add #include <monitor.hfa> \n",163 "monitor keyword requires monitors to be in scope, add #include <monitor.hfa>", 166 164 false, 167 165 KeywordCastExpr::Monitor … … 286 284 } 287 285 288 DeclarationWithType * ConcurrentSueKeyword::postmutate( FunctionDecl * decl ) {289 if( !type_decl ) return decl;290 if( !CodeGen::isDestructor( decl->name ) ) return decl;291 292 auto params = decl->type->parameters;293 if( params.size() != 1 ) return decl;294 295 auto type = dynamic_cast<ReferenceType*>( params.front()->get_type() );296 if( !type ) return decl;297 298 auto stype = dynamic_cast<StructInstType*>( type->base );299 if( !stype ) return decl;300 if( stype->baseStruct != type_decl ) return decl;301 302 if( !dtor_decl ) dtor_decl = decl;303 return decl;304 }305 306 286 Expression * ConcurrentSueKeyword::postmutate( KeywordCastExpr * cast ) { 307 287 if ( cast_target == cast->target ) { 308 288 // convert (thread &)t to (thread_desc &)*get_thread(t), etc. 309 289 if( !type_decl ) SemanticError( cast, context_error ); 310 if( !dtor_decl ) SemanticError( cast, context_error ); 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; 290 Expression * arg = cast->arg; 291 cast->arg = nullptr; 292 delete cast; 293 return new CastExpr( 294 UntypedExpr::createDeref( 295 new UntypedExpr( new NameExpr( getter_name ), { arg } ) 296 ), 297 new ReferenceType( 298 noQualifiers, 299 new StructInstType( noQualifiers, type_decl ) ) 300 ); 315 301 } 316 302 return cast; … … 322 308 323 309 if( !type_decl ) SemanticError( decl, context_error ); 324 if( !dtor_decl ) SemanticError( decl, context_error );325 310 326 311 FunctionDecl * func = forwardDeclare( decl );
Note:
See TracChangeset
for help on using the changeset viewer.