Index: BasicCompiler_Common/ParamImpl.cpp
===================================================================
--- BasicCompiler_Common/ParamImpl.cpp	(revision 73)
+++ BasicCompiler_Common/ParamImpl.cpp	(revision 75)
@@ -7,5 +7,7 @@
 #endif
 
-ParamImpl::ParamImpl(const char *buffer){
+ParamImpl::ParamImpl(const char *buffer):
+	returnType()
+{
 	///////////////////////////
 	// パラメータ文字列を整理
@@ -55,33 +57,19 @@
 		ParmsNum++;
 
+		types.push_back( Type() );
+
 		if(buffer[i]==',') i++;
 	}
-
-	ReturnTypeInfo.type=DEF_NON;
-	ReturnTypeInfo.u.lpIndex=-1;
-}
-ParamImpl::ParamImpl(const PARAMETER_INFO *pParamInfo,const int ParmNum){
-	int i;
-	for(i=0;i<ParmNum;i++){
-		Parms[i]=0;
-		types[i].type=pParamInfo[i].type;
-		types[i].u.lpIndex=pParamInfo[i].u.index;
-	}
-	this->ParmsNum=ParmNum;
-
-	ReturnTypeInfo.type=DEF_NON;
-	ReturnTypeInfo.u.lpIndex=-1;
-}
-ParamImpl::ParamImpl(const Parameters &params){
-	int count = 0;
+}
+ParamImpl::ParamImpl(const Parameters &params):
+	returnType()
+{
+	ParmsNum = 0;
 	foreach( Parameter *pParam, params ){
-		types[count].type = pParam->GetBasicType();
-		types[count].u.lpIndex = pParam->GetIndex();
-		count++;
-	}
-	this->ParmsNum=params.size();
-
-	ReturnTypeInfo.type=DEF_NON;
-	ReturnTypeInfo.u.lpIndex=-1;
+		Parms[ParmsNum]=0;
+		ParmsNum++;
+
+		types.push_back( *pParam );
+	}
 }
 ParamImpl::~ParamImpl(){
@@ -96,18 +84,20 @@
 }
 
