Changeset cbce272 for src/Virtual


Ignore:
Timestamp:
Aug 9, 2017, 2:08:14 PM (7 years ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
65cdc1e
Parents:
e195093
Message:

Structure based exception handling.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Virtual/ExpandCasts.cc

    re195093 rcbce272  
    1010// Created On       : Mon Jul 24 13:59:00 2017
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Jul 26 14:16:00 2017
    13 // Update Count     : 0
     12// Last Modified On : Tus Aug  2 14:59:00 2017
     13// Update Count     : 1
    1414//
    1515
     
    7878
    7979        void VirtualCastCore::premutate( FunctionDecl * functionDecl ) {
    80                 if ( (! vcast_decl) && functionDecl->get_statements() &&
     80                if ( (! vcast_decl) &&
    8181                     functionDecl->get_name() == "__cfa__virtual_cast" ) {
    8282                        vcast_decl = functionDecl;
     
    101101                assertf( castExpr->get_result(), "Virtual Cast target not found before expansion." );
    102102
    103                 //assert( vcast_decl );
     103                assert( vcast_decl );
    104104                assert( pvt_decl );
    105105
    106106                // May only cast to a pointer or reference type.
    107107                // A earlier validation should give a syntax error, this is
    108                 // just to make sure errors don't creep in.
     108                // just to make sure errors don't creep during translation.
     109                // Move to helper with more detailed error messages.
    109110                PointerType * target_type =
    110111                        dynamic_cast<PointerType *>( castExpr->get_result() );
    111         assert( target_type );
     112                assert( target_type );
    112113
    113114                StructInstType * target_struct =
    114115                        dynamic_cast<StructInstType *>( target_type->get_base() );
     116                assert( target_struct );
     117
    115118                StructDecl * target_decl = target_struct->get_baseStruct();
    116119
     
    124127
    125128                Expression * result = new CastExpr(
    126                         //new ApplicationExpr( new VariableExpr( vcast_decl ), {
     129                        //new ApplicationExpr(
     130                                //new AddressExpr( new VariableExpr( vcast_decl ) ),
     131                                //new CastExpr( new VariableExpr( vcast_decl ),
     132                                //      new PointerType( noQualifiers,
     133                                //              vcast_decl->get_type()->clone()
     134                                //              )
     135                                //      ),
    127136                        new UntypedExpr( new NameExpr( "__cfa__virtual_cast" ), {
    128                                 new CastExpr(
    129                                         new AddressExpr( new VariableExpr( table ) ),
    130                                         pointer_to_pvt(1)
    131                                         ),
    132                                 new CastExpr(
    133                                         castExpr->get_arg(),
    134                                         pointer_to_pvt(2)
    135                                         ) }
    136                                 ),
    137                         castExpr->get_result()
     137                                        new CastExpr(
     138                                                new AddressExpr( new VariableExpr( table ) ),
     139                                                pointer_to_pvt(1)
     140                                                ),
     141                                        new CastExpr(
     142                                                castExpr->get_arg(),
     143                                                pointer_to_pvt(2)
     144                                                )
     145                                } ),
     146                        castExpr->get_result()->clone()
    138147                        );
    139148
Note: See TracChangeset for help on using the changeset viewer.