Changeset b7778c1 for src/SynTree/AddressExpr.cc
- Timestamp:
- Oct 4, 2017, 3:31:43 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:
- 3364962
- Parents:
- 3628765 (diff), bb9d8e8 (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/AddressExpr.cc
r3628765 rb7778c1 33 33 Type * addrType( Type * type ) { 34 34 if ( ReferenceType * refType = dynamic_cast< ReferenceType * >( type ) ) { 35 return new ReferenceType( refType->get_qualifiers(), addrType( refType-> get_base()) );35 return new ReferenceType( refType->get_qualifiers(), addrType( refType->base ) ); 36 36 } else { 37 37 return new PointerType( Type::Qualifiers(), type->clone() ); … … 40 40 } 41 41 42 AddressExpr::AddressExpr( Expression *arg , Expression *_aname ) : Expression( _aname), arg( arg ) {43 if ( arg-> has_result()) {44 if ( arg-> get_result()->get_lvalue() ) {42 AddressExpr::AddressExpr( Expression *arg ) : Expression(), arg( arg ) { 43 if ( arg->result ) { 44 if ( arg->result->get_lvalue() ) { 45 45 // lvalue, retains all layers of reference and gains a pointer inside the references 46 set_result( addrType( arg-> get_result()) );46 set_result( addrType( arg->result ) ); 47 47 } else { 48 48 // taking address of non-lvalue -- must be a reference, loses one layer of reference 49 ReferenceType * refType = strict_dynamic_cast< ReferenceType * >( arg-> get_result());50 set_result( addrType( refType-> get_base()) );49 ReferenceType * refType = strict_dynamic_cast< ReferenceType * >( arg->result ); 50 set_result( addrType( refType->base ) ); 51 51 } 52 52 // result of & is never an lvalue … … 62 62 } 63 63 64 void AddressExpr::print( std::ostream &os, intindent ) const {64 void AddressExpr::print( std::ostream &os, Indenter indent ) const { 65 65 os << "Address of:" << std::endl; 66 66 if ( arg ) { 67 os << std::string( indent+2, ' ' );68 arg->print( os, indent+ 2);67 os << indent+1; 68 arg->print( os, indent+1 ); 69 69 } // if 70 70 } … … 77 77 LabelAddressExpr::~LabelAddressExpr() {} 78 78 79 void LabelAddressExpr::print( std::ostream & os, int indent) const {80 os << "Address of label:" << std::endl << std::string( indent+2, ' ' ) <<arg;79 void LabelAddressExpr::print( std::ostream & os, Indenter ) const { 80 os << "Address of label:" << arg; 81 81 } 82 82
Note: See TracChangeset
for help on using the changeset viewer.