Changeset 28e58fd for src/GenPoly/Box.cc
- Timestamp:
- Aug 25, 2017, 10:38:34 AM (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:
- 800d275
- Parents:
- af08051 (diff), 3eab308c (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/GenPoly/Box.cc
raf08051 r28e58fd 25 25 26 26 #include "Box.h" 27 28 #include "CodeGen/OperatorTable.h" 27 29 #include "Common/ScopedMap.h" // for ScopedMap, ScopedMap<>::iter... 28 30 #include "Common/SemanticError.h" // for SemanticError … … 564 566 // To compound the issue, the right side can be *x, etc. because of lvalue-returning functions 565 567 if ( UntypedExpr * assign = dynamic_cast< UntypedExpr * >( commaExpr->get_arg1() ) ) { 566 if ( InitTweak::isAssignment( InitTweak::getFunctionName( assign ) ) ) {568 if ( CodeGen::isAssignment( InitTweak::getFunctionName( assign ) ) ) { 567 569 assert( assign->get_args().size() == 2 ); 568 570 if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * > ( assign->get_args().back() ) ) { … … 604 606 } 605 607 } else { 606 throw SemanticError( "Cannot pass non-struct type for generic struct ");608 throw SemanticError( "Cannot pass non-struct type for generic struct: ", argBaseType ); 607 609 } 608 610 } … … 1019 1021 } // if 1020 1022 if ( baseType1 || baseType2 ) { 1023 delete ret->get_result(); 1021 1024 ret->set_result( appExpr->get_result()->clone() ); 1022 1025 if ( appExpr->get_env() ) { … … 1032 1035 assert( ! appExpr->get_args().empty() ); 1033 1036 if ( isPolyType( appExpr->get_result(), scopeTyVars, env ) ) { 1037 // remove dereference from polymorphic types since they are boxed. 1034 1038 Expression *ret = appExpr->get_args().front(); 1039 // fix expr type to remove pointer 1035 1040 delete ret->get_result(); 1036 1041 ret->set_result( appExpr->get_result()->clone() ); … … 1122 1127 1123 1128 assert( appExpr->get_function()->has_result() ); 1124 PointerType *pointer = safe_dynamic_cast< PointerType *>( appExpr->get_function()->get_result() );1125 FunctionType *function = safe_dynamic_cast< FunctionType *>( pointer->get_base() );1129 FunctionType * function = getFunctionType( appExpr->get_function()->get_result() ); 1130 assertf( function, "ApplicationExpr has non-function type: %s", toString( appExpr->get_function()->get_result() ).c_str() ); 1126 1131 1127 1132 if ( Expression *newExpr = handleIntrinsics( appExpr ) ) { … … 1200 1205 if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( expr->get_args().front() ) ) { 1201 1206 assert( appExpr->get_function()->has_result() ); 1202 PointerType *pointer = safe_dynamic_cast< PointerType *>( appExpr->get_function()->get_result() );1203 FunctionType *function = safe_dynamic_cast< FunctionType *>( pointer->get_base());1207 FunctionType *function = getFunctionType( appExpr->get_function()->get_result() ); 1208 assert( function ); 1204 1209 needs = needsAdapter( function, scopeTyVars ); 1205 1210 } // if … … 1210 1215 // isPolyType check needs to happen before mutating addrExpr arg, so pull it forward 1211 1216 // out of the if condition. 1217 addrExpr->set_arg( mutateExpression( addrExpr->get_arg() ) ); 1218 // ... but must happen after mutate, since argument might change (e.g. intrinsic *?, ?[?]) - re-evaluate above comment 1212 1219 bool polytype = isPolyType( addrExpr->get_arg()->get_result(), scopeTyVars, env ); 1213 addrExpr->set_arg( mutateExpression( addrExpr->get_arg() ) );1214 1220 if ( polytype || needs ) { 1215 1221 Expression *ret = addrExpr->get_arg(); … … 1278 1284 if ( adaptersDone.find( mangleName ) == adaptersDone.end() ) { 1279 1285 std::string adapterName = makeAdapterName( mangleName ); 1280 paramList.push_front( new ObjectDecl( adapterName, Type::StorageClasses(), LinkageSpec::C, 0, new PointerType( Type::Qualifiers(), makeAdapterType( *funType, scopeTyVars ) ), 0 ) ); 1286 // adapter may not be used in body, pass along with unused attribute. 1287 paramList.push_front( new ObjectDecl( adapterName, Type::StorageClasses(), LinkageSpec::C, 0, new PointerType( Type::Qualifiers(), makeAdapterType( *funType, scopeTyVars ) ), 0, { new Attribute( "unused" ) } ) ); 1281 1288 adaptersDone.insert( adaptersDone.begin(), mangleName ); 1282 1289 } … … 1384 1391 std::list< DeclarationWithType *>::iterator last = funcType->get_parameters().begin(); 1385 1392 std::list< DeclarationWithType *> inferredParams; 1386 ObjectDecl newObj( "", Type::StorageClasses(), LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0 ); 1393 // size/align/offset parameters may not be used in body, pass along with unused attribute. 1394 ObjectDecl newObj( "", Type::StorageClasses(), LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, 1395 { new Attribute( "unused" ) } ); 1387 1396 ObjectDecl newPtr( "", Type::StorageClasses(), LinkageSpec::C, 0, 1388 1397 new PointerType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ), 0 ); … … 1407 1416 for ( std::list< DeclarationWithType *>::iterator assert = (*tyParm)->get_assertions().begin(); assert != (*tyParm)->get_assertions().end(); ++assert ) { 1408 1417 // *assert = (*assert)->acceptMutator( *this ); 1418 // assertion parameters may not be used in body, pass along with unused attribute. 1419 (*assert)->get_attributes().push_back( new Attribute( "unused" ) ); 1409 1420 inferredParams.push_back( *assert ); 1410 1421 }
Note:
See TracChangeset
for help on using the changeset viewer.