Changeset d3e4d6c for src/SynTree/Expression.cc
- Timestamp:
- Aug 23, 2017, 6:22:07 PM (7 years ago)
- 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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Expression.cc
r9f07232 rd3e4d6c 31 31 #include "TypeSubstitution.h" // for TypeSubstitution 32 32 33 #include "GenPoly/Lvalue.h" 33 34 34 35 Expression::Expression( Expression *_aname ) : result( 0 ), env( 0 ), argName( _aname ) {} … … 89 90 } 90 91 92 VariableExpr * 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 91 98 void VariableExpr::print( std::ostream &os, int indent ) const { 92 99 os << "Variable Expression: "; … … 149 156 150 157 void AlignofExpr::print( std::ostream &os, int indent) const { 151 os << std::string( indent, ' ' ) <<"Alignof Expression on: ";158 os << "Alignof Expression on: "; 152 159 153 160 if (isType) … … 258 265 259 266 void AttrExpr::print( std::ostream &os, int indent) const { 260 os << std::string( indent, ' ' ) <<"Attr ";267 os << "Attr "; 261 268 attr->print( os, indent + 2 ); 262 269 if ( isType || expr ) { … … 357 364 namespace { 358 365 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 ) ) { 360 369 return TypeSubstitution( aggInst->get_baseParameters()->begin(), aggInst->get_baseParameters()->end(), aggInst->get_parameters().begin() ); 361 370 } else if ( UnionInstType * aggInst = dynamic_cast< UnionInstType * >( t ) ) { … … 422 431 if ( Type * type = expr->get_result() ) { 423 432 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 ); 426 441 } 427 assertf( base, "expected pointer type in dereference\n" );428 ret->set_result( maybeClone( base ) );429 442 } 430 443 return ret; … … 490 503 491 504 void 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: "; 493 506 arg1->print(os); 494 507 os << " and "; … … 595 608 CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : initializer( initializer ) { 596 609 assert( type && initializer ); 610 type->set_lvalue( true ); 597 611 set_result( type ); 598 612 }
Note: See TracChangeset
for help on using the changeset viewer.