Index: BasicCompiler_Common/Parameter.cpp
===================================================================
--- BasicCompiler_Common/Parameter.cpp	(revision 52)
+++ BasicCompiler_Common/Parameter.cpp	(revision 64)
@@ -58,6 +58,6 @@
 	}
 
-	ReturnTypeInfo.type=0;
-	ReturnTypeInfo.u.lpIndex=0;
+	ReturnTypeInfo.type=DEF_NON;
+	ReturnTypeInfo.u.lpIndex=-1;
 }
 CParameter::CParameter(const PARAMETER_INFO *pParamInfo,const int ParmNum){
@@ -70,6 +70,6 @@
 	this->ParmsNum=ParmNum;
 
-	ReturnTypeInfo.type=0;
-	ReturnTypeInfo.u.lpIndex=0;
+	ReturnTypeInfo.type=DEF_NON;
+	ReturnTypeInfo.u.lpIndex=-1;
 }
 CParameter::~CParameter(){
@@ -99,5 +99,7 @@
 		if(Parms[i]){
 			TYPEINFO BaseType={ppi[i].type,ppi[i].u.index};
-			type=NumOpe_GetType(Parms[i],&BaseType,&lpIndex);
+			type=NumOpe_GetType(Parms[i],
+				(overload_level==OVERLOAD_LEVEL0) ? NULL : &BaseType,
+				&lpIndex);
 		}
 		else{
@@ -107,5 +109,5 @@
 
 		if(type!=ppi[i].type){
-			if(overload_level==OVERLOAD_LEVEL1){
+			if(overload_level==OVERLOAD_LEVEL1 || overload_level == OVERLOAD_LEVEL0){
 				return 0;
 			}
@@ -121,5 +123,5 @@
 		}
 		else{
-			if(NATURAL_TYPE(type)==DEF_OBJECT){
+			if(NATURAL_TYPE(type)==DEF_OBJECT || NATURAL_TYPE(type)==DEF_STRUCT){
 				if(lpIndex!=ppi[i].u.index) return 0;
 			}
@@ -130,6 +132,7 @@
 		//戻り値も比較対象にする
 		if(ReturnTypeInfo.type==pReturnTypeInfo->type){
-			if(NATURAL_TYPE(ReturnTypeInfo.type)==DEF_OBJECT){
-				if(ReturnTypeInfo.u.lpIndex != pReturnTypeInfo->u.lpIndex) return 0;
+			if(NATURAL_TYPE(ReturnTypeInfo.type)==DEF_OBJECT
+				|| NATURAL_TYPE(ReturnTypeInfo.type)==DEF_STRUCT ){
+					if(ReturnTypeInfo.u.lpIndex != pReturnTypeInfo->u.lpIndex) return 0;
 			}
 		}
@@ -145,30 +148,13 @@
 	psi=0;
 
-	foreach( psi, subs ){
-
-		TYPEINFO ReturnTypeInfo;
-		ReturnTypeInfo.type=psi->ReturnType;
-		ReturnTypeInfo.u.lpIndex=psi->u.ReturnIndex;
-
-		//エラーチェック
-		if(_overload_check(psi->pParmInfo,psi->ParmNum,&ReturnTypeInfo,OVERLOAD_LEVEL1)){
-			if(sw){
-				SetError(52,name,cp);
-				return 0;
-			}
-			sw=1;
-			break;
-		}
-	}
-
-	if(!sw){
-		foreach( psi, subs ){
+	for( int level=OVERLOAD_MIN_LEVEL; level<=OVERLOAD_MAX_LEVEL; level++ ){
+		foreach( SUBINFO *temp_psi, subs ){
 
 			TYPEINFO ReturnTypeInfo;
-			ReturnTypeInfo.type=psi->ReturnType;
-			ReturnTypeInfo.u.lpIndex=psi->u.ReturnIndex;
+			ReturnTypeInfo.type=temp_psi->ReturnType;
+			ReturnTypeInfo.u.lpIndex=temp_psi->u.ReturnIndex;
 
 			//エラーチェック
-			if(_overload_check(psi->pParmInfo,psi->ParmNum,&ReturnTypeInfo,OVERLOAD_LEVEL2)){
+			if(_overload_check(temp_psi->pParmInfo,temp_psi->ParmNum,&ReturnTypeInfo,level)){
 				if(sw){
 					SetError(52,name,cp);
@@ -176,26 +162,11 @@
 				}
 				sw=1;
+
+				psi = temp_psi;
 				break;
 			}
 		}
-	}
-
-	if(!sw){
-		foreach( psi, subs ){
-
-			TYPEINFO ReturnTypeInfo;
-			ReturnTypeInfo.type=psi->ReturnType;
-			ReturnTypeInfo.u.lpIndex=psi->u.ReturnIndex;
-
-			//エラーチェック
-			if(_overload_check(psi->pParmInfo,psi->ParmNum,&ReturnTypeInfo,OVERLOAD_LEVEL3)){
-				if(sw){
-					SetError(52,name,cp);
-					return 0;
-				}
-				sw=1;
-				break;
-			}
-		}
+
+		if( sw ) break;
 	}
 
@@ -212,42 +183,20 @@
 	psi=0;
 
-	foreach( psi, subs ){
-
-		//エラーチェック
-		if(_overload_check(psi->pParmInfo,psi->ParmNum,NULL,OVERLOAD_LEVEL1)){
-			if(sw){
-				return OverloadSolutionWithReturnType(name,subs);
-			}
-			sw=1;
-			break;
-		}
-	}
-
-	if(!sw){
-		foreach( psi, subs ){
+	for( int level=OVERLOAD_MIN_LEVEL; level<=OVERLOAD_MAX_LEVEL; level++ ){
+
+		foreach( SUBINFO *temp_psi, subs ){
 
 			//エラーチェック
-			if(_overload_check(psi->pParmInfo,psi->ParmNum,NULL,OVERLOAD_LEVEL2)){
+			if(_overload_check(temp_psi->pParmInfo,temp_psi->ParmNum,NULL,level)){
 				if(sw){
 					return OverloadSolutionWithReturnType(name,subs);
 				}
 				sw=1;
-				break;
-			}
-		}
-	}
-
-	if(!sw){
-		foreach( psi, subs ){
-
-			//エラーチェック
-			if(_overload_check(psi->pParmInfo,psi->ParmNum,NULL,OVERLOAD_LEVEL3)){
-				if(sw){
-					return OverloadSolutionWithReturnType(name,subs);
-				}
-				sw=1;
-				break;
-			}
-		}
+
+				psi = temp_psi;
+			}
+		}
+
+		if( sw ) break;
 	}
 