-void ParamImpl::SetReturnType(TYPEINFO *pTypeInfo){
-	ReturnTypeInfo=*pTypeInfo;
-}
-
-BOOL ParamImpl::_overload_check( Parameters &params,TYPEINFO *pReturnTypeInfo,int overload_level){
+void ParamImpl::SetReturnType( const Type &returnType ){
+	this->returnType = returnType;
+}
+
+bool ParamImpl::_overload_check( int level, const Parameters &targetParms, const Type &targetResultType ){
 	//パラメータを識別してオーバーロードを解決
 
 	//パラメータの個数が不一致の場合
-	int max = (int)params.size();
-	if(max!=ParmsNum) return 0;
+	int max = (int)targetParms.size();
+	if(max!=ParmsNum){
+		return false;
+	}
 
 	Type argType;
 	for(int i=0;i<max;i++){
-		Parameter &param = *params[i];
+		Parameter &param = *targetParms[i];
 
 		if(Parms[i]){
@@ -115,22 +105,24 @@
 
 			NumOpe_GetType(Parms[i],
-				(overload_level==OVERLOAD_LEVEL0)? nullParam : param,
+				(level==OVERLOAD_LEVEL0)? nullParam : param,
 				argType);
 		}
 		else{
-			argType.SetType( types[i].type, types[i].u.lpIndex );
+			argType = types[i];
 		}
 
 		if(argType.GetBasicType()!=param.GetBasicType()){
-			if(overload_level==OVERLOAD_LEVEL1 || overload_level == OVERLOAD_LEVEL0){
-				return 0;
-			}
-			else if(overload_level==OVERLOAD_LEVEL2){
+			if(level==OVERLOAD_LEVEL1 || level == OVERLOAD_LEVEL0){
+				return false;
+			}
+			else if(level==OVERLOAD_LEVEL2){
 				if(!(
 					IsWholeNumberType(argType.GetBasicType())&&IsWholeNumberType(param.GetBasicType())||
 					IsRealNumberType(argType.GetBasicType())&&IsRealNumberType(param.GetBasicType())
-					)) return 0;
-			}
-			else if(overload_level==OVERLOAD_LEVEL3){
+					)){
+						return false;
+				}
+			}
+			else if(level==OVERLOAD_LEVEL3){
 				if(argType.GetBasicType()==DEF_OBJECT||param.GetBasicType()==DEF_OBJECT) return 0;
 			}
@@ -138,37 +130,30 @@
 		else{
 			if(NATURAL_TYPE(argType.GetBasicType())==DEF_OBJECT || NATURAL_TYPE(argType.GetBasicType())==DEF_STRUCT){
-				if(argType.GetIndex()!=param.GetIndex()) return 0;
-			}
-		}
-	}
-
-	if(pReturnTypeInfo){
+				if(argType.GetIndex()!=param.GetIndex()){
+					return false;
+				}
+			}
+		}
+	}
+
+	if( !targetResultType.IsNull() ){
 		//戻り値も比較対象にする
-		if(ReturnTypeInfo.type==pReturnTypeInfo->type){
-			if(NATURAL_TYPE(ReturnTypeInfo.type)==DEF_OBJECT
-				|| NATURAL_TYPE(ReturnTypeInfo.type)==DEF_STRUCT ){
-					if(ReturnTypeInfo.u.lpIndex != pReturnTypeInfo->u.lpIndex) return 0;
-			}
-		}
-		else return 0;
-	}
-
-	return 1;
-}
-
-SubInfo *ParamImpl::OverloadSolutionWithReturnType( const char *name, std::vector<SubInfo *> &subs ){
+		if( !returnType.Equals( targetResultType ) ){
+			return false;
+		}
+	}
+
+	return true;
+}
+
+UserProc *ParamImpl::OverloadSolutionWithReturnType( const char *name, std::vector<UserProc *> &subs ){
 	int sw=0;
-	SubInfo *psi;
-	psi=0;
+	UserProc *pUserProc = NULL;
 
 	for( int level=OVERLOAD_MIN_LEVEL; level<=OVERLOAD_MAX_LEVEL; level++ ){
-		foreach( SubInfo *temp_psi, subs ){
-
-			TYPEINFO ReturnTypeInfo;
-			ReturnTypeInfo.type=temp_psi->ReturnType;
-			ReturnTypeInfo.u.lpIndex=temp_psi->u.ReturnIndex;
+		foreach( UserProc *pTempUserProc, subs ){
 
 			//エラーチェック
-			if(_overload_check(temp_psi->params,&ReturnTypeInfo,level)){
+			if(_overload_check( level, pTempUserProc->Params(), pTempUserProc->ReturnType() )){
 				if(sw){
 					SetError(52,name,cp);
@@ -177,5 +162,5 @@
 				sw=1;
 
-				psi = temp_psi;
+				pUserProc = pTempUserProc;
 				break;
 			}
@@ -190,17 +175,17 @@
 	}
 
-	return psi;
-}
-SubInfo *ParamImpl::OverloadSolution( const char *name, std::vector<SubInfo *> &subs ){
+	return pUserProc;
+}
+UserProc *ParamImpl::OverloadSolution( const char *name, std::vector<UserProc *> &subs ){
 	int sw=0;
-	SubInfo *psi;
-	psi=0;
+	UserProc *pUserProc;
+	pUserProc=0;
 
 	for( int level=OVERLOAD_MIN_LEVEL; level<=OVERLOAD_MAX_LEVEL; level++ ){
 
-		foreach( SubInfo *temp_psi, subs ){
+		foreach( UserProc *pTempUserProc, subs ){
 
 			//エラーチェック
-			if(_overload_check(temp_psi->params,NULL,level)){
+			if(_overload_check( level, pTempUserProc->Params(), Type() )){
 				if(sw){
 					return OverloadSolutionWithReturnType(name,subs);
@@ -208,5 +193,5 @@
 				sw=1;
 
-				psi = temp_psi;
+				pUserProc = pTempUserProc;
 			}
 		}
@@ -216,9 +201,8 @@
 
 	if(!sw){
-		SubInfo *temp_psi;
-		foreach( temp_psi, subs ){
+		foreach( UserProc *pTempUserProc, subs ){
 
 			//エラーチェック
-			if(temp_psi->params.size()==this->ParmsNum){
+			if(pTempUserProc->Params().size()==this->ParmsNum){
 				if(sw){
 					sw=0;
@@ -227,5 +211,5 @@
 				sw=1;
 
-				psi=temp_psi;
+				pUserProc=pTempUserProc;
 			}
 		}
@@ -237,40 +221,10 @@
 	}
 
-	return psi;
-}
-
-BOOL ParamImpl::ErrorCheck(const char *FuncName,PARAMETER_INFO *ppi,int pi_num,int SecondParmNum){
-	if(ParmsNum>pi_num){
-		if(ppi[pi_num-1].type!=DEF_ELLIPSE){
-			//パラメータが多すぎるとき
-			SetError(10,FuncName,cp);
-			return 0;
-		}
-	}
-	else if(ParmsNum<pi_num){
-		if(ParmsNum<SecondParmNum){
-			if(ppi[ParmsNum].type==DEF_ELLIPSE){
-				return 1;
-			}
-
-			//パラメータが少なすぎるとき
-			SetError(10,FuncName,cp);
-			return 0;
-		}
-
-		//省略パラメータに "0" を指定する
-		for(;ParmsNum < pi_num;ParmsNum++){
-			extern HANDLE hHeap;
-			char temporary[64];
-			if(ppi[ParmsNum].bByVal) lstrcpy(temporary,"0");
-			else sprintf(temporary,"%c%c0",1,ESC_BYVAL);
-			Parms[ParmsNum]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
-			lstrcpy(Parms[ParmsNum],temporary);
-		}
-	}
-
-	return 1;
-}
-bool ParamImpl::ErrorCheck( const char *procName, const Parameters &params, int SecondParmNum ){
+	return pUserProc;
+}
+
+bool ParamImpl::ErrorCheck( const string &procName, const Parameters &params, int SecondParmNum ){
+	if( SecondParmNum == -1 ) SecondParmNum = (int)params.size();
+
 	if(ParmsNum>(int)params.size()){
 		if(params[params.size()-1]->GetBasicType()!=DEF_ELLIPSE){
@@ -305,17 +259,4 @@
 }
 
-void ParamImpl::MacroParameterSupport(PARAMETER_INFO *ppi){
-	for(int i=0;i<ParmsNum;i++){
-		if(Parms[i][0]=='\0'){
-			extern HANDLE hHeap;
-			char temporary[64];
-			if(ppi[i].bByVal) lstrcpy(temporary,"0");
-			else sprintf(temporary,"%c%c0",1,ESC_BYVAL);
-			HeapDefaultFree(Parms[i]);
-			Parms[i]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
-			lstrcpy(Parms[i],temporary);
-		}
-	}
-}
 void ParamImpl::MacroParameterSupport( const Parameters &params ){
 	for(int i=0;i<ParmsNum;i++){
