Changeset b3b2077 for src/SynTree
- Timestamp:
- Nov 9, 2016, 2:05:09 PM (8 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:
- 23bb1b9
- Parents:
- 8780e30
- Location:
- src/SynTree
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/SynTree/Expression.cc ¶
r8780e30 rb3b2077 380 380 } 381 381 382 UntypedExpr * UntypedExpr::createDeref( Expression * expr ) { 383 UntypedExpr * ret = new UntypedExpr( new NameExpr("*?"), std::list< Expression * >{ expr } ); 384 if ( Type * type = expr->get_result() ) { 385 Type * base = InitTweak::getPointerBase( type ); 386 if ( ! base ) { 387 std::cerr << type << std::endl; 388 } 389 assertf( base, "expected pointer type in dereference\n" ); 390 ret->set_result( maybeClone( base ) ); 391 } 392 return ret; 393 } 394 395 UntypedExpr * UntypedExpr::createAssign( Expression * arg1, Expression * arg2 ) { 396 assert( arg1 && arg2 ); 397 UntypedExpr * ret = new UntypedExpr( new NameExpr( "?=?" ), std::list< Expression * >{ arg1, arg2 } ); 398 if ( arg1->get_result() && arg2->get_result() ) { 399 // if both expressions are typed, assumes that this assignment is a C bitwise assignment, 400 // so the result is the type of the RHS 401 ret->set_result( arg2->get_result()->clone() ); 402 } 403 return ret; 404 } 405 406 382 407 void UntypedExpr::print( std::ostream &os, int indent ) const { 383 408 os << "Applying untyped: " << std::endl; … … 446 471 447 472 void ConditionalExpr::print( std::ostream &os, int indent ) const { 448 os << std::string( indent, ' ' ) << "Conditional expression on: " << std::endl; 473 os << "Conditional expression on: " << std::endl; 474 os << std::string( indent+2, ' ' ); 449 475 arg1->print( os, indent+2 ); 450 476 os << std::string( indent, ' ' ) << "First alternative:" << std::endl; 477 os << std::string( indent+2, ' ' ); 451 478 arg2->print( os, indent+2 ); 452 479 os << std::string( indent, ' ' ) << "Second alternative:" << std::endl; 480 os << std::string( indent+2, ' ' ); 453 481 arg3->print( os, indent+2 ); 454 482 os << std::endl; -
TabularUnified src/SynTree/Expression.h ¶
r8780e30 rb3b2077 111 111 std::list<Expression*>& get_args() { return args; } 112 112 113 static UntypedExpr * createDeref( Expression * arg ); 114 static UntypedExpr * createAssign( Expression * arg1, Expression * arg2 ); 115 113 116 virtual UntypedExpr *clone() const { return new UntypedExpr( *this ); } 114 117 virtual void accept( Visitor &v ) { v.visit( this ); }
Note: See TracChangeset
for help on using the changeset viewer.