Ignore:
Timestamp:
Apr 12, 2021, 11:53:30 AM (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:
73f4d08
Parents:
ecfd758
Message:

Added and used some helpers. The widely useful one is a from_string helper for constants.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Virtual/ExpandCasts.cc

    recfd758 rb91bfde  
    7777
    7878        class VirtualCastCore {
    79                 Type * pointer_to_pvt(int level_of_indirection) {
     79                CastExpr * cast_to_type_id( Expression * expr, int level_of_indirection ) {
    8080                        Type * type = new StructInstType(
    8181                                Type::Qualifiers( Type::Const ), pvt_decl );
     
    8383                                type = new PointerType( noQualifiers, type );
    8484                        }
    85                         return type;
     85                        return new CastExpr( expr, type );
    8686                }
    8787
     
    253253                Expression * result = new CastExpr(
    254254                        new ApplicationExpr( VariableExpr::functionPointer( vcast_decl ), {
    255                                         new CastExpr(
    256                                                 new AddressExpr( new VariableExpr( type_id ) ),
    257                                                 pointer_to_pvt(1)
    258                                         ),
    259                                         new CastExpr(
    260                                                 castExpr->get_arg(),
    261                                                 pointer_to_pvt(2)
    262                                         )
     255                                cast_to_type_id( new AddressExpr( new VariableExpr( type_id ) ), 1 ),
     256                                cast_to_type_id( castExpr->get_arg(), 2 ),
    263257                        } ),
    264258                        castExpr->get_result()->clone()
Note: See TracChangeset for help on using the changeset viewer.