Index: BasicCompiler64/Compile_Statement.cpp
===================================================================
--- BasicCompiler64/Compile_Statement.cpp	(revision 73)
+++ BasicCompiler64/Compile_Statement.cpp	(revision 75)
@@ -5,5 +5,5 @@
 	int i,i2;
 	char buffer[8192];
-	SubInfo *psi;
+	UserProc *pUserProc;
 
 	for(i=0;;i++){
@@ -41,24 +41,24 @@
 		//////////////////////////////
 
-		psi=GetSubHash(Command);
+		pUserProc=GetSubHash(Command);
 
 		//GetSubHash内でエラー提示が行われた場合
-		if(psi==(SubInfo *)-1) return;
-
-		if(psi==0){
+		if(pUserProc==(UserProc *)-1) return;
+
+		if(pUserProc==0){
 			char temporary[VN_SIZE];
 			lstrcpy(temporary,Command);
 
 			CharUpper(temporary);
-			psi=GetSubHash(temporary);
+			pUserProc=GetSubHash(temporary);
 
 			//GetSubHash内でエラー提示が行われた場合
-			if(psi==(SubInfo *)-1) return;
-		}
-
-		if(psi){
-			if(psi->dwType!=SUBTYPE_MACRO) SetError(10,Command,cp);
-
-			Opcode_CallProc("",psi,0,"",0);
+			if(pUserProc==(UserProc *)-1) return;
+		}
+
+		if(pUserProc){
+			if( !pUserProc->IsMacro() ) SetError(10,Command,cp);
+
+			Opcode_CallProc("",pUserProc,0,"",0);
 
 			return;
@@ -72,6 +72,6 @@
 
 	int idProc;
-	void *pInfo;
-	idProc=GetProc(buffer,&pInfo);
+	void *pProc;
+	idProc=GetProc(buffer,(void **)&pProc);
 
 	int i4;
@@ -91,6 +91,6 @@
 		////////////////
 
-		LONG_PTR lp;
-		i2=CallProc(idProc,pInfo,buffer,temp2,&lp);
+		Type resultType;
+		CallProc(idProc,pProc,buffer,temp2,resultType);
 
 
@@ -99,9 +99,9 @@
 		/////////////////////
 
-		if(i2==DEF_STRUCT){
+		if( resultType.IsStruct() ){
 			//mov r14,rax
 			op_mov_RR(REG_R14,REG_RAX);
 
-			FreeTempObject(REG_R14,(CClass *)lp);
+			FreeTempObject(REG_R14,&resultType.GetClass());
 		}
 		return;
@@ -116,10 +116,13 @@
 
 void Judgment(char *buffer){
-	int reg=REG_RAX,type;
-	type=NumOpe(&reg,buffer,0,0,0);
+	int reg=REG_RAX;
+	Type resultType;
+	if( !NumOpe(&reg,buffer,Type(),resultType) ){
+		return;
+	}
 
 	int offset;
 
-	if(type==DEF_DOUBLE){
+	if(resultType.IsDouble()){
 		double dbl=0;
 		offset=dataTable.Add( dbl );
@@ -135,5 +138,5 @@
 		obp+=sizeof(long);
 	}
-	else if(type==DEF_SINGLE){
+	else if(resultType.IsSingle()){
 		float flt=0;
 		offset=dataTable.Add( flt );
@@ -152,5 +155,5 @@
 
 		//cmp rax,0
-		op_cmp_value(GetTypeSize(type,-1),REG_RAX,0);
+		op_cmp_value(resultType.GetSize(),REG_RAX,0);
 	}
 }
@@ -340,4 +343,5 @@
 void OpcodeFor(char *Parameter){
 	extern HANDLE hHeap;
+	Type resultType;
 	int i,i2,i3;
 	char temporary[VN_SIZE],variable[VN_SIZE],JudgeNum[VN_SIZE],StepNum[VN_SIZE];
@@ -400,10 +404,12 @@
 	sprintf(temporary,"(%s)>=0",StepNum);
 
-	int reg,type;
+	int reg;
 	reg=REG_RAX;
-	type=NumOpe(&reg,temporary,0,0,0);
+	if( !NumOpe(&reg,temporary,Type(),resultType) ){
+		return;
+	}
 
 	//cmp rax,0
-	op_cmp_value(GetTypeSize(type,-1),REG_RAX,0);
+	op_cmp_value(resultType.GetSize(),REG_RAX,0);
 
 	//je [カウンタ減少の場合の判定]
@@ -417,5 +423,5 @@
 
 	reg=REG_RAX;
-	type=NumOpe(&reg,temporary,0,0,0);
+	NumOpe(&reg,temporary,Type(),Type());
 
 	//jmp [カウンタ減少の場合の判定を飛び越す]
@@ -430,10 +436,10 @@
 
 	reg=REG_RAX;
-	type=NumOpe(&reg,temporary,0,0,0);
+	NumOpe(&reg,temporary,Type(),resultType);
 
 	*((long *)(OpBuffer+i3))=obp-(i3+sizeof(long)); //jmpジャンプ先のオフセット値
 
 	//cmp rax,0
-	op_cmp_value(GetTypeSize(type,-1),REG_RAX,0);
+	op_cmp_value(resultType.GetSize(),REG_RAX,0);
 
 ErrorStep:
@@ -583,6 +589,5 @@
 	extern HANDLE hHeap;
 
-	extern BOOL bCompilingGlobal;
-	if(bCompilingGlobal){
+	if( UserProc::IsGlobalAreaCompiling() ){
 		SetError(12,"Exit Sub/Function",cp);
 		return;
@@ -611,5 +616,5 @@
 	CaseScheduleNum++;
 }
-void OpcodeSelect(char *Parameter){
+void OpcodeSelect( const char *lpszParms ){
 	extern DWORD *pCaseSchedule;
 	extern int CaseScheduleNum;
@@ -631,18 +636,20 @@
 	NowCaseSchedule=0;
 
-	int reg1=REG_RAX,type1;
-	LONG_PTR lpIndex;
-	type1=NumOpe(&reg1,Parameter,0,0,&lpIndex);
-
-	if(type1==DEF_DOUBLE){
+	int reg1=REG_RAX;
+	Type type1;
+	if( !NumOpe(&reg1,lpszParms,Type(), type1 ) ){
+		return;
+	}
+
+	if(type1.IsDouble()){
 		//movsd qword ptr[rsp+offset],xmm_reg		※スタックフレームを利用
 		pobj_sf->push(reg1,sizeof(double));
 	}
-	else if(type1==DEF_SINGLE){
+	else if(type1.IsSingle()){
 		//movss dword ptr[rsp+offset],xmm_reg		※スタックフレームを利用
 		pobj_sf->push(reg1,sizeof(float));
 	}
 	else{
-		ExtendTypeTo64(type1,reg1);
+		ExtendTypeTo64(type1.GetBasicType(),reg1);
 
 		//mov qword ptr[rsp+offset],reg     ※スタックフレームを利用
@@ -712,36 +719,29 @@
 				cp=NowCaseCp;
 
-				int reg2=REG_RDX,type2;
-				LONG_PTR lpIndex2;
-				type2=NumOpe(&reg2,temporary,type1,lpIndex,&lpIndex2);
+				int reg2=REG_RDX;
+				Type type2;
+				if( !NumOpe(&reg2,temporary,type1,type2) ){
+					return;
+				}
 
 				cp=i2;
 
-				if(type1==DEF_OBJECT){
-					CClass *pobj_c;
-					pobj_c=(CClass *)lpIndex;
-
-					std::vector<SubInfo *> subs;
-					pobj_c->EnumMethod( CALC_EQUAL, subs );
+				if(type1.IsObject()){
+					std::vector<UserProc *> subs;
+					type1.GetClass().EnumMethod( CALC_EQUAL, subs );
 					if( subs.size() == 0 ){
 						return;
 					}
 
-					PARAMETER_INFO *ppi = (PARAMETER_INFO *)HeapAlloc(hHeap,0,sizeof(PARAMETER_INFO)*3);
-					int iParmNum=0;
-					ppi[iParmNum].bArray=0;
-					ppi[iParmNum].bByVal=0;
-					ppi[iParmNum].name=0;
-					ppi[iParmNum].type=type2;
-					ppi[iParmNum].u.index=lpIndex2;
-					ppi[iParmNum].SubScripts[0]=-1;
-					iParmNum++;
+					Parameters params;
+					params.push_back( new Parameter( "", Type( type2 ) ) );
 
 					//オーバーロードを解決
-					SubInfo *psi;
-					psi=OverloadSolution("==",subs,ppi,iParmNum,NULL);
-					HeapDefaultFree(ppi);
-
-					if(!psi){
+					UserProc *pUserProc;
+					pUserProc=OverloadSolution("==",subs, params, NULL);
+
+					delete params[0];
+
+					if(!pUserProc){
 						//エラー
 						return;
@@ -759,5 +759,5 @@
 
 					//call operator_proc	※ ==演算子
-					op_call(psi);
+					op_call(pUserProc);
 
 					//test rax,rax
@@ -769,9 +769,9 @@
 				}
 				else{
-					if(type1==DEF_DOUBLE){
+					if(type1.IsDouble()){
 						int xmm_reg;
 						if(IsXmmReg(reg2)) xmm_reg=reg2;
 						else xmm_reg=REG_XMM5;
-						ChangeTypeToXmm_Double(type2,xmm_reg,reg2);
+						ChangeTypeToXmm_Double(type2.GetBasicType(),xmm_reg,reg2);
 
 						//movsd xmm4,qword ptr[rsp+offset]	※スタックフレームから参照
@@ -781,9 +781,9 @@
 						op_comisd(xmm_reg,REG_XMM4);
 					}
-					else if(type1==DEF_SINGLE){
+					else if(type1.IsSingle()){
 						int xmm_reg;
 						if(IsXmmReg(reg2)) xmm_reg=reg2;
 						else xmm_reg=REG_XMM5;
-						ChangeTypeToXmm_Single(type2,xmm_reg,reg2);
+						ChangeTypeToXmm_Single(type2.GetBasicType(),xmm_reg,reg2);
 
 						//movss xmm4,dword ptr[rsp+offset]	※スタックフレームから参照
@@ -796,5 +796,5 @@
 						//その他整数型
 
-						i2=NeutralizationType(type1,-1,type2,-1);
+						i2=NeutralizationType(type1.GetBasicType(),-1,type2.GetBasicType(),-1);
 
 						//mov r14,qword ptr[rsp+offset]		※スタックフレームから参照
@@ -883,5 +883,5 @@
 
 	//call _System_GetEip
-	extern SubInfo *pSub_System_GetEip;
+	extern UserProc *pSub_System_GetEip;
 	op_call(pSub_System_GetEip);
 
@@ -938,6 +938,5 @@
 }
 void OpcodeReturn(char *Parameter){
-	extern BOOL bCompilingGlobal;
-	if(bCompilingGlobal){
+	if( UserProc::IsGlobalAreaCompiling() ){
 		SetError(62,NULL,cp);
 	}
@@ -945,22 +944,17 @@
 		//戻り値をセット
 		if(Parameter[0]){
-			extern SubInfo *pCompilingSubInfo;
-			char *temp;
-			if(pCompilingSubInfo->name[0]==1&&pCompilingSubInfo->name[1]==ESC_OPERATOR)
-				temp="_System_ReturnValue";
-			else temp=pCompilingSubInfo->name;
-
-			/*
-			TODO: 消す
-			if( pCompilingSubInfo->isReturnRef ){
-				//参照型
-				SetRefVariable( temp, Parameter );
+			UserProc &proc = UserProc::CompilingUserProc();
+
+			const char *temp = "_System_ReturnValue";
+			if(proc.GetName()[0]==1&&proc.GetName()[1]==ESC_OPERATOR)
+			{
 			}
 			else{
-				//値型*/
-				char temporary[VN_SIZE];
-				sprintf(temporary,"%s=%s",temp,Parameter);
-				OpcodeCalc(temporary);
-			//}
+				temp=proc.GetName().c_str();
+			}
+
+			char temporary[VN_SIZE];
+			sprintf(temporary,"%s=%s",temp,Parameter);
+			OpcodeCalc(temporary);
 		}
 
@@ -972,5 +966,5 @@
 void Opcode_Input(const char *Parameter){
 	extern int cp;
-	int i2,i3,i4,i5,type;
+	int i2,i3,i4,i5;
 	BOOL bFile;
 	char temporary[VN_SIZE],temp2[VN_SIZE],buffer[VN_SIZE];
@@ -1054,17 +1048,21 @@
 		}
 
-		LONG_PTR lpIndex;
-		type = GetVarType(temporary, &lpIndex, 1);
+		Type varType;
+		if( !GetVarType(temporary, varType, 1) ){
+			return;
+		}
 
 		sprintf(temp2,"_System_InputDataPtr[%d]=VarPtr(%s)",i4,temporary);
 		OpcodeCalc(temp2);
 
-		if(type==DEF_LONG) type=DEF_DWORD;
-		else if(type==DEF_INTEGER) type=DEF_WORD;
-		else if(type==DEF_OBJECT){
-			CClass *pobj_Class=(CClass *)lpIndex;
-			if(lstrcmp(pobj_Class->name,"String")==0) type=DEF_STRING;
-		}
-		sprintf(temp2,"_System_InputDataType[%d]=%d",i4,type);
+		if(varType.IsLong()) varType.SetBasicType( DEF_DWORD );
+		else if(varType.IsInteger()) varType.SetBasicType( DEF_WORD );
+		else if(varType.IsObject()){
+			varType.SetBasicType( DEF_OBJECT );
+			if( varType.IsStringObject() ){
+				varType.SetBasicType( DEF_STRING );
+			}
+		}
+		sprintf(temp2,"_System_InputDataType[%d]=%d",i4,varType.GetBasicType());
 		OpcodeCalc(temp2);
 
@@ -1075,12 +1073,12 @@
 	OpcodeCalc(temp2);
 
-	SubInfo *psi;
-	if(bFile) psi=GetSubHash("INPUT_FromFile");
-	else psi=GetSubHash("INPUT_FromPrompt");
-	if(!psi){
+	UserProc *pUserProc;
+	if(bFile) pUserProc=GetSubHash("INPUT_FromFile");
+	else pUserProc=GetSubHash("INPUT_FromPrompt");
+	if(!pUserProc){
 		SetError(3,"Input",cp);
 		return;
 	}
-	Opcode_CallProc(buffer,psi,0,"",0);
+	Opcode_CallProc(buffer,pUserProc,0,"",0);
 }
 void Opcode_PrintUsing(const char *Parameter,char *buffer,BOOL bFile){
@@ -1177,12 +1175,12 @@
 	OpcodeCalc(temp2);
 
-	SubInfo *psi;
-	if(bFile) psi=GetSubHash("PRINTUSING_ToFile");
-	else psi=GetSubHash("PRINTUSING_ToPrompt");
-	if(!psi){
+	UserProc *pUserProc;
+	if(bFile) pUserProc=GetSubHash("PRINTUSING_ToFile");
+	else pUserProc=GetSubHash("PRINTUSING_ToPrompt");
+	if(!pUserProc){
 		SetError(3,"Print",cp);
 		return;
 	}
-	Opcode_CallProc(buffer,psi,0,"",0);
+	Opcode_CallProc(buffer,pUserProc,0,"",0);
 }
 void Opcode_Print(const char *Parameter,BOOL bWrite){
@@ -1281,12 +1279,12 @@
 	if(sw) lstrcat(buffer,"+Ex\"\\r\\n\"");
 
-	SubInfo *psi;
-	if(bFile) psi=GetSubHash("PRINT_ToFile");
-	else psi=GetSubHash("PRINT_ToPrompt");
-	if(!psi){
+	UserProc *pUserProc;
+	if(bFile) pUserProc=GetSubHash("PRINT_ToFile");
+	else pUserProc=GetSubHash("PRINT_ToPrompt");
+	if(!pUserProc){
 		SetError(3,"Print",cp);
 		return;
 	}
-	Opcode_CallProc(buffer,psi,0,"",0);
+	Opcode_CallProc(buffer,pUserProc,0,"",0);
 }
 
@@ -1299,5 +1297,5 @@
 
 void OpcodeSetPtrData(char *Parameter,int type){
-	int i,i2;
+	int i;
 	char temporary[VN_SIZE];
 
@@ -1321,6 +1319,9 @@
 
 	int reg_ptr=REG_RAX;
-	i2=NumOpe(&reg_ptr,temporary,0,0,0);
-	if(!IsWholeNumberType(i2)){
+	Type resultType;
+	if( !NumOpe(&reg_ptr,temporary,Type(),resultType) ){
+		return;
+	}
+	if(!resultType.IsWhole()){
 		SetError(11,Parameter,cp);
 		return;
@@ -1338,5 +1339,7 @@
 
 	int temp_reg=REG_NON;
-	i2=NumOpe(&temp_reg,temporary,0,0,0);
+	if( !NumOpe(&temp_reg,temporary,Type(),resultType) ){
+		return;
+	}
 
 	//レジスタのブロッキングを解除
@@ -1344,5 +1347,5 @@
 
 	if(type==DEF_DOUBLE){
-		ChangeTypeToXmm_Double(i2,REG_XMM0,temp_reg);
+		ChangeTypeToXmm_Double(resultType.GetBasicType(),REG_XMM0,temp_reg);
 
 		//movsd qword ptr[reg_ptr],xmm0
@@ -1350,5 +1353,5 @@
 	}
 	else if(type==DEF_SINGLE){
-		ChangeTypeToXmm_Single(i2,REG_XMM0,temp_reg);
+		ChangeTypeToXmm_Single(resultType.GetBasicType(),REG_XMM0,temp_reg);
 
 		//movss dword ptr[reg_ptr],xmm0
@@ -1356,5 +1359,5 @@
 	}
 	else{
-		ChangeTypeToWhole(i2,type,REG_RCX,temp_reg);
+		ChangeTypeToWhole(resultType.GetBasicType(),type,REG_RCX,temp_reg);
 
 		//mov ptr[reg_ptr],rcx
