Index: BasicCompiler_Common/Subroutine.cpp
===================================================================
--- BasicCompiler_Common/Subroutine.cpp	(revision 69)
+++ BasicCompiler_Common/Subroutine.cpp	(revision 73)
@@ -8,5 +8,5 @@
 
 //コンパイル中の関数情報
-SUBINFO *pCompilingSubInfo;
+SubInfo *pCompilingSubInfo;
 
 int GetCallProcName(char *buffer,char *name){
@@ -114,9 +114,9 @@
 		/////////////////////
 
-		SUBINFO *psi;
-		psi=(SUBINFO *)pInfo;
+		SubInfo *pSub;
+		pSub=(SubInfo *)pInfo;
 
 		//GetSubHash内でエラー提示が行われた場合
-		if(psi==(SUBINFO *)-1) return -1;
+		if(pSub==(SubInfo *)-1) return -1;
 
 
@@ -131,19 +131,19 @@
 		////////////////////////
 
-		std::vector<SUBINFO *> subs;
+		std::vector<SubInfo *> subs;
 		GetOverloadSubHash(name,subs);
 		if(subs.size()){
 			//オーバーロードを解決
-			psi=OverloadSolutionWithStrParam(name,subs,Parameter,ObjectName,NULL);
-
-			if(!psi) return 0;
-		}
-
-
-		Opcode_CallProc(Parameter,psi,0,ObjectName,RefType);
+			pSub=OverloadSolutionWithStrParam(name,subs,Parameter,ObjectName,NULL);
+
+			if(!pSub) return 0;
+		}
+
+
+		Opcode_CallProc(Parameter,pSub,0,ObjectName,RefType);
 		if( plpRetIndex ){
-			*plpRetIndex = psi->u.ReturnIndex;
-		}
-		return psi->ReturnType;
+			*plpRetIndex = pSub->u.ReturnIndex;
+		}
+		return pSub->ReturnType;
 	}
 	else if(idProc==PROC_DLL){
@@ -197,5 +197,5 @@
 
 	//オーバーロード用の関数リストを作成
-	std::vector<SUBINFO *> subs;
+	std::vector<SubInfo *> subs;
 	GetOverloadSubHash(VarName,subs);
 	if(subs.size()==0){
@@ -213,14 +213,14 @@
 
 	//オーバーロードを解決
-	SUBINFO *psi;
-	psi=OverloadSolutionWithStrParam(VarName,subs,Parameter,ObjectName,NULL);
-
-	if(psi){
+	SubInfo *pSub;
+	pSub=OverloadSolutionWithStrParam(VarName,subs,Parameter,ObjectName,NULL);
+
+	if(pSub){
 		//呼び出し
-		Opcode_CallProc(Parameter,psi,0,ObjectName,RefType);
+		Opcode_CallProc(Parameter,pSub,0,ObjectName,RefType);
 
 		if( pRetTypeInfo ){
-			pRetTypeInfo->type = psi->ReturnType;
-			pRetTypeInfo->u.lpIndex = psi->u.ReturnIndex;
+			pRetTypeInfo->type = pSub->ReturnType;
+			pRetTypeInfo->u.lpIndex = pSub->u.ReturnIndex;
 		}
 	}
@@ -240,9 +240,9 @@
 		/////////////////////
 
-		SUBINFO *psi;
-		psi=(SUBINFO *)pInfo;
+		SubInfo *pSub;
+		pSub=(SubInfo *)pInfo;
 
 		//GetSubHash内でエラー提示が行われた場合
-		if(psi==(SUBINFO *)-1) return -1;
+		if(pSub==(SubInfo *)-1) return -1;
 
 
@@ -257,16 +257,16 @@
 		////////////////////////
 
-		std::vector<SUBINFO *> subs;
+		std::vector<SubInfo *> subs;
 		GetOverloadSubHash(name,subs);
 		if( subs.size() > 0 ){
 			//オーバーロードを解決
-			psi=OverloadSolutionWithStrParam(name,subs,Parameter,ObjectName,NULL);
-
-			if(!psi) return 0;
-		}
-
-
-		ret_type=psi->ReturnType;
-		*plpRetIndex=psi->u.ReturnIndex;
+			pSub=OverloadSolutionWithStrParam(name,subs,Parameter,ObjectName,NULL);
+
+			if(!pSub) return 0;
+		}
+
+
+		ret_type=pSub->ReturnType;
+		*plpRetIndex=pSub->u.ReturnIndex;
 	}
 	else if(idProc==PROC_DLL){
@@ -318,5 +318,5 @@
 
 	//オーバーロード用の関数リストを作成
-	std::vector<SUBINFO *> subs;
+	std::vector<SubInfo *> subs;
 	GetOverloadSubHash(VarName,subs);
 	if(subs.size()==0){
@@ -334,11 +334,11 @@
 
 	//オーバーロードを解決
-	SUBINFO *psi;
-	psi=OverloadSolutionWithStrParam(VarName,subs,Parameter,ObjectName,NULL);
-
-	if(psi){
+	SubInfo *pSub;
+	pSub=OverloadSolutionWithStrParam(VarName,subs,Parameter,ObjectName,NULL);
+
+	if(pSub){
 		if(pRetTypeInfo){
-			pRetTypeInfo->type=psi->ReturnType;
-			pRetTypeInfo->u.lpIndex=psi->u.ReturnIndex;
+			pRetTypeInfo->type=pSub->ReturnType;
+			pRetTypeInfo->u.lpIndex=pSub->u.ReturnIndex;
 		}
 	}
@@ -349,5 +349,5 @@
 //インデクサ（getter）の戻り値を取得
 bool GetReturnTypeOfIndexerGetterProc(CClass *pobj_Class,TYPEINFO &RetTypeInfo){
-	std::vector<SUBINFO *> subs;
+	std::vector<SubInfo *> subs;
 	pobj_Class->EnumMethod( CALC_ARRAY_GET, subs );
 	if( subs.size() == 0 ){
@@ -644,5 +644,5 @@
 	return 0;
 }
-SUBINFO *AddSubData(char *buffer,int NowLine,BOOL bVirtual,CClass *pobj_c,BOOL bStatic){
+SubInfo *AddSubData(char *buffer,int NowLine,BOOL bVirtual,CClass *pobj_c,BOOL bStatic){
 	int i,i2,i3,sw;
 	DWORD dwType;
@@ -761,42 +761,41 @@
 	SubNum++;
 
-	SUBINFO *psi;
-	psi=(SUBINFO *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,sizeof(SUBINFO));
+	SubInfo *pSub = new SubInfo();
 
 	//クラス名
-	psi->pobj_ParentClass=pobj_c;
+	pSub->pobj_ParentClass=pobj_c;
 
 	//ID
 	static int id_base=0;
-	psi->id=(id_base++);
+	pSub->id=(id_base++);
 
 	//関数名
-	psi->name=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
-	lstrcpy(psi->name,temporary);
+	pSub->name=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
+	lstrcpy(pSub->name,temporary);
 
 	//ソースコードの位置
-	psi->address=NowLine;
-
-	psi->bExport=bExport;
-	psi->bCdecl=bCdecl;
-	psi->bVirtual=bVirtual;
-	if(bExport) psi->bUse=1;
-	else psi->bUse=0;
-	psi->bCompile=0;
-	psi->bSystem=0;
-
-	psi->dwType=dwType;
-
-
-	if(psi->dwType==SUBTYPE_FUNCTION){
+	pSub->address=NowLine;
+
+	pSub->bExport=bExport;
+	pSub->bCdecl=bCdecl;
+	pSub->bVirtual=bVirtual;
+	if(bExport) pSub->bUse=1;
+	else pSub->bUse=0;
+	pSub->bCompile=0;
+	pSub->bSystem=0;
+
+	pSub->dwType=dwType;
+
+
+	if(pSub->dwType==SUBTYPE_FUNCTION){
 		///////////////////
 		// 戻り値を取得
 		///////////////////
 
-		psi->isReturnRef = false;
+		pSub->isReturnRef = false;
 
 		if(pobj_c){
-			if(lstrcmp(psi->name,pobj_c->name)==0||
-				psi->name[0]=='~'){
+			if(lstrcmp(pSub->name,pobj_c->name)==0||
+				pSub->name[0]=='~'){
 				//クラスのコンストラクタ、デストラクタがFunction定義の場合はエラーをだす
 				SetError(115,NULL,NowLine);
@@ -814,5 +813,5 @@
 				if( buffer[i2-2] == 1 && buffer[i2-1] == ESC_BYREF ){
 					//参照型
-					psi->isReturnRef = true;
+					pSub->isReturnRef = true;
 				}
 
@@ -827,6 +826,6 @@
 					temporary[i3]=buffer[i2];
 				}
-				psi->ReturnType=GetTypeFixed(temporary,&psi->u.ReturnIndex);
-				if(psi->ReturnType==DEF_NON) SetError(3,temporary,NowLine);
+				pSub->ReturnType=GetTypeFixed(temporary,&pSub->u.ReturnIndex);
+				if(pSub->ReturnType==DEF_NON) SetError(3,temporary,NowLine);
 
 				sw_as=1;
@@ -836,19 +835,14 @@
 
 		if(!sw_as){
-			SetError(-104,psi->name,NowLine);
-
-			psi->ReturnType=DEF_DOUBLE;
+			SetError(-104,pSub->name,NowLine);
+
+			pSub->ReturnType=DEF_DOUBLE;
 		}
 	}
 	else{
 		//戻り値なしのSub定義
-		psi->ReturnType=DEF_NON;
-		psi->u.ReturnIndex=-1;
-	}
-
-
-
-	psi->pParmInfo=(PARAMETER_INFO *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,sizeof(PARAMETER_INFO)*2);
-	psi->ParmNum=0;
+		pSub->ReturnType=DEF_NON;
+		pSub->u.ReturnIndex=-1;
+	}
 
 	//パラメータ
@@ -860,5 +854,5 @@
 	if(buffer[i]!=')'&&pobj_c){
 		//クラスのメンバ関数の場合のみ、デストラクタにパラメータがある場合にエラーをだす
-		if(psi->name[0]=='~'){
+		if(pSub->name[0]=='~'){
 			SetError(114,NULL,NowLine);
 			i=JumpStringInPare(buffer,i);
@@ -868,18 +862,20 @@
 		if(buffer[i]==')') break;
 
-		psi->pParmInfo=(PARAMETER_INFO *)HeapReAlloc(hHeap,0,psi->pParmInfo,(psi->ParmNum+1)*sizeof(PARAMETER_INFO));
-
-		//ByVal
+		//ByRef
+		bool isRef;
 		if(buffer[i]==1&&buffer[i+1]==ESC_BYVAL){
-			psi->pParmInfo[psi->ParmNum].bByVal=1;
+			isRef = false;
 			i+=2;
 		}
 		else if(buffer[i]==1&&buffer[i+1]==ESC_BYREF){
-			psi->pParmInfo[psi->ParmNum].bByVal=0;
+			isRef = true;
 			i+=2;
 		}
-		else psi->pParmInfo[psi->ParmNum].bByVal=1;
+		else isRef = false;
 
 		//パラメータ名
+		bool isArray = false;
+		int subScripts[MAX_ARRAYDIM];
+		char name[VN_SIZE];
 		sw=0;
 		for(i2=0;;i++,i2++){
@@ -887,5 +883,5 @@
 				if(!sw) sw=1;
 
-				i3=GetStringInPare(temporary+i2,buffer+i);
+				i3=GetStringInPare(name+i2,buffer+i);
 				i2+=i3-1;
 				i+=i3-1;
@@ -895,5 +891,5 @@
 				if(!sw) sw=1;
 
-				i3=GetStringInBracket(temporary+i2,buffer+i);
+				i3=GetStringInBracket(name+i2,buffer+i);
 				i2+=i3-1;
 				i+=i3-1;
@@ -901,36 +897,31 @@
 			}
 			if(!IsVariableChar(buffer[i])){
-				temporary[i2]=0;
+				name[i2]=0;
 				break;
 			}
-			temporary[i2]=buffer[i];
+			name[i2]=buffer[i];
 		}
 		if(sw){
 			//配列パラメータ
-			if(psi->pParmInfo[psi->ParmNum].bByVal) SetError(29,NULL,NowLine);
-			psi->pParmInfo[psi->ParmNum].bArray=1;
-
-			if((temporary[i2-2]=='('&&temporary[i2-1]==')')||
-				(temporary[i2-2]=='['&&temporary[i2-1]==']')){
-				psi->pParmInfo[psi->ParmNum].SubScripts[0]=LONG_MAX;
-				psi->pParmInfo[psi->ParmNum].SubScripts[1]=-1;
-
-				temporary[i2-2]=0;
+			if( isRef == false ) SetError(29,NULL,NowLine);
+			isArray = true;
+
+			if((name[i2-2]=='('&&name[i2-1]==')')||
+				(name[i2-2]=='['&&name[i2-1]==']')){
+				subScripts[0]=LONG_MAX;
+				subScripts[1]=-1;
+
+				name[i2-2]=0;
 			}
 			else{
-				GetArrange(temporary,temp2,psi->pParmInfo[psi->ParmNum].SubScripts);
-				lstrcpy(temporary,temp2);
-			}
-
-			i2=lstrlen(temporary);
-		}
-		else{
-			psi->pParmInfo[psi->ParmNum].bArray=0;
-			psi->pParmInfo[psi->ParmNum].SubScripts[0]=-1;
-		}
-		psi->pParmInfo[psi->ParmNum].name=(char *)HeapAlloc(hHeap,0,i2+1);
-		lstrcpy(psi->pParmInfo[psi->ParmNum].name,temporary);
+				GetArrange(name,temp2,subScripts);
+				lstrcpy(name,temp2);
+			}
+
+			i2=lstrlen(name);
+		}
 
 		//型
+		Type type( DEF_NON );
 		if(buffer[i]==1&&buffer[i+1]==ESC_AS){
 			i+=2;
@@ -955,6 +946,5 @@
 			}
 
-			psi->pParmInfo[psi->ParmNum].type=
-				GetTypeFixed(temporary,&psi->pParmInfo[psi->ParmNum].u.index);
+			Type::StringToType( temporary, type );
 
 			if(temporary[0]=='*'&&
@@ -963,5 +953,5 @@
 				if(buffer[i]!='('){
 					SetError(10,temporary,NowLine);
-					return 0;
+					break;
 				}
 				i3=GetStringInPare(temporary+i2,buffer+i);
@@ -986,26 +976,26 @@
 			}
 
-			if(psi->pParmInfo[psi->ParmNum].type==-1){
+			if( type.IsNull() ){
 				SetError(3,temporary,NowLine);
-				psi->pParmInfo[psi->ParmNum].type=DEF_PTR_VOID;
-			}
-
-			/*未完成（構造体パラメータを値参照として渡してよいものか！？）
-			if(psi->pParmInfo[psi->ParmNum].type==DEF_OBJECT){
-				if(psi->pParmInfo[psi->ParmNum].bByVal) SetError(28,temporary,NowLine);
-			}*/
+				type.SetBasicType( DEF_PTR_VOID );
+			}
 		}
 		else{
-			psi->pParmInfo[psi->ParmNum].type=GetTypeFromSimpleName(temporary);
+			type.SetBasicType( GetTypeFromSimpleName(temporary) );
 			SetError(-103,temporary,NowLine);
 		}
 
-		if(psi->pParmInfo[psi->ParmNum].type==DEF_PTR_PROC){
+		if( type.IsProcPtr() ){
 			//関数ポインタの場合
-			psi->pParmInfo[psi->ParmNum].u.index=AddProcPtrInfo(temporary+3,temporary[2]);
-		}
-
-		//パラメータの数を更新
-		psi->ParmNum++;
+			type.SetIndex( AddProcPtrInfo(temporary+3,temporary[2]) );
+		}
+
+		Parameter *pParam = new Parameter( name, type, isRef );
+		if( isArray ){
+			pParam->SetArray( subScripts );
+		}
+
+		//パラメータを追加
+		pSub->params.push_back( pParam );
 
 		if(buffer[i]==','){
@@ -1016,8 +1006,8 @@
 		else{
 			SetError(1,NULL,NowLine);
-			return 0;
-		}
-	}
-	psi->SecondParmNum=psi->ParmNum;
+			break;
+		}
+	}
+	pSub->SecondParmNum = (int)pSub->params.size();
 	i++;
 	if(buffer[i]=='('){
@@ -1026,18 +1016,20 @@
 			if(buffer[i]==')') break;
 
-			psi->pParmInfo=(PARAMETER_INFO *)HeapReAlloc(hHeap,0,psi->pParmInfo,(psi->ParmNum+1)*sizeof(PARAMETER_INFO));
-
-			//ByVal
+			//ByRef
+			bool isRef;
 			if(buffer[i]==1&&buffer[i+1]==ESC_BYVAL){
-				psi->pParmInfo[psi->ParmNum].bByVal=1;
+				isRef = false;
 				i+=2;
 			}
 			else if(buffer[i]==1&&buffer[i+1]==ESC_BYREF){
-				psi->pParmInfo[psi->ParmNum].bByVal=0;
+				isRef = true;
 				i+=2;
 			}
-			else psi->pParmInfo[psi->ParmNum].bByVal=1;
+			else isRef = false;
 
 			//パラメータ名
+			bool isArray = false;
+			int subScripts[MAX_ARRAYDIM];
+			char name[VN_SIZE];
 			sw=0;
 			for(i2=0;;i++,i2++){
@@ -1045,5 +1037,5 @@
 					if(!sw) sw=1;
 
-					i3=GetStringInPare(temporary+i2,buffer+i);
+					i3=GetStringInPare(name+i2,buffer+i);
 					i2+=i3-1;
 					i+=i3-1;
@@ -1053,5 +1045,5 @@
 					if(!sw) sw=1;
 
-					i3=GetStringInBracket(temporary+i2,buffer+i);
+					i3=GetStringInBracket(name+i2,buffer+i);
 					i2+=i3-1;
 					i+=i3-1;
@@ -1059,38 +1051,34 @@
 				}
 				if(!IsVariableChar(buffer[i])){
-					temporary[i2]=0;
+					name[i2]=0;
 					break;
 				}
-				temporary[i2]=buffer[i];
+				name[i2]=buffer[i];
 			}
 			if(sw){
 				//配列パラメータ
-				if(psi->pParmInfo[psi->ParmNum].bByVal) SetError(29,NULL,NowLine);
-				psi->pParmInfo[psi->ParmNum].bArray=1;
-
-				if((temporary[i2-2]=='('&&temporary[i2-1]==')')||
-					(temporary[i2-2]=='['&&temporary[i2-1]==']')){
-					psi->pParmInfo[psi->ParmNum].SubScripts[0]=LONG_MAX;
-					psi->pParmInfo[psi->ParmNum].SubScripts[1]=-1;
-
-					temporary[i2-2]=0;
+				if( isRef == false ) SetError(29,NULL,NowLine);
+				isArray = true;
+
+				if((name[i2-2]=='('&&name[i2-1]==')')||
+					(name[i2-2]=='['&&name[i2-1]==']')){
+					subScripts[0]=LONG_MAX;
+					subScripts[1]=-1;
+
+					name[i2-2]=0;
 				}
 				else{
-					GetArrange(temporary,temp2,psi->pParmInfo[psi->ParmNum].SubScripts);
-					lstrcpy(temporary,temp2);
-				}
-
-				i2=lstrlen(temporary);
-			}
-			else{
-				psi->pParmInfo[psi->ParmNum].bArray=0;
-				psi->pParmInfo[psi->ParmNum].SubScripts[0]=-1;
-			}
-			psi->pParmInfo[psi->ParmNum].name=(char *)HeapAlloc(hHeap,0,i2+1);
-			lstrcpy(psi->pParmInfo[psi->ParmNum].name,temporary);
+					GetArrange(name,temp2,subScripts);
+					lstrcpy(name,temp2);
+				}
+
+				i2=lstrlen(name);
+			}
 
 			//型
+			Type type( DEF_NON );
 			if(buffer[i]==1&&buffer[i+1]==ESC_AS){
 				i+=2;
+
 				i2=0;
 				while(buffer[i]=='*'){
@@ -1101,4 +1089,9 @@
 				for(;;i++,i2++){
 					if(!IsVariableChar(buffer[i])){
+						if(buffer[i]==1&&(buffer[i+1]==ESC_FUNCTION||buffer[i+1]==ESC_SUB)){
+							temporary[i2++]=buffer[i++];
+							temporary[i2]=buffer[i];
+							continue;
+						}
 						temporary[i2]=0;
 						break;
@@ -1106,14 +1099,57 @@
 					temporary[i2]=buffer[i];
 				}
-				psi->pParmInfo[psi->ParmNum].type=
-					GetTypeFixed(temporary,&psi->pParmInfo[psi->ParmNum].u.index);
-				if(psi->pParmInfo[psi->ParmNum].type==-1) SetError(3,temporary,NowLine);
+
+				Type::StringToType( temporary, type );
+
+				if(temporary[0]=='*'&&
+					temporary[1]==1&&
+					(temporary[2]==ESC_FUNCTION||temporary[2]==ESC_SUB)){
+					if(buffer[i]!='('){
+						SetError(10,temporary,NowLine);
+						break;
+					}
+					i3=GetStringInPare(temporary+i2,buffer+i);
+					i+=i3;
+					i2+=i3;
+
+					if(temporary[2]==ESC_FUNCTION&&buffer[i]==1&&buffer[i+1]==ESC_AS){
+						temporary[i2++]=buffer[i++];
+						temporary[i2++]=buffer[i++];
+						for(;;i++,i2++){
+							if(!IsVariableChar(buffer[i])){
+								temporary[i2]=0;
+								break;
+							}
+							temporary[i2]=buffer[i];
+						}
+					}
+				}
+				else{
+					//TypeDefをする前のベース型を取得
+					GetOriginalTypeName(temporary);
+				}
+
+				if( type.IsNull() ){
+					SetError(3,temporary,NowLine);
+					type.SetBasicType( DEF_PTR_VOID );
+				}
 			}
 			else{
-				psi->pParmInfo[psi->ParmNum].type=GetTypeFromSimpleName(temporary);
+				type.SetBasicType( GetTypeFromSimpleName(temporary) );
 				SetError(-103,temporary,NowLine);
 			}
 
-			psi->ParmNum++;
+			if( type.IsProcPtr() ){
+				//関数ポインタの場合
+				type.SetIndex( AddProcPtrInfo(temporary+3,temporary[2]) );
+			}
+
+			Parameter *pParam = new Parameter( name, type, isRef );
+			if( isArray ){
+				pParam->SetArray( subScripts );
+			}
+
+			//パラメータを追加
+			pSub->params.push_back( pParam );
 
 			if(buffer[i]==','){
@@ -1124,5 +1160,5 @@
 			else{
 				SetError(1,NULL,NowLine);
-				return 0;
+				break;
 			}
 		}
@@ -1130,43 +1166,28 @@
 	}
 
-	//リアルパラメータ領域を取得（_System_LocalThisを考慮して2つだけ多く確保する）
-	psi->pRealParmInfo=(PARAMETER_INFO *)HeapAlloc(hHeap,0,(psi->ParmNum+2)*sizeof(PARAMETER_INFO));
-	psi->RealParmNum=0;
+	//リアルパラメータ領域を取得（_System_LocalThisを考慮して2つだけ多く確保する場合がある）
 
 	if(pobj_c&&bStatic==0){
-		i = psi->RealParmNum;
-
 		//オブジェクトメンバの場合は、第一パラメータを_System_LocalThis引き渡し用として利用
-		psi->pRealParmInfo[i].name = "_System_LocalThis";
-		psi->pRealParmInfo[i].type=DEF_PTR_VOID;
-		psi->pRealParmInfo[i].u.index=-1;
-		psi->pRealParmInfo[i].bByVal=1;
-		psi->pRealParmInfo[i].bArray=0;
-		psi->pRealParmInfo[i].SubScripts[0]=-1;
-
-		psi->RealParmNum++;
-	}
-
-	if(psi->ReturnType==DEF_STRUCT){
-		i = psi->RealParmNum;
-
+		string name = "_System_LocalThis";
+		Type type( DEF_PTR_VOID );
+		pSub->realParams.push_back( new Parameter( name, type ) );
+	}
+
+	if(pSub->ReturnType==DEF_STRUCT){
 		//構造体を戻り値として持つ場合
 		//※第一パラメータ（Thisポインタありの場合は第二パラメータ）を戻り値用の参照宣言にする
 
-		if(psi->name[0]==1&&psi->name[1]==ESC_OPERATOR)
-			psi->pRealParmInfo[i].name="_System_ReturnValue";
-		else psi->pRealParmInfo[i].name=psi->name;
-		psi->pRealParmInfo[i].type=DEF_STRUCT;
-		psi->pRealParmInfo[i].u.index=psi->u.ReturnIndex;
-		psi->pRealParmInfo[i].bByVal=0;
-		psi->pRealParmInfo[i].bArray=0;
-		psi->pRealParmInfo[i].SubScripts[0]=-1;
-		
-		psi->RealParmNum++;
+		string name = pSub->name;
+		if(pSub->name[0]==1&&pSub->name[1]==ESC_OPERATOR){
+			name="_System_ReturnValue";
+		}
+		Type type( DEF_STRUCT, pSub->u.ReturnIndex );
+		pSub->realParams.push_back( new Parameter( name, type, true ) );
 	}
 
 	//パラメータをコピー
-	for( i = 0; i < psi->ParmNum; i++, psi->RealParmNum++ ){
-		psi->pRealParmInfo[psi->RealParmNum]=psi->pParmInfo[i];
+	foreach( Parameter *pParam, pSub->params ){
+		pSub->realParams.push_back( new Parameter( *pParam ) );
 	}
 
@@ -1177,16 +1198,16 @@
 
 	int key;
-	key=hash_default(psi->name);
-
-	extern SUBINFO **ppSubHash;
+	key=hash_default(pSub->name);
+
+	extern SubInfo **ppSubHash;
 	if(ppSubHash[key]){
-		SUBINFO *psi2;
+		SubInfo *psi2;
 		psi2=ppSubHash[key];
 		while(1){
 			if(pobj_c==psi2->pobj_ParentClass){
 				//重複エラーチェックを行う
-				if(lstrcmp(psi2->name,psi->name)==0){
-					if(CompareParameter(psi2->pParmInfo,psi2->ParmNum,psi->pParmInfo,psi->ParmNum)==0){
-						SetError(15,psi->name,NowLine);
+				if(lstrcmp(psi2->name,pSub->name)==0){
+					if( Parameter::Equals( psi2->params, pSub->params ) ){
+						SetError(15,pSub->name,NowLine);
 						return 0;
 					}
@@ -1197,11 +1218,11 @@
 			psi2=psi2->pNextData;
 		}
-		psi2->pNextData=psi;
+		psi2->pNextData=pSub;
 	}
 	else{
-		ppSubHash[key]=psi;
-	}
-
-	return psi;
+		ppSubHash[key]=pSub;
+	}
+
+	return pSub;
 }
 
@@ -1217,7 +1238,7 @@
 
 	//サブルーチン（ユーザー定義）情報を初期化
-	extern SUBINFO **ppSubHash;
+	extern SubInfo **ppSubHash;
 	extern int SubNum;
-	ppSubHash=(SUBINFO **)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,MAX_HASH*sizeof(SUBINFO *));
+	ppSubHash=(SubInfo **)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,MAX_HASH*sizeof(SubInfo *));
 	SubNum=0;
 
@@ -1313,21 +1334,19 @@
 	AddSubData(temporary,0,0,0);
 }
-void Delete_si(SUBINFO *psi){
-	int i2;
-
-	for(i2=0;i2<psi->ParmNum;i2++){
-		HeapDefaultFree(psi->pParmInfo[i2].name);
-	}
-	HeapDefaultFree(psi->pRealParmInfo);
-	if(psi->pParmInfo) HeapDefaultFree(psi->pParmInfo);
-	psi->pRealParmInfo=0;
-	psi->pParmInfo=0;
-
-	if(psi->pNextData) Delete_si(psi->pNextData);
-
-	HeapDefaultFree(psi->name);
-	HeapDefaultFree(psi);
-}
-void DeleteSubInfo(SUBINFO **ppSubHash,char **ppMacroNames,int MacroNum){	//サブルーチン情報のメモリ解放
+void Delete_si(SubInfo *pSub){
+	foreach( Parameter *pParam, pSub->params ){
+		delete pParam;
+	}
+
+	foreach( Parameter *pParam, pSub->realParams ){
+		delete pParam;
+	}
+
+	if(pSub->pNextData) Delete_si(pSub->pNextData);
+
+	HeapDefaultFree(pSub->name);
+	delete pSub;
+}
+void DeleteSubInfo(SubInfo **ppSubHash,char **ppMacroNames,int MacroNum){	//サブルーチン情報のメモリ解放
 	int i;
 	for(i=0;i<MAX_HASH;i++){
