Changeset 32805db for src/GenPoly


Ignore:
Timestamp:
Jan 22, 2016, 1:54:30 PM (8 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
6d160d7
Parents:
4a79e3c
Message:

Switched parameter adder over to add for pointer*-to-polymorphic-generic as well

Location:
src/GenPoly
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    r4a79e3c r32805db  
    423423                        std::set< std::string > seenTypes; //< names for generic types we've seen
    424424                        for ( ; fnParm != funcType->get_parameters().end() && fnArg != appExpr->get_args().end(); ++fnParm, ++fnArg ) {
    425                                 Type *parmType = (*fnParm)->get_type();
    426                                 if ( ! dynamic_cast< TypeInstType* >( parmType ) && isPolyType( parmType, exprTyVars ) ) {
    427                                         std::string sizeName = sizeofName( parmType );
     425                                Type *polyBase = hasPolyBase( (*fnParm)->get_type(), exprTyVars );
     426                                if ( polyBase && ! dynamic_cast< TypeInstType* >( polyBase ) ) {
     427                                        std::string sizeName = sizeofName( polyBase );
    428428                                        if ( seenTypes.count( sizeName ) ) continue;
    429429
    430                                         assert( ! (*fnArg)->get_results().empty() );
    431                                         Type *argType = (*fnArg)->get_results().front();
    432                                         arg = appExpr->get_args().insert( arg, new SizeofExpr( argType->clone() ) );
     430                                        VariableExpr *fnArgBase = getBaseVar( *fnArg );
     431                                        assert( fnArgBase && ! fnArgBase->get_results().empty() );
     432                                        Type *argBaseType = fnArgBase->get_results().front();
     433                                        arg = appExpr->get_args().insert( arg, new SizeofExpr( argBaseType->clone() ) );
    433434                                        arg++;
    434                                         arg = appExpr->get_args().insert( arg, new AlignofExpr( argType->clone() ) );
     435                                        arg = appExpr->get_args().insert( arg, new AlignofExpr( argBaseType->clone() ) );
    435436                                        arg++;
    436                                         if ( dynamic_cast< StructInstType* >( parmType ) ) {
    437                                                 if ( StructInstType *argStructType = dynamic_cast< StructInstType* >( argType ) ) {
    438                                                         arg = appExpr->get_args().insert( arg, makeOffsetArray( argStructType ) );
     437                                        if ( dynamic_cast< StructInstType* >( polyBase ) ) {
     438                                                if ( StructInstType *argBaseStructType = dynamic_cast< StructInstType* >( argBaseType ) ) {
     439                                                        arg = appExpr->get_args().insert( arg, makeOffsetArray( argBaseStructType ) );
    439440                                                        arg++;
    440441                                                } else {
     
    11771178                        std::set< std::string > seenTypes; // sizeofName for generic types we've seen
    11781179                        for ( std::list< DeclarationWithType* >::const_iterator fnParm = last; fnParm != funcType->get_parameters().end(); ++fnParm ) {
    1179                                 Type *parmType = (*fnParm)->get_type();
    1180                                 if ( ! dynamic_cast< TypeInstType* >( parmType ) && isPolyType( parmType, scopeTyVars ) ) {
    1181                                         std::string sizeName = sizeofName( parmType );
     1180                                Type *polyBase = hasPolyBase( (*fnParm)->get_type(), scopeTyVars );
     1181                                if ( polyBase && ! dynamic_cast< TypeInstType* >( polyBase ) ) {
     1182                                        std::string sizeName = sizeofName( polyBase );
    11821183                                        if ( seenTypes.count( sizeName ) ) continue;
    11831184
     
    11891190
    11901191                                        alignParm = newObj.clone();
    1191                                         alignParm->set_name( alignofName( parmType ) );
     1192                                        alignParm->set_name( alignofName( polyBase ) );
    11921193                                        last = funcType->get_parameters().insert( last, alignParm );
    11931194                                        ++last;
    11941195
    1195                                         if ( dynamic_cast< StructInstType* >( parmType ) ) {
     1196                                        if ( dynamic_cast< StructInstType* >( polyBase ) ) {
    11961197                                                offsetParm = newPtr.clone();
    1197                                                 offsetParm->set_name( offsetofName( parmType ) );
     1198                                                offsetParm->set_name( offsetofName( polyBase ) );
    11981199                                                last = funcType->get_parameters().insert( last, offsetParm );
    11991200                                                ++last;
  • src/GenPoly/GenPoly.cc

    r4a79e3c r32805db  
    168168                        // found the variable directly
    169169                        return varExpr;
     170                } else if ( AddressExpr *addressExpr = dynamic_cast< AddressExpr* >( expr ) ) {
     171                        return getBaseVar( addressExpr->get_arg() );
    170172                } else if ( UntypedExpr *untypedExpr = dynamic_cast< UntypedExpr* >( expr ) ) {
    171173                        // look for compiler-inserted dereference operator
Note: See TracChangeset for help on using the changeset viewer.