Index: BasicCompiler64/OperatorProc.cpp
===================================================================
--- BasicCompiler64/OperatorProc.cpp	(revision 73)
+++ BasicCompiler64/OperatorProc.cpp	(revision 75)
@@ -2,5 +2,5 @@
 #include "Opcode.h"
 
-void FreeTempObject(int reg,CClass *pobj_c){
+void FreeTempObject(int reg,const CClass *pobj_c){
 	if(!IsSafeReg(reg)) SetError(300,NULL,cp);
 
@@ -16,5 +16,5 @@
 
 		//call DestructorProcAddr
-		op_call( method->psi );
+		op_call( method->pUserProc );
 	}
 
@@ -23,14 +23,14 @@
 
 	//call free
-	extern SubInfo *pSub_free;
+	extern UserProc *pSub_free;
 	op_call(pSub_free);
 }
 
-int CallOperatorProc(int idCalc,TYPEINFO *pBaseTypeInfo,int *type,LONG_PTR *index_stack,BOOL *bUseHeap,int &sp){
+int CallOperatorProc(int idCalc, const Type &baseType, int *type_stack,LONG_PTR *index_stack,BOOL *bUseHeap,int &sp){
 	//オーバーロードされたオペレータ関数を呼び出す
 	CClass *pobj_c;
 	pobj_c=(CClass *)index_stack[sp-2];
 
-	std::vector<SubInfo *> subs;
+	std::vector<UserProc *> subs;
 	pobj_c->EnumMethod( idCalc, subs );
 	if( subs.size() == 0 ){
@@ -45,19 +45,4 @@
 
 	int i;
-	BOOL bReturnTypeIsObject=1;
-	TYPEINFO ReturnType={DEF_OBJECT,subs[0]->u.ReturnIndex};
-	for(i=0;i<subs.size();i++){
-		if(subs[i]->ReturnType!=DEF_OBJECT)
-			bReturnTypeIsObject=0;
-	}
-
-	if(bReturnTypeIsObject==0){
-		if(pBaseTypeInfo){
-			if(pBaseTypeInfo->type==DEF_OBJECT){
-				ReturnType.u.lpIndex=pBaseTypeInfo->u.lpIndex;
-			}
-		}
-	}
-
 
 
@@ -66,17 +51,9 @@
 	/////////////////////////////////////////////
 
-	PARAMETER_INFO *ppi = (PARAMETER_INFO *)HeapAlloc(hHeap,0,sizeof(PARAMETER_INFO)*3);
-	int iParmNum=0;
-
-	if(bTwoTerm){
-		ppi[iParmNum].bArray=0;
-		ppi[iParmNum].bByVal=0;
-		ppi[iParmNum].name=0;
-		ppi[iParmNum].type=type[sp-1];
-		ppi[iParmNum].u.index=index_stack[sp-1];
-		ppi[iParmNum].SubScripts[0]=-1;
-		iParmNum++;
-	}
-
+	Parameters params;
+
+	if(bTwoTerm){
+		params.push_back( new Parameter( "", Type( type_stack[sp-1], index_stack[sp-1] ) ) );
+	}
 
 	//オーバーロードを解決
@@ -84,34 +61,40 @@
 	if(idCalc==CALC_EQUAL) lstrcpy(temporary,"==");
 	else GetCalcName(idCalc,temporary);
-	SubInfo *psi;
-	psi=OverloadSolution(temporary,subs,ppi,iParmNum,pBaseTypeInfo);
-
-
-	if(!psi){
-		HeapDefaultFree(ppi);
+	UserProc *pUserProc = OverloadSolution( temporary, subs, params, baseType );
+
+	if(!pUserProc){
+		if(bTwoTerm){
+			delete params[0];
+		}
 		return -1;
 	}
 	else{
 		//オーバーロードされていないが、パラメータ個数が一致しないとき
-		if(iParmNum!=psi->params.size()){
-			HeapDefaultFree(ppi);
+		if(params.size()!=pUserProc->Params().size()){
+			if(bTwoTerm){
+				delete params[0];
+			}
 			return -1;
 		}
 	}
 
-	for(i=0;i<iParmNum;i++){
+	for(i=0;i<(int)params.size();i++){
 		CheckDifferentType(
-			psi->params[i]->GetBasicType(),
-			psi->params[i]->GetIndex(),
-			ppi[i].type,
-			ppi[i].u.index,
+			pUserProc->Params()[i]->GetBasicType(),
+			pUserProc->Params()[i]->GetIndex(),
+			params[i]->GetBasicType(),
+			params[i]->GetIndex(),
 			"",
 			i);
 	}
 
-	HeapDefaultFree(ppi);
-
-	if(bTwoTerm){
-		if( psi->realParams[1]->IsStruct() && psi->realParams[1]->IsRef() == false ){
+	if(bTwoTerm){
+		delete params[0];
+	}
+
+	int right_side_size = GetTypeSize(type_stack[sp-1],index_stack[sp-1]);
+
+	if(bTwoTerm){
+		if( pUserProc->RealParams()[1]->IsStruct() &&pUserProc->RealParams()[1]->IsRef() == false ){
 			//一時オブジェクトはメソッド内で破棄される
 			bUseHeap[sp-1]=0;
@@ -119,5 +102,6 @@
 	}
 
-	if(psi->ReturnType==DEF_STRUCT){
+
+	if( pUserProc->ReturnType().IsStruct() ){
 		//////////////////////////////////////////////////////
 		// 戻り値に構造体インスタンスを持つ場合
@@ -131,5 +115,5 @@
 		//////////////////////////////////////////////////////
 
-			int object_size = psi->u.Return_pobj_c->GetSize();
+			int object_size = pUserProc->ReturnType().GetClass().GetSize();
 
 			//mov rcx,object_size
@@ -137,5 +121,5 @@
 
 			//call calloc
-			extern SubInfo *pSub_calloc;
+			extern UserProc *pSub_calloc;
 			op_call(pSub_calloc);
 
@@ -152,7 +136,7 @@
 	if(bTwoTerm){
 		//右の項（実数の場合が未完成）
-		SetOneTermToReg_Whole64Calc(type[sp-1],&reg2);
+		SetOneTermToReg_Whole64Calc(type_stack[sp-1],&reg2);
 		pobj_reg->UnlockReg();
-		if( !psi->realParams[1]->IsRef() == false ){
+		if( !pUserProc->RealParams()[1]->IsRef() == false ){
 			//一時参照を作成
 			pobj_sf->push( reg2 );
@@ -190,5 +174,5 @@
 
 		if(bTwoTerm){
-			if(psi->ReturnType==DEF_STRUCT){
+			if( pUserProc->ReturnType().IsStruct() ){
 				//mov r8,reg2
 				op_mov_RR(REG_R8,reg2);
@@ -200,5 +184,5 @@
 		}
 
-		if(psi->ReturnType==DEF_STRUCT){
+		if( pUserProc->ReturnType().IsStruct() ){
 			//mov rdx,r13
 			op_mov_RR(REG_RDX,REG_R13);
@@ -209,7 +193,7 @@
 
 		//call operator_proc
-		op_call(psi);
-
-		if(psi->ReturnType!=DEF_NON){
+		op_call(pUserProc);
+
+		if( !pUserProc->ReturnType().IsNull() ){
 			//戻り値を一時的に退避
 
@@ -253,5 +237,5 @@
 
 	if(bTwoTerm){
-		if( !psi->realParams[1]->IsRef() == false ){
+		if( !pUserProc->RealParams()[1]->IsRef() == false ){
 			//一時参照を破棄
 			pobj_sf->pop();
@@ -259,5 +243,5 @@
 	}
 
-	if(psi->ReturnType!=DEF_NON){
+	if( !pUserProc->ReturnType().IsNull() ){
 		//戻り値をreg1にセット
 		reg1=pobj_reg->LockReg();
@@ -268,8 +252,8 @@
 
 	sp--;
-	type[sp-1]=psi->ReturnType;
-	index_stack[sp-1]=psi->u.ReturnIndex;
-
-	if(psi->ReturnType==DEF_STRUCT){
+	type_stack[sp-1]=pUserProc->ReturnType().GetBasicType();
+	index_stack[sp-1]=pUserProc->ReturnType().GetIndex();
+
+	if( pUserProc->ReturnType().IsStruct() ){
 		//構造体が戻ったときはヒープ領域にインスタンスが格納されている
 		//※後にfreeする必要あり
@@ -281,6 +265,6 @@
 }
 
-void CallCastOperatorProc(int reg,int &CalcType,LONG_PTR &lpCalcIndex,BOOL bCalcUseHeap,int ToType,LONG_PTR lpToIndex){
-	int type[10];
+void CallCastOperatorProc(int reg,Type &calcType,BOOL bCalcUseHeap,const Type &toType){
+	int type_stack[10];
 	LONG_PTR index_stack[10];
 	BOOL array_bUseHeap[10];
@@ -304,14 +288,12 @@
 
 		//左辺
-		type[0]=CalcType;
-		index_stack[0]=lpCalcIndex;
+		type_stack[0]=calcType.GetBasicType();
+		index_stack[0]=calcType.GetIndex();
 		array_bUseHeap[0]=0;
-		type[1]=ToType;
-		index_stack[1]=lpToIndex;
+		type_stack[1]=toType.GetBasicType();
+		index_stack[1]=toType.GetIndex();
 		array_bUseHeap[1]=0;
 
-		TYPEINFO BaseTypeInfo={ToType,lpToIndex};
-
-		iRet=CallOperatorProc(CALC_AS,&BaseTypeInfo,type,index_stack,array_bUseHeap,sp);
+		iRet=CallOperatorProc(CALC_AS,toType,type_stack,index_stack,array_bUseHeap,sp);
 
 		pobj_reg->UnlockReg();
@@ -325,6 +307,5 @@
 	if(iRet==1){
 		//成功したとき
-		CalcType=type[0];
-		lpCalcIndex=index_stack[0];
+		calcType.SetType( type_stack[0], index_stack[0] );
 		return;
 	}
@@ -339,7 +320,7 @@
 
 //インデクサ（getter）を呼び出す
-void CallIndexerGetterProc(int reg,CClass *pobj_Class,char *ObjectName,char *Parameter,TYPEINFO &RetTypeInfo){
-
-	std::vector<SubInfo *> subs;
+void CallIndexerGetterProc(int reg,const CClass *pobj_Class,char *ObjectName,char *Parameter,Type &resultType ){
+
+	std::vector<UserProc *> subs;
 	pobj_Class->EnumMethod( CALC_ARRAY_GET, subs );
 	if( subs.size() == 0 ){
@@ -353,6 +334,5 @@
 
 		Opcode_CallProc(Parameter,subs[0],0,ObjectName,DEF_OBJECT);
-		RetTypeInfo.type = subs[0]->ReturnType;
-		RetTypeInfo.u.lpIndex = subs[0]->u.ReturnIndex;
+		resultType = subs[0]->ReturnType();
 
 		//mov reg,rax
