Ignore:
Timestamp:
Aug 23, 2017, 6:22:07 PM (7 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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:
87e08e24, cb811ac
Parents:
9f07232 (diff), bd37119 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg2:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.cc

    r9f07232 rd3e4d6c  
    3131#include "TypeSubstitution.h"        // for TypeSubstitution
    3232
     33#include "GenPoly/Lvalue.h"
    3334
    3435Expression::Expression( Expression *_aname ) : result( 0 ), env( 0 ), argName( _aname ) {}
     
    8990}
    9091
     92VariableExpr * VariableExpr::functionPointer( FunctionDecl * func ) {
     93        VariableExpr * funcExpr = new VariableExpr( func );
     94        funcExpr->set_result( new PointerType( Type::Qualifiers(), funcExpr->get_result() ) );
     95        return funcExpr;
     96}
     97
    9198void VariableExpr::print( std::ostream &os, int indent ) const {
    9299        os << "Variable Expression: ";
     
    149156
    150157void AlignofExpr::print( std::ostream &os, int indent) const {
    151         os << std::string( indent, ' ' ) << "Alignof Expression on: ";
     158        os << "Alignof Expression on: ";
    152159
    153160        if (isType)
     
    258265
    259266void AttrExpr::print( std::ostream &os, int indent) const {
    260         os << std::string( indent, ' ' ) << "Attr ";
     267        os << "Attr ";
    261268        attr->print( os, indent + 2 );
    262269        if ( isType || expr ) {
     
    357364namespace {
    358365        TypeSubstitution makeSub( Type * t ) {
    359                 if ( StructInstType * aggInst = dynamic_cast< StructInstType * >( t ) ) {
     366                if ( ReferenceType * refType = dynamic_cast< ReferenceType * >( t ) ) {
     367                        return makeSub( refType->get_base() );
     368                } else if ( StructInstType * aggInst = dynamic_cast< StructInstType * >( t ) ) {
    360369                        return TypeSubstitution( aggInst->get_baseParameters()->begin(), aggInst->get_baseParameters()->end(), aggInst->get_parameters().begin() );
    361370                } else if ( UnionInstType * aggInst = dynamic_cast< UnionInstType * >( t ) ) {
     
    422431        if ( Type * type = expr->get_result() ) {
    423432                Type * base = InitTweak::getPointerBase( type );
    424                 if ( ! base ) {
    425                         std::cerr << type << std::endl;
     433                assertf( base, "expected pointer type in dereference (type was %s)", toString( type ).c_str() );
     434                ret->set_result( base->clone() );
     435                if ( GenPoly::referencesPermissable() ) {
     436                        // if references are still allowed in the AST, dereference returns a reference
     437                        ret->set_result( new ReferenceType( Type::Qualifiers(), ret->get_result() ) );
     438                } else {
     439                        // references have been removed, in which case dereference returns an lvalue of the base type.
     440                        ret->get_result()->set_lvalue( true );
    426441                }
    427                 assertf( base, "expected pointer type in dereference\n" );
    428                 ret->set_result( maybeClone( base ) );
    429442        }
    430443        return ret;
     
    490503
    491504void LogicalExpr::print( std::ostream &os, int indent )const {
    492         os << std::string( indent, ' ' ) << "Short-circuited operation (" << (isAnd?"and":"or") << ") on: ";
     505        os << "Short-circuited operation (" << (isAnd?"and":"or") << ") on: ";
    493506        arg1->print(os);
    494507        os << " and ";
     
    595608CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : initializer( initializer ) {
    596609        assert( type && initializer );
     610        type->set_lvalue( true );
    597611        set_result( type );
    598612}
Note: See TracChangeset for help on using the changeset viewer.