Ignore:
Timestamp:
Jul 12, 2017, 4:44:44 PM (7 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:
cda7889
Parents:
aca65621
Message:

Add stripReferences, fix createDeref and makeSub to work with reference types

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.cc

    raca65621 r0698aa1  
    335335namespace {
    336336        TypeSubstitution makeSub( Type * t ) {
    337                 if ( StructInstType * aggInst = dynamic_cast< StructInstType * >( t ) ) {
     337                if ( ReferenceType * refType = dynamic_cast< ReferenceType * >( t ) ) {
     338                        return makeSub( refType->get_base() );
     339                } else if ( StructInstType * aggInst = dynamic_cast< StructInstType * >( t ) ) {
    338340                        return TypeSubstitution( aggInst->get_baseParameters()->begin(), aggInst->get_baseParameters()->end(), aggInst->get_parameters().begin() );
    339341                } else if ( UnionInstType * aggInst = dynamic_cast< UnionInstType * >( t ) ) {
     
    400402        if ( Type * type = expr->get_result() ) {
    401403                Type * base = InitTweak::getPointerBase( type );
    402                 if ( ! base ) {
    403                         std::cerr << type << std::endl;
    404                 }
    405                 assertf( base, "expected pointer type in dereference\n" );
    406                 ret->set_result( maybeClone( base ) );
     404                assertf( base, "expected pointer type in dereference (type was %s)", toString( type ).c_str() );
     405                ret->set_result( new ReferenceType( Type::Qualifiers(), base->clone() ) );
    407406        }
    408407        return ret;
Note: See TracChangeset for help on using the changeset viewer.