Changeset 69c5c00 for src/Concurrency


Ignore:
Timestamp:
Oct 7, 2020, 6:08:35 PM (3 years ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
6fbe9a5
Parents:
41b8ea4
Message:

Rework exceptions mark_exception -> get_exception_vtable and the needed follow up.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Concurrency/Keywords.cc

    r41b8ea4 r69c5c00  
    6666                        bool needs_main, AggregateDecl::Aggregate cast_target ) :
    6767                  type_name( type_name ), field_name( field_name ), getter_name( getter_name ),
    68                   context_error( context_error ), vtable_name( getVTableName( exception_name ) ),
     68                  context_error( context_error ), exception_name( exception_name ),
     69                  vtable_name( getVTableName( exception_name ) ),
    6970                  needs_main( needs_main ), cast_target( cast_target ) {}
    7071
     
    8990                const std::string getter_name;
    9091                const std::string context_error;
     92                const std::string exception_name;
    9193                const std::string vtable_name;
    9294                bool needs_main;
     
    9597                StructDecl   * type_decl = nullptr;
    9698                FunctionDecl * dtor_decl = nullptr;
     99                StructDecl * except_decl = nullptr;
    97100                StructDecl * vtable_decl = nullptr;
    98101        };
     
    376379                else if ( is_target(decl) ) {
    377380                        handle( decl );
     381                }
     382                else if ( !except_decl && exception_name == decl->name && decl->body ) {
     383                        except_decl = decl;
    378384                }
    379385                else if ( !vtable_decl && vtable_name == decl->name && decl->body ) {
     
    398404                        assert( struct_type );
    399405
    400                         declsToAddAfter.push_back( Virtual::makeVtableInstance( vtable_decl, {
    401                                 new TypeExpr( struct_type->clone() ),
    402                         }, struct_type, nullptr ) );
     406                        std::list< Expression * > poly_args = { new TypeExpr( struct_type->clone() ) };
     407                        ObjectDecl * vtable_object = Virtual::makeVtableInstance(
     408                                vtable_decl->makeInst( poly_args ), struct_type, nullptr );
     409                        declsToAddAfter.push_back( vtable_object );
     410                        declsToAddAfter.push_back( Virtual::makeGetExceptionFunction(
     411                                vtable_object, except_decl->makeInst( std::move( poly_args ) )
     412                        ) );
    403413                }
    404414
     
    434444        void ConcurrentSueKeyword::addVtableForward( StructDecl * decl ) {
    435445                if ( vtable_decl ) {
    436                         declsToAddBefore.push_back( Virtual::makeVtableForward( vtable_decl, {
     446                        std::list< Expression * > poly_args = {
    437447                                new TypeExpr( new StructInstType( noQualifiers, decl ) ),
    438                         } ) );
     448                        };
     449                        declsToAddBefore.push_back( Virtual::makeGetExceptionForward(
     450                                vtable_decl->makeInst( poly_args ),
     451                                except_decl->makeInst( poly_args )
     452                        ) );
     453                        declsToAddBefore.push_back( Virtual::makeVtableForward(
     454                                vtable_decl->makeInst( move( poly_args ) ) ) );
    439455                // Its only an error if we want a vtable and don't have one.
    440456                } else if ( ! vtable_name.empty() ) {
Note: See TracChangeset for help on using the changeset viewer.