Changeset 8d7bef2 for src/ResolvExpr


Ignore:
Timestamp:
Mar 20, 2018, 5:12:25 PM (6 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
new-env, with_gc
Children:
7e4b44db
Parents:
68f9c43
Message:

First compiling build of CFA-CC with GC

Location:
src/ResolvExpr
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/AlternativeFinder.cc

    r68f9c43 r8d7bef2  
    2121#include <list>                    // for _List_iterator, list, _List_const_...
    2222#include <map>                     // for _Rb_tree_iterator, map, _Rb_tree_c...
    23 #include <memory>                  // for allocator_traits<>::value_type, unique_ptr
     23#include <memory>                  // for allocator_traits<>::value_type
    2424#include <utility>                 // for pair
    2525#include <vector>                  // for vector
     
    296296                // adds anonymous member interpretations whenever an aggregate value type is seen.
    297297                // it's okay for the aggregate expression to have reference type -- cast it to the base type to treat the aggregate as the referenced value
    298                 std::unique_ptr<Expression> aggrExpr( alt.expr->clone() );
     298                Expression* aggrExpr = alt.expr->clone();
    299299                alt.env.apply( aggrExpr->get_result() );
    300300                Type * aggrType = aggrExpr->get_result();
    301301                if ( dynamic_cast< ReferenceType * >( aggrType ) ) {
    302302                        aggrType = aggrType->stripReferences();
    303                         aggrExpr.reset( new CastExpr( aggrExpr.release(), aggrType->clone() ) );
     303                        aggrExpr = new CastExpr{ aggrExpr, aggrType->clone() };
    304304                }
    305305
    306306                if ( StructInstType *structInst = dynamic_cast< StructInstType* >( aggrExpr->get_result() ) ) {
    307307                        NameExpr nameExpr( "" );
    308                         addAggMembers( structInst, aggrExpr.get(), alt.cost+Cost::safe, alt.env, &nameExpr );
     308                        addAggMembers( structInst, aggrExpr, alt.cost+Cost::safe, alt.env, &nameExpr );
    309309                } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( aggrExpr->get_result() ) ) {
    310310                        NameExpr nameExpr( "" );
    311                         addAggMembers( unionInst, aggrExpr.get(), alt.cost+Cost::safe, alt.env, &nameExpr );
     311                        addAggMembers( unionInst, aggrExpr, alt.cost+Cost::safe, alt.env, &nameExpr );
    312312                } // if
    313313        }
     
    630630        struct ArgPack {
    631631                std::size_t parent;                ///< Index of parent pack
    632                 std::unique_ptr<Expression> expr;  ///< The argument stored here
     632                Expression* expr;                  ///< The argument stored here
    633633                Cost cost;                         ///< The cost of this argument
    634634                TypeEnvironment env;               ///< Environment for this pack
     
    677677                        std::list<Expression*> exprs;
    678678                        const ArgPack* pack = this;
    679                         if ( expr ) { exprs.push_front( expr.release() ); }
     679                        if ( expr ) { exprs.push_front( expr ); }
    680680                        while ( pack->tupleStart == 0 ) {
    681681                                pack = &packs[pack->parent];
     
    684684                        }
    685685                        // reset pack to appropriate tuple
    686                         expr.reset( new TupleExpr( exprs ) );
     686                        expr = new TupleExpr{ exprs };
    687687                        tupleStart = pack->tupleStart - 1;
    688688                        parent = pack->parent;
     
    736736
    737737                                                results.emplace_back(
    738                                                         i, expl.exprs[results[i].nextExpl].get(), copy(results[i].env),
     738                                                        i, expl.exprs[results[i].nextExpl], copy(results[i].env),
    739739                                                        copy(results[i].need), copy(results[i].have),
    740740                                                        copy(results[i].openVars), nextArg, nTuples, Cost::zero, nextExpl,
     
    757757                                                        newResult.parent = i;
    758758                                                        std::list<Expression*> emptyList;
    759                                                         newResult.expr.reset( new TupleExpr( emptyList ) );
     759                                                        newResult.expr = new TupleExpr{ emptyList };
    760760                                                        argType = newResult.expr->get_result();
    761761                                                } else {
     
    764764                                                        newResult.cost = results[i].cost;
    765765                                                        newResult.tupleStart = results[i].tupleStart;
    766                                                         newResult.expr.reset( results[i].expr->clone() );
     766                                                        newResult.expr = results[i].expr->clone();
    767767                                                        argType = newResult.expr->get_result();
    768768
     
    814814                                                // add new result
    815815                                                results.emplace_back(
    816                                                         i, expl.exprs.front().get(), move(env), copy(results[i].need),
     816                                                        i, expl.exprs.front(), move(env), copy(results[i].need),
    817817                                                        copy(results[i].have), move(openVars), nextArg + 1,
    818818                                                        nTuples, expl.cost, expl.exprs.size() == 1 ? 0 : 1, j );
     
    840840                        if ( results[i].hasExpl() ) {
    841841                                const ExplodedActual& expl = results[i].getExpl( args );
    842                                 Expression* expr = expl.exprs[results[i].nextExpl].get();
     842                                Expression* expr = expl.exprs[results[i].nextExpl];
    843843
    844844                                TypeEnvironment env = results[i].env;
     
    911911
    912912                                // consider only first exploded actual
    913                                 Expression* expr = expl.exprs.front().get();
     913                                Expression* expr = expl.exprs.front();
    914914                                Type* actualType = expr->get_result()->clone();
    915915
     
    10141014
    10151015                                                results.emplace_back(
    1016                                                         i, expl.exprs[results[i].nextExpl].get(), copy(results[i].env),
     1016                                                        i, expl.exprs[results[i].nextExpl], copy(results[i].env),
    10171017                                                        copy(results[i].need), copy(results[i].have),
    10181018                                                        copy(results[i].openVars), nextArg, 0, Cost::zero, nextExpl,
     
    10501050                                                // add new result
    10511051                                                results.emplace_back(
    1052                                                         i, expl.exprs.front().get(), move(env), copy(results[i].need),
     1052                                                        i, expl.exprs.front(), move(env), copy(results[i].need),
    10531053                                                        copy(results[i].have), move(openVars), nextArg + 1, 0,
    10541054                                                        expl.cost, expl.exprs.size() == 1 ? 0 : 1, j );
     
    13441344                        Expression * aggrExpr = agg->expr->clone();
    13451345                        referenceToRvalueConversion( aggrExpr, cost );
    1346                         std::unique_ptr<Expression> guard( aggrExpr );
    13471346
    13481347                        // find member of the given type
  • src/ResolvExpr/ExplodedActual.h

    r68f9c43 r8d7bef2  
    1616#pragma once
    1717
    18 #include <memory>
    1918#include <vector>
    2019
     
    2928                TypeEnvironment env;
    3029                Cost cost;
    31                 std::vector< std::unique_ptr<Expression> > exprs;
     30                std::vector< Expression* > exprs;
    3231
    3332                ExplodedActual() : env(), cost(Cost::zero), exprs() {}
  • src/ResolvExpr/Unify.cc

    r68f9c43 r8d7bef2  
    1717#include <iterator>               // for back_insert_iterator, back_inserter
    1818#include <map>                    // for _Rb_tree_const_iterator, _Rb_tree_i...
    19 #include <memory>                 // for unique_ptr
    2019#include <set>                    // for set
    2120#include <string>                 // for string, operator==, operator!=, bas...
     
    165164                                Type *common = 0;
    166165                                // attempt to unify equivalence class type (which has qualifiers stripped, so they must be restored) with the type to bind to
    167                                 std::unique_ptr< Type > newType( curClass.type->clone() );
     166                                Type* newType = curClass.type->clone();
    168167                                newType->get_qualifiers() = typeInst->get_qualifiers();
    169                                 if ( unifyInexact( newType.get(), other, env, needAssertions, haveAssertions, openVars, widenMode & WidenMode( curClass.allowWidening, true ), indexer, common ) ) {
     168                                if ( unifyInexact( newType, other, env, needAssertions, haveAssertions, openVars, widenMode & WidenMode( curClass.allowWidening, true ), indexer, common ) ) {
    170169                                        if ( common ) {
    171170                                                common->get_qualifiers() = Type::Qualifiers();
     
    466465
    467466        template< typename Iterator, typename Func >
    468         std::unique_ptr<Type> combineTypes( Iterator begin, Iterator end, Func & toType ) {
     467        Type* combineTypes( Iterator begin, Iterator end, Func & toType ) {
    469468                std::list< Type * > types;
    470469                for ( ; begin != end; ++begin ) {
     
    472471                        flatten( toType( *begin ), back_inserter( types ) );
    473472                }
    474                 return std::unique_ptr<Type>( new TupleType( Type::Qualifiers(), types ) );
     473                return new TupleType{ Type::Qualifiers(), types };
    475474        }
    476475
     
    487486                        if ( isTtype1 && ! isTtype2 ) {
    488487                                // combine all of the things in list2, then unify
    489                                 return unifyExact( t1, combineTypes( list2Begin, list2End, get_type ).get(), env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
     488                                return unifyExact( t1, combineTypes( list2Begin, list2End, get_type ), env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
    490489                        } else if ( isTtype2 && ! isTtype1 ) {
    491490                                // combine all of the things in list1, then unify
    492                                 return unifyExact( combineTypes( list1Begin, list1End, get_type ).get(), t2, env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
     491                                return unifyExact( combineTypes( list1Begin, list1End, get_type ), t2, env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
    493492                        } else if ( ! unifyExact( t1, t2, env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer ) ) {
    494493                                return false;
     
    500499                        Type * t1 = (*list1Begin)->get_type();
    501500                        if ( Tuples::isTtype( t1 ) ) {
    502                                 return unifyExact( t1, combineTypes( list2Begin, list2End, get_type ).get(), env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
     501                                return unifyExact( t1, combineTypes( list2Begin, list2End, get_type ), env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
    503502                        } else return false;
    504503                } else if ( list2Begin != list2End ) {
     
    506505                        Type * t2 = (*list2Begin)->get_type();
    507506                        if ( Tuples::isTtype( t2 ) ) {
    508                                 return unifyExact( combineTypes( list1Begin, list1End, get_type ).get(), t2, env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
     507                                return unifyExact( combineTypes( list1Begin, list1End, get_type ), t2, env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
    509508                        } else return false;
    510509                } else {
     
    559558                        // flatten the parameter lists for both functions so that tuple structure
    560559                        // doesn't affect unification. Must be a clone so that the types don't change.
    561                         std::unique_ptr<FunctionType> flatFunc( functionType->clone() );
    562                         std::unique_ptr<FunctionType> flatOther( otherFunction->clone() );
     560                        FunctionType* flatFunc = functionType->clone();
     561                        FunctionType* flatOther = otherFunction->clone();
    563562                        flattenList( flatFunc->get_parameters(), flatFunc->get_parameters(), env );
    564563                        flattenList( flatOther->get_parameters(), flatOther->get_parameters(), env );
     
    701700                        if ( isTtype1 && ! isTtype2 ) {
    702701                                // combine all of the things in list2, then unify
    703                                 return unifyExact( t1, combineTypes( list2Begin, list2End, get_type ).get(), env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
     702                                return unifyExact( t1, combineTypes( list2Begin, list2End, get_type ), env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
    704703                        } else if ( isTtype2 && ! isTtype1 ) {
    705704                                // combine all of the things in list1, then unify
    706                                 return unifyExact( combineTypes( list1Begin, list1End, get_type ).get(), t2, env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
     705                                return unifyExact( combineTypes( list1Begin, list1End, get_type ), t2, env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
    707706                        } else if ( ! unifyExact( t1, t2, env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer ) ) {
    708707                                return false;
     
    714713                        Type * t1 = *list1Begin;
    715714                        if ( Tuples::isTtype( t1 ) ) {
    716                                 return unifyExact( t1, combineTypes( list2Begin, list2End, get_type ).get(), env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
     715                                return unifyExact( t1, combineTypes( list2Begin, list2End, get_type ), env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
    717716                        } else return false;
    718717                } else if ( list2Begin != list2End ) {
     
    720719                        Type * t2 = *list2Begin;
    721720                        if ( Tuples::isTtype( t2 ) ) {
    722                                 return unifyExact( combineTypes( list1Begin, list1End, get_type ).get(), t2, env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
     721                                return unifyExact( combineTypes( list1Begin, list1End, get_type ), t2, env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
    723722                        } else return false;
    724723                } else {
     
    729728        void Unify::postvisit(TupleType *tupleType) {
    730729                if ( TupleType *otherTuple = dynamic_cast< TupleType* >( type2 ) ) {
    731                         std::unique_ptr<TupleType> flat1( tupleType->clone() );
    732                         std::unique_ptr<TupleType> flat2( otherTuple->clone() );
     730                        TupleType* flat1 = tupleType->clone();
     731                        TupleType* flat2 = otherTuple->clone();
    733732                        std::list<Type *> types1, types2;
    734733
     
    737736                        flat2->acceptMutator( expander );
    738737
    739                         flatten( flat1.get(), back_inserter( types1 ) );
    740                         flatten( flat2.get(), back_inserter( types2 ) );
     738                        flatten( flat1, back_inserter( types1 ) );
     739                        flatten( flat2, back_inserter( types2 ) );
    741740
    742741                        result = unifyList( types1.begin(), types1.end(), types2.begin(), types2.end(), env, needAssertions, haveAssertions, openVars, indexer );
Note: See TracChangeset for help on using the changeset viewer.