Changeset 28e58fd for src/GenPoly/Box.cc


Ignore:
Timestamp:
Aug 25, 2017, 10:38:34 AM (8 years ago)
Author:
Thierry Delisle <tdelisle@…>
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:
800d275
Parents:
af08051 (diff), 3eab308c (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' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    raf08051 r28e58fd  
    2525
    2626#include "Box.h"
     27
     28#include "CodeGen/OperatorTable.h"
    2729#include "Common/ScopedMap.h"            // for ScopedMap, ScopedMap<>::iter...
    2830#include "Common/SemanticError.h"        // for SemanticError
     
    564566                        // To compound the issue, the right side can be *x, etc. because of lvalue-returning functions
    565567                        if ( UntypedExpr * assign = dynamic_cast< UntypedExpr * >( commaExpr->get_arg1() ) ) {
    566                                 if ( InitTweak::isAssignment( InitTweak::getFunctionName( assign ) ) ) {
     568                                if ( CodeGen::isAssignment( InitTweak::getFunctionName( assign ) ) ) {
    567569                                        assert( assign->get_args().size() == 2 );
    568570                                        if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * > ( assign->get_args().back() ) ) {
     
    604606                                                }
    605607                                        } else {
    606                                                 throw SemanticError( "Cannot pass non-struct type for generic struct" );
     608                                                throw SemanticError( "Cannot pass non-struct type for generic struct: ", argBaseType );
    607609                                        }
    608610                                }
     
    10191021                                                } // if
    10201022                                                if ( baseType1 || baseType2 ) {
     1023                                                        delete ret->get_result();
    10211024                                                        ret->set_result( appExpr->get_result()->clone() );
    10221025                                                        if ( appExpr->get_env() ) {
     
    10321035                                                assert( ! appExpr->get_args().empty() );
    10331036                                                if ( isPolyType( appExpr->get_result(), scopeTyVars, env ) ) {
     1037                                                        // remove dereference from polymorphic types since they are boxed.
    10341038                                                        Expression *ret = appExpr->get_args().front();
     1039                                                        // fix expr type to remove pointer
    10351040                                                        delete ret->get_result();
    10361041                                                        ret->set_result( appExpr->get_result()->clone() );
     
    11221127
    11231128                        assert( appExpr->get_function()->has_result() );
    1124                         PointerType *pointer = safe_dynamic_cast< PointerType *>( appExpr->get_function()->get_result() );
    1125                         FunctionType *function = safe_dynamic_cast< FunctionType *>( pointer->get_base() );
     1129                        FunctionType * function = getFunctionType( appExpr->get_function()->get_result() );
     1130                        assertf( function, "ApplicationExpr has non-function type: %s", toString( appExpr->get_function()->get_result() ).c_str() );
    11261131
    11271132                        if ( Expression *newExpr = handleIntrinsics( appExpr ) ) {
     
    12001205                                                        if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( expr->get_args().front() ) ) {
    12011206                                                                assert( appExpr->get_function()->has_result() );
    1202                                                                 PointerType *pointer = safe_dynamic_cast< PointerType *>( appExpr->get_function()->get_result() );
    1203                                                                 FunctionType *function = safe_dynamic_cast< FunctionType *>( pointer->get_base() );
     1207                                                                FunctionType *function = getFunctionType( appExpr->get_function()->get_result() );
     1208                                                                assert( function );
    12041209                                                                needs = needsAdapter( function, scopeTyVars );
    12051210                                                        } // if
     
    12101215                        // isPolyType check needs to happen before mutating addrExpr arg, so pull it forward
    12111216                        // out of the if condition.
     1217                        addrExpr->set_arg( mutateExpression( addrExpr->get_arg() ) );
     1218                        // ... but must happen after mutate, since argument might change (e.g. intrinsic *?, ?[?]) - re-evaluate above comment
    12121219                        bool polytype = isPolyType( addrExpr->get_arg()->get_result(), scopeTyVars, env );
    1213                         addrExpr->set_arg( mutateExpression( addrExpr->get_arg() ) );
    12141220                        if ( polytype || needs ) {
    12151221                                Expression *ret = addrExpr->get_arg();
     
    12781284                                if ( adaptersDone.find( mangleName ) == adaptersDone.end() ) {
    12791285                                        std::string adapterName = makeAdapterName( mangleName );
    1280                                         paramList.push_front( new ObjectDecl( adapterName, Type::StorageClasses(), LinkageSpec::C, 0, new PointerType( Type::Qualifiers(), makeAdapterType( *funType, scopeTyVars ) ), 0 ) );
     1286                                        // adapter may not be used in body, pass along with unused attribute.
     1287                                        paramList.push_front( new ObjectDecl( adapterName, Type::StorageClasses(), LinkageSpec::C, 0, new PointerType( Type::Qualifiers(), makeAdapterType( *funType, scopeTyVars ) ), 0, { new Attribute( "unused" ) } ) );
    12811288                                        adaptersDone.insert( adaptersDone.begin(), mangleName );
    12821289                                }
     
    13841391                        std::list< DeclarationWithType *>::iterator last = funcType->get_parameters().begin();
    13851392                        std::list< DeclarationWithType *> inferredParams;
    1386                         ObjectDecl newObj( "", Type::StorageClasses(), LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0 );
     1393                        // size/align/offset parameters may not be used in body, pass along with unused attribute.
     1394                        ObjectDecl newObj( "", Type::StorageClasses(), LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0,
     1395                                           { new Attribute( "unused" ) } );
    13871396                        ObjectDecl newPtr( "", Type::StorageClasses(), LinkageSpec::C, 0,
    13881397                                           new PointerType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ), 0 );
     
    14071416                                for ( std::list< DeclarationWithType *>::iterator assert = (*tyParm)->get_assertions().begin(); assert != (*tyParm)->get_assertions().end(); ++assert ) {
    14081417//      *assert = (*assert)->acceptMutator( *this );
     1418                                        // assertion parameters may not be used in body, pass along with unused attribute.
     1419                                        (*assert)->get_attributes().push_back( new Attribute( "unused" ) );
    14091420                                        inferredParams.push_back( *assert );
    14101421                                }
Note: See TracChangeset for help on using the changeset viewer.