Changeset 0690350
- Timestamp:
- Jan 12, 2018, 4:57:40 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:
- 1a4bef3
- Parents:
- bd0b6b62
- git-author:
- Rob Schluntz <rschlunt@…> (01/12/18 15:24:25)
- git-committer:
- Rob Schluntz <rschlunt@…> (01/12/18 16:57:40)
- Location:
- src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Box.cc
rbd0b6b62 r0690350 302 302 Expression *makeOp( const std::string &name, Expression *arg ) { 303 303 UntypedExpr *expr = new UntypedExpr( new NameExpr( name ) ); 304 expr-> get_args().push_back( arg );304 expr->args.push_back( arg ); 305 305 return expr; 306 306 } … … 309 309 Expression *makeOp( const std::string &name, Expression *lhs, Expression *rhs ) { 310 310 UntypedExpr *expr = new UntypedExpr( new NameExpr( name ) ); 311 expr-> get_args().push_back( lhs );312 expr-> get_args().push_back( rhs );311 expr->args.push_back( lhs ); 312 expr->args.push_back( rhs ); 313 313 return expr; 314 314 } … … 316 316 /// Returns the dereference of a local pointer variable 317 317 Expression *derefVar( ObjectDecl *var ) { 318 return makeOp( "*?",new VariableExpr( var ) );318 return UntypedExpr::createDeref( new VariableExpr( var ) ); 319 319 } 320 320 … … 831 831 if ( ! isPolyType( arg->get_type() ) ) { 832 832 UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) ); 833 deref-> get_args().push_back( new CastExpr( new VariableExpr( param ), new PointerType( Type::Qualifiers(), arg->get_type()->clone() ) ) );834 deref-> set_result( arg->get_type()->clone());833 deref->args.push_back( new CastExpr( new VariableExpr( param ), new PointerType( Type::Qualifiers(), arg->get_type()->clone() ) ) ); 834 deref->result = arg->get_type()->clone(); 835 835 return deref; 836 836 } // if -
src/GenPoly/Lvalue.cc
rbd0b6b62 r0690350 47 47 if ( SymTab::dereferenceOperator ) { 48 48 VariableExpr * deref = new VariableExpr( SymTab::dereferenceOperator ); 49 deref-> set_result( new PointerType( Type::Qualifiers(), deref->get_result() ));50 Type * base = InitTweak::getPointerBase( arg-> get_result());51 assertf( base, "expected pointer type in dereference (type was %s)", toString( arg-> get_result()).c_str() );49 deref->result = new PointerType( Type::Qualifiers(), deref->result ); 50 Type * base = InitTweak::getPointerBase( arg->result ); 51 assertf( base, "expected pointer type in dereference (type was %s)", toString( arg->result ).c_str() ); 52 52 ApplicationExpr * ret = new ApplicationExpr( deref, { arg } ); 53 delete ret-> get_result();54 ret-> set_result( base->clone());55 ret-> get_result()->set_lvalue( true );53 delete ret->result; 54 ret->result = base->clone(); 55 ret->result->set_lvalue( true ); 56 56 return ret; 57 57 } else { … … 308 308 int diff = depth1-depth2; 309 309 if ( diff == 0 ) { 310 // conversion between references of the same depth 310 311 assertf( depth1 == depth2, "non-intrinsic reference with cast of reference to reference not yet supported: %d %d %s", depth1, depth2, toString( castExpr ).c_str() ); 311 312 PRINT( std::cerr << castExpr << std::endl; ) 312 313 return castExpr; 313 314 } else if ( diff < 0 ) { 314 Expression * ret = castExpr->get_arg(); 315 // conversion from reference to reference with less depth (e.g. int && -> int &): add dereferences 316 Expression * ret = castExpr->arg; 315 317 for ( int i = 0; i < diff; ++i ) { 316 318 ret = mkDeref( ret ); 317 319 } 318 ret-> set_env( castExpr->get_env() );319 delete ret-> get_result();320 ret-> set_result( castExpr->get_result() );321 castExpr-> set_env( nullptr );322 castExpr-> set_arg( nullptr );323 castExpr-> set_result( nullptr );320 ret->env = castExpr->env; 321 delete ret->result; 322 ret->result = castExpr->result; 323 castExpr->env = nullptr; 324 castExpr->arg = nullptr; 325 castExpr->result = nullptr; 324 326 delete castExpr; 325 327 return ret; 326 328 } else if ( diff > 0 ) { 327 Expression * ret = castExpr->get_arg(); 329 // conversion from reference to reference with more depth (e.g. int & -> int &&): add address-of 330 Expression * ret = castExpr->arg; 328 331 for ( int i = 0; i < diff; ++i ) { 329 332 ret = new AddressExpr( ret ); 330 333 } 331 ret-> set_env( castExpr->get_env() );332 delete ret-> get_result();333 ret-> set_result( castExpr->get_result() );334 castExpr-> set_env( nullptr );335 castExpr-> set_arg( nullptr );336 castExpr-> set_result( nullptr );334 ret->env = castExpr->env; 335 delete ret->result; 336 ret->result = castExpr->result; 337 castExpr->env = nullptr; 338 castExpr->arg = nullptr; 339 castExpr->result = nullptr; 337 340 delete castExpr; 338 341 return ret; … … 342 345 PRINT( std::cerr << castExpr << std::endl; ) 343 346 return castExpr; 344 } else if ( castExpr-> get_arg()->get_result()->get_lvalue() ) {347 } else if ( castExpr->arg->result->get_lvalue() ) { 345 348 // conversion from lvalue to reference 346 349 // xxx - keep cast, but turn into pointer cast?? … … 348 351 PRINT( 349 352 std::cerr << "convert lvalue to reference -- &" << std::endl; 350 std::cerr << castExpr-> get_arg()<< std::endl;353 std::cerr << castExpr->arg << std::endl; 351 354 ) 352 AddressExpr * ret = new AddressExpr( castExpr-> get_arg());353 if ( refType-> get_base()->get_qualifiers() != castExpr->get_arg()->get_result()->get_qualifiers() ) {355 AddressExpr * ret = new AddressExpr( castExpr->arg ); 356 if ( refType->base->get_qualifiers() != castExpr->arg->result->get_qualifiers() ) { 354 357 // must keep cast if cast-to type is different from the actual type 355 castExpr-> set_arg( ret );358 castExpr->arg = ret; 356 359 return castExpr; 357 360 } 358 ret-> set_env( castExpr->get_env() );359 delete ret-> get_result();360 ret-> set_result( castExpr->get_result() );361 castExpr-> set_env( nullptr );362 castExpr-> set_arg( nullptr );363 castExpr-> set_result( nullptr );361 ret->env = castExpr->env; 362 delete ret->result; 363 ret->result = castExpr->result; 364 castExpr->env = nullptr; 365 castExpr->arg = nullptr; 366 castExpr->result = nullptr; 364 367 delete castExpr; 365 368 return ret; … … 368 371 } 369 372 assertf( false, "Only conversions to reference from lvalue are currently supported: %s", toString( castExpr ).c_str() ); 370 } else if ( ReferenceType * refType = dynamic_cast< ReferenceType * >( castExpr-> get_arg()->get_result()) ) {373 } else if ( ReferenceType * refType = dynamic_cast< ReferenceType * >( castExpr->arg->result ) ) { 371 374 (void)refType; 372 375 // conversion from reference to rvalue … … 375 378 std::cerr << "was = " << castExpr << std::endl; 376 379 ) 377 Expression * ret = castExpr-> get_arg();378 TypeSubstitution * env = castExpr-> get_env();380 Expression * ret = castExpr->arg; 381 TypeSubstitution * env = castExpr->env; 379 382 castExpr->set_env( nullptr ); 380 383 if ( ! isIntrinsicReference( ret ) ) { … … 382 385 ret = mkDeref( ret ); 383 386 } 384 if ( ResolvExpr::typesCompatibleIgnoreQualifiers( castExpr-> get_result(), castExpr->get_arg()->get_result()->stripReferences(), SymTab::Indexer() ) ) {387 if ( ResolvExpr::typesCompatibleIgnoreQualifiers( castExpr->result, castExpr->arg->result->stripReferences(), SymTab::Indexer() ) ) { 385 388 // can remove cast if types are compatible, changing expression type to value type 386 ret-> set_result( castExpr->get_result()->clone());387 castExpr-> set_arg( nullptr );389 ret->result = castExpr->result->clone(); 390 castExpr->arg = nullptr; 388 391 delete castExpr; 389 392 } else { 390 393 // must keep cast if types are different 391 castExpr-> set_arg( ret );394 castExpr->arg = ret; 392 395 ret = castExpr; 393 396 } -
src/SynTree/AggregateDecl.cc
rbd0b6b62 r0690350 92 92 } else if ( ConstantExpr * constExpr = dynamic_cast< ConstantExpr * >( expr ) ) { 93 93 return constExpr->intValue(); 94 // can be -1, +1, etc. 95 // } else if ( UntypedExpr * untypedExpr = dynamic_cast< UntypedExpr * >( expr ) ) { 96 // if ( untypedExpr-> ) 94 97 } else { 95 98 assertf( false, "Unhandled expression type in getConstValue for enumerators: %s", toString( expr ).c_str() ); -
src/SynTree/Expression.cc
rbd0b6b62 r0690350 108 108 // assert( inst->baseEnum ); 109 109 // EnumDecl * decl = inst->baseEnum; 110 // for ( Declaration * member : decl->members ) { 111 // if ( member == _var ) { 112 // type->set_lvalue( false ); 113 // } 110 // long long int value; 111 // if ( decl->valueOf( var, value ) ) { 112 // type->set_lvalue( false ); 114 113 // } 115 114 // } … … 416 415 } else { 417 416 // references have been removed, in which case dereference returns an lvalue of the base type. 418 ret-> get_result()->set_lvalue( true );417 ret->result->set_lvalue( true ); 419 418 } 420 419 }
Note: See TracChangeset
for help on using the changeset viewer.