Index: BasicCompiler_Common/ParamImpl.cpp
===================================================================
--- BasicCompiler_Common/ParamImpl.cpp	(revision 71)
+++ BasicCompiler_Common/ParamImpl.cpp	(revision 73)
@@ -73,4 +73,16 @@
 	ReturnTypeInfo.u.lpIndex=-1;
 }
+ParamImpl::ParamImpl(const Parameters &params){
+	int count = 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;
+}
 ParamImpl::~ParamImpl(){
 	int i2;
@@ -88,25 +100,27 @@
 }
 
-BOOL ParamImpl::_overload_check(PARAMETER_INFO *ppi,int pi_num,TYPEINFO *pReturnTypeInfo,int overload_level){
+BOOL ParamImpl::_overload_check( Parameters &params,TYPEINFO *pReturnTypeInfo,int overload_level){
 	//パラメータを識別してオーバーロードを解決
 
 	//パラメータの個数が不一致の場合
-	if(pi_num!=ParmsNum) return 0;
-
-	int i,type;
-	LONG_PTR lpIndex;
-	for(i=0;i<pi_num;i++){
+	int max = (int)params.size();
+	if(max!=ParmsNum) return 0;
+
+	Type argType;
+	for(int i=0;i<max;i++){
+		Parameter &param = *params[i];
+
 		if(Parms[i]){
-			TYPEINFO BaseType={ppi[i].type,ppi[i].u.index};
-			type=NumOpe_GetType(Parms[i],
-				(overload_level==OVERLOAD_LEVEL0) ? NULL : &BaseType,
-				&lpIndex);
+			Type nullParam( DEF_NON );
+
+			NumOpe_GetType(Parms[i],
+				(overload_level==OVERLOAD_LEVEL0)? nullParam : param,
+				argType);
 		}
 		else{
-			type=types[i].type;
-			lpIndex=types[i].u.lpIndex;
-		}
-
-		if(type!=ppi[i].type){
+			argType.SetType( types[i].type, types[i].u.lpIndex );
+		}
+
+		if(argType.GetBasicType()!=param.GetBasicType()){
 			if(overload_level==OVERLOAD_LEVEL1 || overload_level == OVERLOAD_LEVEL0){
 				return 0;
@@ -114,15 +128,15 @@
 			else if(overload_level==OVERLOAD_LEVEL2){
 				if(!(
-					IsWholeNumberType(type)&&IsWholeNumberType(ppi[i].type)||
-					IsRealNumberType(type)&&IsRealNumberType(ppi[i].type)
+					IsWholeNumberType(argType.GetBasicType())&&IsWholeNumberType(param.GetBasicType())||
+					IsRealNumberType(argType.GetBasicType())&&IsRealNumberType(param.GetBasicType())
 					)) return 0;
 			}
 			else if(overload_level==OVERLOAD_LEVEL3){
-				if(type==DEF_OBJECT||ppi[i].type==DEF_OBJECT) return 0;
+				if(argType.GetBasicType()==DEF_OBJECT||param.GetBasicType()==DEF_OBJECT) return 0;
 			}
 		}
 		else{
-			if(NATURAL_TYPE(type)==DEF_OBJECT || NATURAL_TYPE(type)==DEF_STRUCT){
-				if(lpIndex!=ppi[i].u.index) return 0;
+			if(NATURAL_TYPE(argType.GetBasicType())==DEF_OBJECT || NATURAL_TYPE(argType.GetBasicType())==DEF_STRUCT){
+				if(argType.GetIndex()!=param.GetIndex()) return 0;
 			}
 		}
@@ -143,11 +157,11 @@
 }
 
-SUBINFO *ParamImpl::OverloadSolutionWithReturnType( const char *name, std::vector<SUBINFO *> &subs ){
+SubInfo *ParamImpl::OverloadSolutionWithReturnType( const char *name, std::vector<SubInfo *> &subs ){
 	int sw=0;
-	SUBINFO *psi;
+	SubInfo *psi;
 	psi=0;
 
 	for( int level=OVERLOAD_MIN_LEVEL; level<=OVERLOAD_MAX_LEVEL; level++ ){
-		foreach( SUBINFO *temp_psi, subs ){
+		foreach( SubInfo *temp_psi, subs ){
 
 			TYPEINFO ReturnTypeInfo;
@@ -156,5 +170,5 @@
 
 			//エラーチェック
-			if(_overload_check(temp_psi->pParmInfo,temp_psi->ParmNum,&ReturnTypeInfo,level)){
+			if(_overload_check(temp_psi->params,&ReturnTypeInfo,level)){
 				if(sw){
 					SetError(52,name,cp);
@@ -178,15 +192,15 @@
 	return psi;
 }
-SUBINFO *ParamImpl::OverloadSolution( const char *name, std::vector<SUBINFO *> &subs ){
+SubInfo *ParamImpl::OverloadSolution( const char *name, std::vector<SubInfo *> &subs ){
 	int sw=0;
-	SUBINFO *psi;
+	SubInfo *psi;
 	psi=0;
 
 	for( int level=OVERLOAD_MIN_LEVEL; level<=OVERLOAD_MAX_LEVEL; level++ ){
 
-		foreach( SUBINFO *temp_psi, subs ){
+		foreach( SubInfo *temp_psi, subs ){
 
 			//エラーチェック
-			if(_overload_check(temp_psi->pParmInfo,temp_psi->ParmNum,NULL,level)){
+			if(_overload_check(temp_psi->params,NULL,level)){
 				if(sw){
 					return OverloadSolutionWithReturnType(name,subs);
@@ -202,9 +216,9 @@
 
 	if(!sw){
-		SUBINFO *temp_psi;
+		SubInfo *temp_psi;
 		foreach( temp_psi, subs ){
 
 			//エラーチェック
-			if(temp_psi->ParmNum==this->ParmsNum){
+			if(temp_psi->params.size()==this->ParmsNum){
 				if(sw){
 					sw=0;
@@ -258,8 +272,39 @@
 	return 1;
 }
+bool ParamImpl::ErrorCheck( const char *procName, const Parameters &params, int SecondParmNum ){
+	if(ParmsNum>(int)params.size()){
+		if(params[params.size()-1]->GetBasicType()!=DEF_ELLIPSE){
+			//パラメータが多すぎるとき
+			SetError(10,procName,cp);
+			return false;
+		}
+	}
+	else if(ParmsNum<(int)params.size()){
+		if(ParmsNum<SecondParmNum){
+			if(params[ParmsNum]->GetBasicType()==DEF_ELLIPSE){
+				return true;
+			}
+
+			//パラメータが少なすぎるとき
+			SetError(10,procName,cp);
+			return false;
+		}
+
+		//省略パラメータに "0" を指定する
+		for(;ParmsNum < (int)params.size();ParmsNum++){
+			extern HANDLE hHeap;
+			char temporary[64];
+			if(params[ParmsNum]->IsRef() == false) 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 true;
+}
 
 void ParamImpl::MacroParameterSupport(PARAMETER_INFO *ppi){
-	int i;
-	for(i=0;i<ParmsNum;i++){
+	for(int i=0;i<ParmsNum;i++){
 		if(Parms[i][0]=='\0'){
 			extern HANDLE hHeap;
@@ -273,2 +318,15 @@
 	}
 }
+void ParamImpl::MacroParameterSupport( const Parameters &params ){
+	for(int i=0;i<ParmsNum;i++){
+		if(Parms[i][0]=='\0'){
+			extern HANDLE hHeap;
+			char temporary[64];
+			if( params[i]->IsRef() == false ) 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);
+		}
+	}
+}
