Changeset 424 in dev for trunk/abdev/BasicCompiler_Common/ParamImpl.cpp
- Timestamp:
- Mar 10, 2008, 5:39:36 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler_Common/ParamImpl.cpp
r364 r424 107 107 } 108 108 109 bool ParamImpl::EvaluateOverloadScore( int level, const Parameters &targetParms, const Type &targetResultType, bool &isErrored ){109 bool ParamImpl::EvaluateOverloadScore( int level, const Parameters &targetParms, const Type &targetResultType, const Type &leftType, const UserProc &userProc, bool &isErrored ){ 110 110 //パラメータを識別してオーバーロードを解決 111 111 … … 124 124 for(int i=0;i<max;i++){ 125 125 Parameter ¶m = *targetParms[i]; 126 127 Type paramType( param ); 128 ResolveFormalGenericTypeParameter( paramType, leftType, &userProc ); 126 129 127 130 if( i >= ParmsNum ){ … … 140 143 141 144 if( !NumOpe_GetType(Parms[i], 142 ( level <= OVERLOAD_LEVEL3 )? nullParam : param ,145 ( level <= OVERLOAD_LEVEL3 )? nullParam : paramType, 143 146 argType) ) 144 147 { … … 151 154 } 152 155 153 if(argType.GetBasicType()!=param.GetBasicType()){ 156 if( ( argType.IsObject() && paramType.IsObject() ) || argType.GetBasicType() == paramType.GetBasicType() ) 157 { 158 if( argType.IsStruct() ){ 159 if(argType.GetIndex()!=paramType.GetIndex()){ 160 return false; 161 } 162 } 163 else if( argType.IsObject() ){ 164 if( level == OVERLOAD_LEVEL0 ){ 165 if( !paramType.GetClass().IsEquals( &argType.GetClass() ) ){ 166 return false; 167 } 168 } 169 else{ 170 if( !paramType.GetClass().IsEqualsOrSubClass( &argType.GetClass() ) ){ 171 return false; 172 } 173 } 174 } 175 } 176 else 177 { 154 178 if( level == OVERLOAD_LEVEL0 || level == OVERLOAD_LEVEL1 || level==OVERLOAD_LEVEL4 ){ 155 179 return false; 156 180 } 157 181 else if( level == OVERLOAD_LEVEL2 ){ 158 if( !(argType.IsWhole() && param .IsWhole() && argType.GetBasicSize() == param.GetBasicSize() ) ){182 if( !(argType.IsWhole() && paramType.IsWhole() && argType.GetBasicSize() == paramType.GetBasicSize() ) ){ 159 183 // サイズ違い 160 184 return false; … … 163 187 else if( level == OVERLOAD_LEVEL3 || level==OVERLOAD_LEVEL5){ 164 188 if(!( 165 argType.IsWhole()&¶m .IsWhole()||166 argType.IsReal()&¶m .IsReal()189 argType.IsWhole()&¶mType.IsWhole()|| 190 argType.IsReal()&¶mType.IsReal() 167 191 )){ 168 192 return false; 169 193 } 170 if( argType.IsPointer() || param .IsPointer() )194 if( argType.IsPointer() || paramType.IsPointer() ) 171 195 { 172 196 // ポインタ型の不整合は認めない … … 175 199 } 176 200 else if(level==OVERLOAD_LEVEL6){ 177 if(argType.IsObject()||param.IsObject()) return false; 178 } 179 } 180 else{ 181 if( NATURAL_TYPE(argType.GetBasicType())==DEF_STRUCT){ 182 if(argType.GetIndex()!=param.GetIndex()){ 183 return false; 184 } 185 } 186 else if( NATURAL_TYPE(argType.GetBasicType())==DEF_OBJECT ){ 187 if( level == OVERLOAD_LEVEL0 ){ 188 if( !param.GetClass().IsEquals( &argType.GetClass() ) ){ 189 return false; 190 } 191 } 192 else{ 193 if( !param.GetClass().IsEqualsOrSubClass( &argType.GetClass() ) ){ 194 return false; 195 } 196 } 201 if(argType.IsObject()||paramType.IsObject()) return false; 197 202 } 198 203 } … … 209 214 } 210 215 211 const UserProc *ParamImpl::_OverloadSolution( const char *name, std::vector<const UserProc *> &subs, bool isEnabledReturnType ){216 const UserProc *ParamImpl::_OverloadSolution( const char *name, std::vector<const UserProc *> &subs, const Type &leftType, bool isEnabledReturnType ){ 212 217 const UserProc *pUserProc = NULL; 213 218 … … 218 223 bool isErrored = false; 219 224 bool isHit = false; 220 isHit = EvaluateOverloadScore( level, pTempUserProc->Params(), isEnabledReturnType?pTempUserProc->ReturnType():Type(), isErrored );225 isHit = EvaluateOverloadScore( level, pTempUserProc->Params(), isEnabledReturnType?pTempUserProc->ReturnType():Type(), leftType, *pTempUserProc, isErrored ); 221 226 if( isErrored ) 222 227 { … … 239 244 trace_for_overload( "戻り値も比較するモードに切り替えてオーバーロード解決を試みる" ); 240 245 241 return OverloadSolution( name,subs, true);246 return OverloadSolution( name, subs, leftType, true); 242 247 } 243 248 } … … 278 283 return pUserProc; 279 284 } 280 const UserProc *ParamImpl::OverloadSolution( const char *name, std::vector<const UserProc *> &subs, bool isEnabledReturnType ){285 const UserProc *ParamImpl::OverloadSolution( const char *name, std::vector<const UserProc *> &subs, const Type &leftType, bool isEnabledReturnType ){ 281 286 trace_for_overload( "" ); 282 287 trace_for_overload( "■■■■■■■■■■■■■■■■■■" ); 283 288 trace_for_overload( "■■■ オーバーロード解決(" << name << ")" ); 284 289 285 const UserProc *result = _OverloadSolution( name, subs, isEnabledReturnType );290 const UserProc *result = _OverloadSolution( name, subs, leftType, isEnabledReturnType ); 286 291 287 292 trace_for_overload( "■■■ ここまで" );
Note:
See TracChangeset
for help on using the changeset viewer.