Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    r2ae171d8 r08fc48f  
    2525
    2626#include "Box.h"
    27 
    28 #include "CodeGen/OperatorTable.h"
    2927#include "Common/ScopedMap.h"            // for ScopedMap, ScopedMap<>::iter...
    3028#include "Common/SemanticError.h"        // for SemanticError
     
    566564                        // To compound the issue, the right side can be *x, etc. because of lvalue-returning functions
    567565                        if ( UntypedExpr * assign = dynamic_cast< UntypedExpr * >( commaExpr->get_arg1() ) ) {
    568                                 if ( CodeGen::isAssignment( InitTweak::getFunctionName( assign ) ) ) {
     566                                if ( InitTweak::isAssignment( InitTweak::getFunctionName( assign ) ) ) {
    569567                                        assert( assign->get_args().size() == 2 );
    570568                                        if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * > ( assign->get_args().back() ) ) {
     
    606604                                                }
    607605                                        } else {
    608                                                 throw SemanticError( "Cannot pass non-struct type for generic struct: ", argBaseType );
     606                                                throw SemanticError( "Cannot pass non-struct type for generic struct" );
    609607                                        }
    610608                                }
     
    756754                                Type * newType = arg->get_result()->clone();
    757755                                if ( env ) env->apply( newType );
    758                                 std::unique_ptr<Type> manager( newType );
     756                                std::auto_ptr<Type> manager( newType );
    759757                                if ( isPolyType( newType ) ) {
    760758                                        // if the argument's type is polymorphic, we don't need to box again!
     
    774772                                        newObj->get_type()->get_qualifiers() = Type::Qualifiers(); // TODO: is this right???
    775773                                        stmtsToAdd.push_back( new DeclStmt( noLabels, newObj ) );
    776                                         UntypedExpr *assign = new UntypedExpr( new NameExpr( "?=?" ) ); // TODO: why doesn't this just use initialization syntax?
     774                                        UntypedExpr *assign = new UntypedExpr( new NameExpr( "?=?" ) );
    777775                                        assign->get_args().push_back( new VariableExpr( newObj ) );
    778776                                        assign->get_args().push_back( arg );
     
    10211019                                                } // if
    10221020                                                if ( baseType1 || baseType2 ) {
    1023                                                         delete ret->get_result();
    10241021                                                        ret->set_result( appExpr->get_result()->clone() );
    10251022                                                        if ( appExpr->get_env() ) {
     
    10351032                                                assert( ! appExpr->get_args().empty() );
    10361033                                                if ( isPolyType( appExpr->get_result(), scopeTyVars, env ) ) {
    1037                                                         // remove dereference from polymorphic types since they are boxed.
    10381034                                                        Expression *ret = appExpr->get_args().front();
    1039                                                         // fix expr type to remove pointer
    10401035                                                        delete ret->get_result();
    10411036                                                        ret->set_result( appExpr->get_result()->clone() );
     
    11271122
    11281123                        assert( appExpr->get_function()->has_result() );
    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() );
     1124                        PointerType *pointer = safe_dynamic_cast< PointerType *>( appExpr->get_function()->get_result() );
     1125                        FunctionType *function = safe_dynamic_cast< FunctionType *>( pointer->get_base() );
    11311126
    11321127                        if ( Expression *newExpr = handleIntrinsics( appExpr ) ) {
     
    12051200                                                        if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( expr->get_args().front() ) ) {
    12061201                                                                assert( appExpr->get_function()->has_result() );
    1207                                                                 FunctionType *function = getFunctionType( appExpr->get_function()->get_result() );
    1208                                                                 assert( function );
     1202                                                                PointerType *pointer = safe_dynamic_cast< PointerType *>( appExpr->get_function()->get_result() );
     1203                                                                FunctionType *function = safe_dynamic_cast< FunctionType *>( pointer->get_base() );
    12091204                                                                needs = needsAdapter( function, scopeTyVars );
    12101205                                                        } // if
     
    12151210                        // isPolyType check needs to happen before mutating addrExpr arg, so pull it forward
    12161211                        // out of the if condition.
     1212                        bool polytype = isPolyType( addrExpr->get_arg()->get_result(), scopeTyVars, env );
    12171213                        addrExpr->set_arg( mutateExpression( addrExpr->get_arg() ) );
    1218                         // ... but must happen after mutate, since argument might change (e.g. intrinsic *?, ?[?]) - re-evaluate above comment
    1219                         bool polytype = isPolyType( addrExpr->get_arg()->get_result(), scopeTyVars, env );
    12201214                        if ( polytype || needs ) {
    12211215                                Expression *ret = addrExpr->get_arg();
     
    12841278                                if ( adaptersDone.find( mangleName ) == adaptersDone.end() ) {
    12851279                                        std::string adapterName = makeAdapterName( mangleName );
    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" ) } ) );
     1280                                        paramList.push_front( new ObjectDecl( adapterName, Type::StorageClasses(), LinkageSpec::C, 0, new PointerType( Type::Qualifiers(), makeAdapterType( *funType, scopeTyVars ) ), 0 ) );
    12881281                                        adaptersDone.insert( adaptersDone.begin(), mangleName );
    12891282                                }
     
    13911384                        std::list< DeclarationWithType *>::iterator last = funcType->get_parameters().begin();
    13921385                        std::list< DeclarationWithType *> inferredParams;
    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" ) } );
     1386                        ObjectDecl newObj( "", Type::StorageClasses(), LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0 );
    13961387                        ObjectDecl newPtr( "", Type::StorageClasses(), LinkageSpec::C, 0,
    13971388                                           new PointerType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ), 0 );
     
    14161407                                for ( std::list< DeclarationWithType *>::iterator assert = (*tyParm)->get_assertions().begin(); assert != (*tyParm)->get_assertions().end(); ++assert ) {
    14171408//      *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" ) );
    14201409                                        inferredParams.push_back( *assert );
    14211410                                }
Note: See TracChangeset for help on using the changeset viewer.