Changeset 0a81c3f
- Timestamp:
- Jul 13, 2017, 1:44:58 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:
- 2463d0e
- Parents:
- c6976ba
- Location:
- src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
rc6976ba r0a81c3f 338 338 if ( varExpr->get_var()->get_linkage() == LinkageSpec::Intrinsic && operatorLookup( varExpr->get_var()->get_name(), opInfo ) ) { 339 339 std::list< Expression* >::iterator arg = applicationExpr->get_args().begin(); 340 switch ( opInfo.type ) {341 case OT_PREFIXASSIGN:342 case OT_POSTFIXASSIGN:343 case OT_INFIXASSIGN:344 case OT_CTOR:345 case OT_DTOR:346 {347 assert( arg != applicationExpr->get_args().end() );348 if ( AddressExpr * addrExpr = dynamic_cast< AddressExpr * >( *arg ) ) {349 // remove & from first assignment/ctor argument350 *arg = addrExpr->get_arg();351 } else {352 // no address-of operator, so must be a pointer - add dereference353 // NOTE: if the assertion starts to trigger, check that the application expr isn't being shared.354 // Since its arguments are modified here, this assertion most commonly triggers when the application355 // is visited multiple times.356 UntypedExpr * newExpr = new UntypedExpr( new NameExpr( "*?" ) );357 newExpr->get_args().push_back( *arg );358 Type * type = InitTweak::getPointerBase( (*arg)->get_result() );359 assertf( type, "First argument to a derefence must be a pointer. Ensure that expressions are not being shared." );360 newExpr->set_result( type->clone() );361 *arg = newExpr;362 } // if363 break;364 }365 366 default:367 // do nothing368 ;369 } // switch370 371 340 switch ( opInfo.type ) { 372 341 case OT_INDEX: -
src/GenPoly/Box.cc
rc6976ba r0a81c3f 758 758 // if the argument's type is polymorphic, we don't need to box again! 759 759 return; 760 } else if ( arg->get_result()->get_lvalue() ) { 760 } else if ( arg->get_result()->get_lvalue() ) { // xxx - is this still right?? 761 // xxx - dynamic_cast<ReferenceType *>( arg->get_result() )?? 761 762 // VariableExpr and MemberExpr are lvalues; need to check this isn't coming from the second arg of a comma expression though (not an lvalue) 762 763 // xxx - need to test that this code is still reachable … … 1036 1037 assert( appExpr->has_result() ); 1037 1038 assert( ! appExpr->get_args().empty() ); 1038 if ( isPolyType( appExpr->get_result(), scopeTyVars, env ) ) { 1039 if ( isPolyPtr( appExpr->get_result(), scopeTyVars, env ) ) { // dereference returns a reference type 1040 // remove dereference from polymorphic types since they are boxed. 1039 1041 Expression *ret = appExpr->get_args().front(); 1040 1042 delete ret->get_result(); -
src/InitTweak/FixInit.cc
rc6976ba r0a81c3f 364 364 assert( ftype ); 365 365 if ( isConstructor( funcDecl->get_name() ) && ftype->get_parameters().size() == 2 ) { 366 Type * t1 = ftype->get_parameters().front()->get_type();366 Type * t1 = getPointerBase( ftype->get_parameters().front()->get_type() ); 367 367 Type * t2 = ftype->get_parameters().back()->get_type(); 368 PointerType * ptrType = safe_dynamic_cast< PointerType * >( t1 );369 370 if ( ResolvExpr::typesCompatible( ptrType->get_base(), t2, SymTab::Indexer() ) ) {368 assert( t1 ); 369 370 if ( ResolvExpr::typesCompatible( t1, t2, SymTab::Indexer() ) ) { 371 371 // optimization: don't need to copy construct in order to call a copy constructor 372 372 return appExpr; … … 489 489 impCpCtorExpr->get_returnDecls().push_back( ret ); 490 490 CP_CTOR_PRINT( std::cerr << "makeCtorDtor for a return" << std::endl; ) 491 if ( ! result->get_lvalue() ) {491 if ( ! dynamic_cast< ReferenceType * >( result ) ) { 492 492 // destructing lvalue returns is bad because it can cause multiple destructor calls to the same object - the returned object is not a temporary 493 493 destructRet( ret, impCpCtorExpr ); … … 997 997 assert( ! type->get_parameters().empty() ); 998 998 thisParam = safe_dynamic_cast< ObjectDecl * >( type->get_parameters().front() ); 999 PointerType * ptrType = safe_dynamic_cast< PointerType * >( thisParam->get_type() );1000 StructInstType * structType = dynamic_cast< StructInstType * >( ptrType->get_base());999 Type * thisType = getPointerBase( thisParam->get_type() ); 1000 StructInstType * structType = dynamic_cast< StructInstType * >( thisType ); 1001 1001 if ( structType ) { 1002 1002 structDecl = structType->get_baseStruct(); … … 1046 1046 // insert and resolve default/copy constructor call for each field that's unhandled 1047 1047 std::list< Statement * > stmt; 1048 UntypedExpr * deref = UntypedExpr::createDeref( new VariableExpr( thisParam ) );1049 1050 1048 Expression * arg2 = 0; 1051 1049 if ( isCopyConstructor( function ) ) { … … 1056 1054 } 1057 1055 InitExpander srcParam( arg2 ); 1058 SymTab::genImplicitCall( srcParam, new MemberExpr( field, deref), function->get_name(), back_inserter( stmt ), field, isCtor );1056 SymTab::genImplicitCall( srcParam, new MemberExpr( field, new VariableExpr( thisParam ) ), function->get_name(), back_inserter( stmt ), field, isCtor ); 1059 1057 1060 1058 assert( stmt.size() <= 1 );
Note: See TracChangeset
for help on using the changeset viewer.