Changeset 83794e1 for src/GenPoly
- Timestamp:
- Aug 8, 2017, 8:22:34 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:
- b1bead1
- Parents:
- e25707d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Box.cc
re25707d r83794e1 755 755 756 756 void Pass1::boxParam( Type *param, Expression *&arg, const TyVarMap &exprTyVars ) { 757 assert ( arg->has_result() );757 assertf( arg->has_result(), "arg does not have result: %s", toString( arg ).c_str() ); 758 758 if ( isPolyType( param, exprTyVars ) ) { 759 759 if ( isPolyType( arg->get_result() ) ) { … … 1027 1027 } // if 1028 1028 if ( baseType1 || baseType2 ) { 1029 Type * baseType = InitTweak::getPointerBase( appExpr->get_result() ); 1030 assert( baseType ); 1031 ret->set_result( baseType->clone() ); 1029 delete ret->get_result(); 1030 ret->set_result( appExpr->get_result()->clone() ); 1032 1031 if ( appExpr->get_env() ) { 1033 1032 ret->set_env( appExpr->get_env() ); … … 1041 1040 assert( appExpr->has_result() ); 1042 1041 assert( ! appExpr->get_args().empty() ); 1043 if ( isPoly Ptr( appExpr->get_result(), scopeTyVars, env ) ) { // dereference returns a reference type1042 if ( isPolyType( appExpr->get_result(), scopeTyVars, env ) ) { 1044 1043 // remove dereference from polymorphic types since they are boxed. 1045 1044 Expression *ret = appExpr->get_args().front(); 1046 // fix expr type to remove reference1045 // fix expr type to remove pointer 1047 1046 delete ret->get_result(); 1048 Type * baseType = InitTweak::getPointerBase( appExpr->get_result() ); 1049 assert( baseType ); 1050 ret->set_result( baseType->clone() ); 1047 ret->set_result( appExpr->get_result()->clone() ); 1051 1048 if ( appExpr->get_env() ) { 1052 1049 ret->set_env( appExpr->get_env() ); … … 1136 1133 1137 1134 assert( appExpr->get_function()->has_result() ); 1138 PointerType *pointer = safe_dynamic_cast< PointerType *>( appExpr->get_function()->get_result() );1139 FunctionType *function = safe_dynamic_cast< FunctionType *>( pointer->get_base() );1135 FunctionType * function = getFunctionType( appExpr->get_function()->get_result() ); 1136 assertf( function, "ApplicationExpr has non-function type: %s", toString( appExpr->get_function()->get_result() ).c_str() ); 1140 1137 1141 1138 if ( Expression *newExpr = handleIntrinsics( appExpr ) ) { … … 1214 1211 if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( expr->get_args().front() ) ) { 1215 1212 assert( appExpr->get_function()->has_result() ); 1216 PointerType *pointer = safe_dynamic_cast< PointerType *>( appExpr->get_function()->get_result() );1217 FunctionType *function = safe_dynamic_cast< FunctionType *>( pointer->get_base());1213 FunctionType *function = getFunctionType( appExpr->get_function()->get_result() ); 1214 assert( function ); 1218 1215 needs = needsAdapter( function, scopeTyVars ); 1219 1216 } // if … … 1293 1290 if ( adaptersDone.find( mangleName ) == adaptersDone.end() ) { 1294 1291 std::string adapterName = makeAdapterName( mangleName ); 1295 paramList.push_front( new ObjectDecl( adapterName, Type::StorageClasses(), LinkageSpec::C, 0, new PointerType( Type::Qualifiers(), makeAdapterType( *funType, scopeTyVars ) ), 0 ) ); 1292 // adapter may not be used in body, pass along with unused attribute. 1293 paramList.push_front( new ObjectDecl( adapterName, Type::StorageClasses(), LinkageSpec::C, 0, new PointerType( Type::Qualifiers(), makeAdapterType( *funType, scopeTyVars ) ), 0, { new Attribute( "unused" ) } ) ); 1296 1294 adaptersDone.insert( adaptersDone.begin(), mangleName ); 1297 1295 } … … 1399 1397 std::list< DeclarationWithType *>::iterator last = funcType->get_parameters().begin(); 1400 1398 std::list< DeclarationWithType *> inferredParams; 1401 ObjectDecl newObj( "", Type::StorageClasses(), LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0 ); 1399 // size/align/offset parameters may not be used in body, pass along with unused attribute. 1400 ObjectDecl newObj( "", Type::StorageClasses(), LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, 1401 { new Attribute( "unused" ) } ); 1402 1402 ObjectDecl newPtr( "", Type::StorageClasses(), LinkageSpec::C, 0, 1403 1403 new PointerType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ), 0 ); … … 1422 1422 for ( std::list< DeclarationWithType *>::iterator assert = (*tyParm)->get_assertions().begin(); assert != (*tyParm)->get_assertions().end(); ++assert ) { 1423 1423 // *assert = (*assert)->acceptMutator( *this ); 1424 // assertion parameters may not be used in body, pass along with unused attribute. 1425 (*assert)->get_attributes().push_back( new Attribute( "unused" ) ); 1424 1426 inferredParams.push_back( *assert ); 1425 1427 }
Note: See TracChangeset
for help on using the changeset viewer.