Changeset 2c57025 for src/GenPoly


Ignore:
Timestamp:
Nov 25, 2016, 6:11:03 PM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
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:
0f35657
Parents:
186fd86
Message:

add support for built-in sized trait which decouples size/alignment information from otype parameters, add test for sized trait

Location:
src/GenPoly
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    r186fd86 r2c57025  
    275275
    276276                for ( std::list< TypeDecl* >::const_iterator decl = decls.begin(); decl != decls.end(); ++decl ) {
    277                         if ( (*decl)->get_kind() == TypeDecl::Any ) {
     277                        if ( (*decl)->isComplete() ) {
    278278                                otypeDecls.push_back( *decl );
    279279                        }
     
    719719
    720720                TypeDecl *Pass1::mutate( TypeDecl *typeDecl ) {
    721                         scopeTyVars[ typeDecl->get_name() ] = typeDecl->get_kind();
     721                        addToTyVarMap( typeDecl, scopeTyVars );
    722722                        return Mutator::mutate( typeDecl );
    723723                }
     
    774774                                ResolvExpr::EqvClass eqvClass;
    775775                                assert( env );
    776                                 if ( tyParm->second == TypeDecl::Any ) {
     776                                if ( tyParm->second.isComplete ) {
    777777                                        Type *concrete = env->lookup( tyParm->first );
    778778                                        if ( concrete ) {
     
    12781278                        std::list< Expression *>::iterator paramBegin = appExpr->get_args().begin();
    12791279
    1280                         TyVarMap exprTyVars( (TypeDecl::Kind)-1 );
     1280                        TyVarMap exprTyVars( TypeDecl::Data{} );
    12811281                        makeTyVarMap( function, exprTyVars );
    12821282                        ReferenceToType *dynRetType = isDynRet( function, exprTyVars );
     
    14281428
    14291429                                                // skip non-otype parameters (ftype/dtype)
     1430                                                // xxx - should this check whether the type is complete instead?
    14301431                                                if ( (*forallIt)->get_kind() != TypeDecl::Any ) continue;
    14311432
     
    15531554
    15541555                TypeDecl * Pass2::mutate( TypeDecl *typeDecl ) {
    1555                         scopeTyVars[ typeDecl->get_name() ] = typeDecl->get_kind();
     1556                        addToTyVarMap( typeDecl, scopeTyVars );
    15561557                        if ( typeDecl->get_base() ) {
    15571558                                return handleDecl( typeDecl, typeDecl->get_base() );
     
    15971598                                ObjectDecl *sizeParm, *alignParm;
    15981599                                // add all size and alignment parameters to parameter list
    1599                                 if ( (*tyParm)->get_kind() == TypeDecl::Any ) {
     1600                                if ( (*tyParm)->isComplete() ) {
    16001601                                        TypeInstType parmType( Type::Qualifiers(), (*tyParm)->get_name(), *tyParm );
    16011602                                        std::string parmName = mangleType( &parmType );
     
    17061707
    17071708                TypeDecl * PolyGenericCalculator::mutate( TypeDecl *typeDecl ) {
    1708                         scopeTyVars[ typeDecl->get_name() ] = typeDecl->get_kind();
     1709                        addToTyVarMap( typeDecl, scopeTyVars );
    17091710                        return Parent::mutate( typeDecl );
    17101711                }
     
    18701871                        for ( ; baseParam != baseParams.end() && typeParam != typeParams.end(); ++baseParam, ++typeParam ) {
    18711872                                // skip non-otype parameters
    1872                                 if ( (*baseParam)->get_kind() != TypeDecl::Any ) continue;
     1873                                if ( ! (*baseParam)->isComplete() ) continue;
    18731874                                TypeExpr *typeExpr = dynamic_cast< TypeExpr* >( *typeParam );
    18741875                                assert( typeExpr && "all otype parameters should be type expressions" );
     
    20822083//   Initializer *init = 0;
    20832084//   std::list< Expression *> designators;
    2084 //   scopeTyVars[ typeDecl->get_name() ] = typeDecl->get_kind();
     2085//   addToTyVarMap( typeDecl, scopeTyVars );
    20852086//   if ( typeDecl->get_base() ) {
    20862087//     init = new SimpleInit( new SizeofExpr( handleDecl( typeDecl, typeDecl->get_base() ) ), designators );
     
    20882089//   return new ObjectDecl( typeDecl->get_name(), Declaration::Extern, LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::UnsignedInt ), init );
    20892090
    2090                         scopeTyVars[ typeDecl->get_name() ] = typeDecl->get_kind();
     2091                        addToTyVarMap( typeDecl, scopeTyVars );
    20912092                        return Mutator::mutate( typeDecl );
    20922093                }
  • src/GenPoly/GenPoly.cc

    r186fd86 r2c57025  
    9797                if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( type ) ) {
    9898                        auto var = tyVars.find( typeInst->get_name() );
    99                         if ( var != tyVars.end() && var->second == TypeDecl::Any ) {
     99                        if ( var != tyVars.end() && var->second.isComplete ) {
    100100                                return typeInst;
    101101                        }
     
    117117                if ( function->get_returnVals().empty() ) return 0;
    118118
    119                 TyVarMap forallTypes( (TypeDecl::Kind)-1 );
     119                TyVarMap forallTypes( TypeDecl::Data{} );
    120120                makeTyVarMap( function, forallTypes );
    121121                return (ReferenceToType*)isDynType( function->get_returnVals().front()->get_type(), forallTypes );
     
    227227        }
    228228
     229        void addToTyVarMap( TypeDecl * tyVar, TyVarMap &tyVarMap ) {
     230                tyVarMap[ tyVar->get_name() ] = TypeDecl::Data{ tyVar };
     231        }
     232
    229233        void makeTyVarMap( Type *type, TyVarMap &tyVarMap ) {
    230234                for ( Type::ForallList::const_iterator tyVar = type->get_forall().begin(); tyVar != type->get_forall().end(); ++tyVar ) {
    231235                        assert( *tyVar );
    232                         tyVarMap[ (*tyVar)->get_name() ] = (*tyVar)->get_kind();
     236                        addToTyVarMap( *tyVar, tyVarMap );
    233237                }
    234238                if ( PointerType *pointer = dynamic_cast< PointerType* >( type ) ) {
  • src/GenPoly/GenPoly.h

    r186fd86 r2c57025  
    3030
    3131namespace GenPoly {
    32         typedef ErasableScopedMap< std::string, TypeDecl::Kind > TyVarMap;
     32        typedef ErasableScopedMap< std::string, TypeDecl::Data > TyVarMap;
    3333
    3434        /// Replaces a TypeInstType by its referrent in the environment, if applicable
     
    7474        VariableExpr *getBaseVar( Expression *expr, int *levels = 0 );
    7575
     76        /// Adds the type variable `tyVar` to `tyVarMap`
     77        void addToTyVarMap( TypeDecl * tyVar, TyVarMap &tyVarMap );
     78
    7679        /// Adds the declarations in the forall list of type (and its pointed-to type if it's a pointer type) to `tyVarMap`
    7780        void makeTyVarMap( Type *type, TyVarMap &tyVarMap );
  • src/GenPoly/InstantiateGeneric.cc

    r186fd86 r2c57025  
    284284                                // set concDecl to new type, insert type declaration into statements to add
    285285                                concDecl = new StructDecl( typeNamer.newName( inst->get_name() ) );
     286                                concDecl->set_body( inst->get_baseStruct()->has_body() );
    286287                                substituteMembers( inst->get_baseStruct()->get_members(), *inst->get_baseParameters(), typeSubs,        concDecl->get_members() );
    287288                                DeclMutator::addDeclaration( concDecl );
     
    337338                                // set concDecl to new type, insert type declaration into statements to add
    338339                                concDecl = new UnionDecl( typeNamer.newName( inst->get_name() ) );
     340                                concDecl->set_body( inst->get_baseUnion()->has_body() );
    339341                                substituteMembers( inst->get_baseUnion()->get_members(), *inst->get_baseParameters(), typeSubs, concDecl->get_members() );
    340342                                DeclMutator::addDeclaration( concDecl );
  • src/GenPoly/PolyMutator.cc

    r186fd86 r2c57025  
    2323
    2424namespace GenPoly {
    25         namespace {
    26                 const std::list<Label> noLabels;
    27         }
    28 
    29         PolyMutator::PolyMutator() : scopeTyVars( (TypeDecl::Kind)-1 ), env( 0 ) {}
     25        PolyMutator::PolyMutator() : scopeTyVars( TypeDecl::Data{} ), env( 0 ) {}
    3026
    3127        void PolyMutator::mutateStatementList( std::list< Statement* > &statements ) {
  • src/GenPoly/ScrubTyVars.cc

    r186fd86 r2c57025  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // ScrubTyVars.cc -- 
     7// ScrubTyVars.cc --
    88//
    99// Author           : Richard C. Bilson
     
    2828                TyVarMap::const_iterator tyVar = tyVars.find( typeInst->get_name() );
    2929                if ( tyVar != tyVars.end() ) {
    30                         switch ( tyVar->second ) {
     30                        switch ( tyVar->second.kind ) {
    3131                          case TypeDecl::Any:
    3232                          case TypeDecl::Dtype:
     
    5252                return ty;
    5353        }
    54        
     54
    5555        Type * ScrubTyVars::mutate( StructInstType *structInst ) {
    5656                return mutateAggregateType( structInst );
Note: See TracChangeset for help on using the changeset viewer.