Ignore:
Timestamp:
Nov 10, 2015, 4:15:48 PM (7 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
aaron-thesis, arm-eh, 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, resolv-new, string, with_gc
Children:
d8847b7
Parents:
d2ded3e7
Message:

First code generation for generic types (incorrect)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/TypeSubstitution.cc

    rd2ded3e7 r37a3b8f9  
    126126Type *TypeSubstitution::handleType( TypeClass *type ) {
    127127        BoundVarsType oldBoundVars( boundVars );
     128        // bind type variables from forall-qualifiers
    128129        if ( freeOnly ) {
    129130                for ( std::list< TypeDecl* >::const_iterator tyvar = type->get_forall().begin(); tyvar != type->get_forall().end(); ++tyvar ) {
     
    136137}
    137138
     139template< typename TypeClass >
     140Type *TypeSubstitution::handleAggregateType( TypeClass *type ) {
     141        BoundVarsType oldBoundVars( boundVars );
     142        // bind type variables from forall-qualifiers
     143        if ( freeOnly ) {
     144                for ( std::list< TypeDecl* >::const_iterator tyvar = type->get_forall().begin(); tyvar != type->get_forall().end(); ++tyvar ) {
     145                        boundVars.insert( (*tyvar )->get_name() );
     146                } // for
     147        } // if
     148        // bind type variables from generic type instantiations
     149        for ( std::list< TypeDecl* >::const_iterator tyvar = type->get_baseParameters().begin(); tyvar != type->get_baseParameters().end(); ++tyvar ) {
     150                boundVars.insert( (*tyvar)->get_name() );
     151        } // for
     152        Type *ret = Mutator::mutate( type );
     153        boundVars = oldBoundVars;
     154        return ret;
     155}
     156
    138157Type * TypeSubstitution::mutate( VoidType *basicType ) {
    139158        return handleType( basicType );
     
    157176
    158177Type * TypeSubstitution::mutate( StructInstType *aggregateUseType ) {
    159         return handleType( aggregateUseType );
     178        return handleAggregateType( aggregateUseType );
    160179}
    161180
    162181Type * TypeSubstitution::mutate( UnionInstType *aggregateUseType ) {
    163         return handleType( aggregateUseType );
     182        return handleAggregateType( aggregateUseType );
    164183}
    165184
Note: See TracChangeset for help on using the changeset viewer.