Changeset b3b2077
- 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
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Specialize.cc
r8780e30 rb3b2077 147 147 148 148 Expression * Specialize::doSpecialization( Type *formalType, Expression *actual, InferredParams *inferParams ) { 149 assert ( actual->has_result());149 assertf( actual->has_result(), "attempting to specialize an untyped expression" ); 150 150 if ( needsSpecialization( formalType, actual->get_result(), env ) ) { 151 151 FunctionType *funType; -
src/InitTweak/FixInit.cc
r8780e30 rb3b2077 509 509 // an AddressExpr. Effectively, this turns 510 510 // lvalue T f(); 511 // &*f() 511 // &*f(); 512 512 // into 513 // T * f(); 513 514 // T * tmp_cp_retN; 514 // tmp_cp_ret_N = &*(tmp_cp_ret_N = &*f(), tmp_cp_ret);515 // &*(tmp_cp_retN = &*f(), tmp_cp_retN); // the first * and second & are generated here 515 516 // which work out in terms of types, but is pretty messy. It would be nice to find a better way. 516 517 assign->get_args().back() = new AddressExpr( assign->get_args().back() ); 517 518 518 Type * resultType = returnDecl->get_type()->clone();519 519 returnDecl->set_type( new PointerType( Type::Qualifiers(), returnDecl->get_type() ) ); 520 UntypedExpr * deref = new UntypedExpr( new NameExpr( "*?" ) ); 521 deref->get_args().push_back( retExpr ); 522 deref->set_result( resultType ); 523 retExpr = deref; 520 retExpr->set_result( new PointerType( Type::Qualifiers(), retExpr->get_result() ) ); 521 retExpr = UntypedExpr::createDeref( retExpr ); 524 522 } // if 525 523 retExpr->set_env( env->clone() ); -
src/SymTab/Validate.cc
r8780e30 rb3b2077 241 241 return dynamic_cast< StructDecl * >( decl ) || dynamic_cast< UnionDecl * >( decl ); 242 242 } 243 243 // xxx - shouldn't this be declsToAddBefore? 244 244 template< typename AggDecl > 245 245 void HoistStruct::handleAggregate( AggDecl *aggregateDecl ) { -
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; -
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 ); } -
src/Tuples/TupleAssignment.cc
r8780e30 rb3b2077 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Mon May 18 15:02:53 201511 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Nov 9 13:48:42 2016 13 13 // Update Count : 2 14 14 // … … 180 180 // explode the lhs so that each field of the tuple-valued-expr is assigned. 181 181 explode( lhsAlt, spotter.currentFinder.get_indexer(), back_inserter(lhs) ); 182 182 183 // and finally, re-add the cast to each lhs expr, so that qualified tuple fields can be constructed 183 184 if ( isCast ) { … … 192 193 } 193 194 } 194 // } 195 } 196 197 TupleAssignSpotter::MassAssignMatcher::MassAssignMatcher( TupleAssignSpotter &spotter,const ResolvExpr::AltList & alts ) : Matcher( spotter, alts ) { 195 } 196 197 TupleAssignSpotter::MassAssignMatcher::MassAssignMatcher( TupleAssignSpotter &spotter, const ResolvExpr::AltList & alts ) : Matcher( spotter, alts ) { 198 198 assert( alts.size() == 1 || alts.size() == 2 ); 199 199 if ( alts.size() == 2 ) { … … 210 210 assert( left ); 211 211 std::list< Expression * > args; 212 args.push_back( new AddressExpr( new UntypedExpr( new NameExpr("*?"), std::list< Expression * >{ new VariableExpr( left ) }) ) );212 args.push_back( new AddressExpr( UntypedExpr::createDeref( new VariableExpr( left ) ) ) ); 213 213 // args.push_back( new AddressExpr( new VariableExpr( left ) ) ); 214 214 if ( right ) args.push_back( new VariableExpr( right ) ); … … 238 238 static UniqueName lhsNamer( "__multassign_L" ); 239 239 static UniqueName rhsNamer( "__multassign_R" ); 240 240 241 // xxx - need more complicated matching? 241 242 if ( lhs.size() == rhs.size() ) {
Note: See TracChangeset
for help on using the changeset viewer.