Changeset f80f840 for src


Ignore:
Timestamp:
Dec 10, 2019, 4:24:49 PM (6 years ago)
Author:
Thierry Delisle <tdelisle@…>
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.
Message:

Merge branch 'master' into relaxed_ready

Location:
src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/Concurrency/Keywords.cc

    rb798713 rf80f840  
    309309                        if( !type_decl ) SemanticError( cast, context_error );
    310310                        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;
    322315                }
    323316                return cast;
  • src/Parser/parser.yy

    rb798713 rf80f840  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Aug  4 21:48:23 2019
    13 // Update Count     : 4364
     12// Last Modified On : Sat Dec  7 10:43:44 2019
     13// Update Count     : 4394
    1414//
    1515
     
    211211} // forCtrl
    212212
     213KeywordCastExpr::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
    213224
    214225bool forall = false, yyy = false;                                               // aggregate have one or more forall qualifiers ?
     
    365376%type<decl> abstract_parameter_declaration
    366377
    367 %type<aggKey> aggregate_key
     378%type<aggKey> aggregate_key aggregate_data aggregate_control
    368379%type<decl> aggregate_type aggregate_type_nobody
    369380
     
    650661        | postfix_expression '.' '[' field_name_list ']'        // CFA, tuple field selector
    651662                { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $4 ) ) ); }
     663        | postfix_expression '.' aggregate_control
     664                { $$ = new ExpressionNode( build_keyword_cast( Aggregate2Target( $3 ), $1 ) ); }
    652665        | postfix_expression ARROW identifier
    653666                { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); }
     
    793806        | '(' type_no_function ')' cast_expression
    794807                { $$ = 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 ) ); }
    804810                // VIRTUAL cannot be opt because of look ahead issues
    805811        | '(' VIRTUAL ')' cast_expression                                       // CFA
     
    20592065
    20602066aggregate_key:
     2067        aggregate_data
     2068        | aggregate_control
     2069        ;
     2070
     2071aggregate_data:
    20612072        STRUCT
    20622073                { yyy = true; $$ = DeclarationNode::Struct; }
    20632074        | UNION
    20642075                { yyy = true; $$ = DeclarationNode::Union; }
    2065         | EXCEPTION
     2076        | EXCEPTION                                                                                     // CFA
    20662077                { yyy = true; $$ = DeclarationNode::Exception; }
    2067         | GENERATOR
     2078        ;
     2079
     2080aggregate_control:                                                                              // CFA
     2081        GENERATOR
    20682082                { yyy = true; $$ = DeclarationNode::Coroutine; }
    20692083        | COROUTINE
     
    20962110                        distInl( $3 );
    20972111                }
     2112        | INLINE aggregate_control ';'                                          // CFA
     2113                { SemanticError( yylloc, "INLINE aggregate control currently unimplemented." ); $$ = nullptr; }
    20982114        | typedef_declaration ';'                                                       // CFA
    20992115        | cfa_field_declaring_list ';'                                          // CFA, new style field declaration
  • src/ResolvExpr/AlternativeFinder.cc

    rb798713 rf80f840  
    6969                void postvisit( CastExpr * castExpr );
    7070                void postvisit( VirtualCastExpr * castExpr );
     71                void postvisit( KeywordCastExpr * castExpr );
    7172                void postvisit( UntypedMemberExpr * memberExpr );
    7273                void postvisit( MemberExpr * memberExpr );
     
    12551256        }
    12561257
     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
    12571315        namespace {
    12581316                /// Gets name from untyped member expression (member must be NameExpr)
  • src/SynTree/Expression.h

    rb798713 rf80f840  
    231231        enum Target {
    232232                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;
    234240
    235241        KeywordCastExpr( Expression * arg, Target target );
  • src/cfa.make

    rb798713 rf80f840  
    44LTCFACOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
    55        $(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)
    87
    98AM_V_CFA = $(am__v_CFA_@AM_V@)
Note: See TracChangeset for help on using the changeset viewer.