Index: BasicCompiler_Common/NumOpe_GetType.cpp
===================================================================
--- BasicCompiler_Common/NumOpe_GetType.cpp	(revision 73)
+++ BasicCompiler_Common/NumOpe_GetType.cpp	(revision 75)
@@ -28,5 +28,5 @@
 	type=CalcType;
 
-	if(!BaseType){
+	if(BaseType==0||BaseType==-1){
 		//ベースタイプが未定のとき
 		return type;
@@ -38,5 +38,5 @@
 	}
 
-	if(BaseType==DEF_OBJECT){
+	if(BaseType==DEF_OBJECT||BaseType==DEF_STRUCT){
 		//ベースタイプがオブジェクトのときは暗黙の変換は必要なし
 		return type;
@@ -188,10 +188,10 @@
 }
 
-int GetReturnType_OperatorProc(int idCalc,TYPEINFO *pBaseTypeInfo,int *type,LONG_PTR *index_stack,int &sp){
+int GetReturnType_OperatorProc(int idCalc,const Type &baseType,int *type,LONG_PTR *index_stack,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 ){
@@ -212,15 +212,8 @@
 
 	//_System_LocalThis
-	PARAMETER_INFO *ppi = (PARAMETER_INFO *)HeapAlloc(hHeap,0,sizeof(PARAMETER_INFO)*3);
-	int iParmNum=0;
+	Parameters params;
 
 	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++;
+		params.push_back( new Parameter( "", Type( type[sp-1], index_stack[sp-1] ) ) );
 	}
 
@@ -230,30 +223,28 @@
 	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(bTwoTerm){
+		delete params[0];
+	}
+
+	if(!pUserProc){
 		return 0;
 	}
 	else{
 		//オーバーロードされていないが、パラメータ個数が一致しないとき
-		if(iParmNum!=psi->params.size()){
-			HeapDefaultFree(ppi);
+		if(params.size()!=pUserProc->Params().size()){
 			return 0;
 		}
 	}
 
-	HeapDefaultFree(ppi);
-
 	sp--;
-	type[sp-1]=psi->ReturnType;
-	index_stack[sp-1]=psi->u.ReturnIndex;
+	type[sp-1]=pUserProc->ReturnType().GetBasicType();
+	index_stack[sp-1]=pUserProc->ReturnType().GetIndex();
 
 	return 1;
 }
 
-int Operator_New_GetType(const char *Parameter,LONG_PTR *plpIndex,const TYPEINFO &baseTypeInfo ){
+bool Operator_New_GetType(const char *Parameter,const Type &baseType, Type &resultType ){
 	char TypeName[VN_SIZE],CreateParameter[VN_SIZE],objectSizeStr[VN_SIZE];
 	int i,i2;
@@ -279,5 +270,5 @@
 			if(Parameter[i]!='\0'){
 				SetError(42,NULL,cp);
-				return 0;
+				return false;
 			}
 			break;
@@ -290,26 +281,30 @@
 	}
 
-	int type;
-	type=GetTypeFixed(TypeName,plpIndex);
-
-	if( baseTypeInfo.type == DEF_OBJECT ){
-		return DEF_OBJECT;
-	}
-	return DEF_PTR_OBJECT;
+	if( !Type::StringToType( TypeName, resultType ) ){
+		return false;
+	}
+
+	if( baseType.IsObject() ){
+		resultType.SetBasicType( DEF_OBJECT );
+	}
+	else{
+		resultType.SetBasicType( DEF_PTR_OBJECT );
+	}
+	return true;
 }
 
-int NumOpe_GetType_Old( const char *Command,TYPEINFO *pBaseType,LONG_PTR *plpIndex){
+bool NumOpe_GetType( const char *expression, const Type &baseType, Type &resultType ){
 	extern int cp;
 	int i,i2,i3,i4;
 	char temporary[1024],temp2[1024],temp3[1024];
 
-	if(Command[0]=='\0'){
+	if(expression[0]=='\0'){
 		SetError(1,NULL,cp);
-		return 0;
-	}
-
-	if(Command[0]==1&& Command[1]==ESC_NEW ){
+		return false;
+	}
+
+	if(expression[0]==1&& expression[1]==ESC_NEW ){
 		//New演算子（オブジェクト生成）
-		return Operator_New_GetType(Command+2,plpIndex, *pBaseType );
+		return Operator_New_GetType(expression+2,baseType, resultType );
 	}
 
@@ -323,9 +318,9 @@
 	long stack[255];
 	int pnum;
-	if(!GetNumOpeElements(Command,&pnum,values,calc,stack)){
+	if(!GetNumOpeElements(expression,&pnum,values,calc,stack)){
 		for(i=0;i<pnum;i++){
 			if(values[i]) HeapDefaultFree(values[i]);
 		}
-		return 0;
+		return false;
 	}
 
@@ -343,5 +338,5 @@
 
 	int sp;
-	int type[255];
+	int type_stack[255];
 	LONG_PTR index_stack[255];
 	_int64 i64data;
@@ -351,7 +346,7 @@
 
 		if(idCalc){
-			if(type[sp-2]==DEF_OBJECT){
+			if(type_stack[sp-2]==DEF_OBJECT){
 				//オーバーロードされたオペレータを呼び出す
-				if(!GetReturnType_OperatorProc(idCalc,pBaseType,type,index_stack,sp)){
+				if(!GetReturnType_OperatorProc(idCalc,baseType,type_stack,index_stack,sp)){
 					goto error;
 				}
@@ -360,5 +355,5 @@
 			}
 
-			if(!CheckCalcType(idCalc,type,sp)) goto error;
+			if(!CheckCalcType(idCalc,type_stack,sp)) goto error;
 		}
 
@@ -374,20 +369,16 @@
 StrLiteral:
 
-					if(pBaseType){
-						if(pBaseType->type==DEF_OBJECT){
-							if(IsStringObjectType(*pBaseType)){
-								//要求タイプがオブジェクトであり、Stringの受け入れが可能な場合
-								extern CClass *pobj_StringClass;
-								type[sp]=DEF_OBJECT;
-								index_stack[sp]=(LONG_PTR)pobj_StringClass;
-								bLiteralCalculation=0;
-
-								sp++;
-								break;
-							}
-						}
+					if( baseType.IsStringObject() ){
+						//要求タイプがオブジェクトであり、Stringの受け入れが可能な場合
+						extern CClass *pobj_StringClass;
+						type_stack[sp]=DEF_OBJECT;
+						index_stack[sp]=(LONG_PTR)pobj_StringClass;
+						bLiteralCalculation=0;
+
+						sp++;
+						break;
 					}
 
-					type[sp]=typeOfPtrChar;
+					type_stack[sp]=typeOfPtrChar;
 					bLiteralCalculation=0;
 				}
@@ -413,6 +404,6 @@
 
 						int idProc;
-						void *pInfo;
-						idProc=GetProc(temporary,&pInfo);
+						void *pProc;
+						idProc=GetProc(temporary,(void **)&pProc);
 
 						if(idProc){
@@ -433,11 +424,16 @@
 							////////////////
 
-							i2=GetReturnTypeOfProc(idProc,pInfo,temporary,temp2,&index_stack[sp]);
-							if(i2==-1){
+							Type resultType;
+							if( !CallProc(idProc,pProc,temporary,temp2, resultType, false ) ){
+								goto error;
+							}
+							if( resultType.IsNull() ){
 								//戻り値が存在しないとき
 								goto error;
 							}
 
-							type[sp]=i2;
+							type_stack[sp] = resultType.GetBasicType();
+							index_stack[sp] = resultType.GetIndex();
+
 							bLiteralCalculation=0;
 
@@ -454,12 +450,14 @@
 
 							//マクロ関数の場合
-							i2=NumOpe_GetType_Old(temp3,NULL,&index_stack[sp]);
-
-							if(!IS_LITERAL(index_stack[sp])){
+							Type tempType;
+							NumOpe_GetType(temp3,Type(),tempType);
+
+							if(!IS_LITERAL(tempType.GetIndex())){
 								//リテラル値ではなかったとき
 								bLiteralCalculation=0;
 							}
 
-							type[sp]=i2;
+							type_stack[sp] = tempType.GetBasicType();
+							index_stack[sp] = tempType.GetIndex(); 
 
 							sp++;
@@ -473,14 +471,13 @@
 					GetArrayElement(term,VarName,ArrayElements);
 					if(ArrayElements[0]){
-						CClass *pobj_c;
-						i2=GetVarType(VarName,(LONG_PTR *)&pobj_c,0);
-						if(i2==DEF_OBJECT){
-							TYPEINFO RetTypeInfo;
-							if( !GetReturnTypeOfIndexerGetterProc(pobj_c,RetTypeInfo) ){
+						Type type;
+						GetVarType(VarName,type,false);
+						if( type.IsObject() ){
+							if( !GetReturnTypeOfIndexerGetterProc( type.GetClass(),type) ){
 								SetError(1,NULL,cp);
 								goto error;
 							}
-							type[sp]=RetTypeInfo.type;
-							index_stack[sp]=RetTypeInfo.u.lpIndex;
+							type_stack[sp]=type.GetBasicType();
+							index_stack[sp]=type.GetIndex();
 							bLiteralCalculation=0;
 
@@ -493,7 +490,7 @@
 					// Nothing
 					if( lstrcmp( term, "Nothing" ) == 0 ){
-						type[sp] = DEF_OBJECT;
-						if( pBaseType && pBaseType->type == DEF_OBJECT ){
-							index_stack[sp] = pBaseType->u.lpIndex;
+						type_stack[sp] = DEF_OBJECT;
+						if( baseType.IsObject() ){
+							index_stack[sp] = baseType.GetIndex();
 						}
 						else{
@@ -506,17 +503,18 @@
 
 
-					i2=GetVarType(term,&index_stack[sp],0);
-					if(i2!=-1){
+					Type varType;
+					if( GetVarType(term,varType,0) ){
 						//////////
 						// 変数
 						//////////
 
-						if(i2&FLAG_PTR){
+						if( varType.GetBasicType() & FLAG_PTR ){
 							//配列ポインタ
-							type[sp]=GetPtrType(i2^FLAG_PTR,index_stack[sp]);
+							type_stack[sp]=GetPtrType( varType.GetBasicType()^FLAG_PTR );
 						}
 						else{
-							type[sp]=i2;
-						}
+							type_stack[sp]=varType.GetBasicType();
+						}
+						index_stack[sp] = varType.GetIndex();
 
 						bLiteralCalculation=0;
@@ -532,5 +530,5 @@
 					i3 = CDBConst::obj.GetType(term);
 					if(i3){
-						type[sp]=i3;
+						type_stack[sp]=i3;
 						if(IsRealNumberType(i3)){
 							//実数
@@ -563,5 +561,5 @@
 					i3=GetTypeFixed(term,&lp);
 					if(i3!=-1){
-						type[sp]=i3|FLAG_CAST;
+						type_stack[sp]=i3|FLAG_CAST;
 						index_stack[sp]=lp;
 						sp++;
@@ -579,11 +577,11 @@
 
 					if(GetSubHash(VarName,0)){
-						TYPEINFO RetTypeInfo;
-						GetReturnTypeOfPropertyMethod(term,NULL,&RetTypeInfo);
+						Type tempType;
+						GetReturnTypeOfPropertyMethod(term,NULL,tempType);
 
 						//大きな型への暗黙の変換
-						type[sp]=RetTypeInfo.type;
-
-						index_stack[sp]=RetTypeInfo.u.lpIndex;
+						type_stack[sp]=tempType.GetBasicType();
+
+						index_stack[sp]=tempType.GetIndex();
 						bLiteralCalculation=0;
 
@@ -597,12 +595,11 @@
 					bError=1;
 					SetError(3,term,cp);
-					type[sp]=DEF_DOUBLE;
+					type_stack[sp]=DEF_DOUBLE;
 				}
 				else{
 					//リテラル値
-					int base_type;
-					base_type=0;
-					if(pBaseType) base_type=pBaseType->type;
-					type[sp]=GetLiteralValue(term,&i64data,base_type);
+					int base_type = 0;
+					if( !baseType.IsNull() ) base_type = baseType.GetBasicType();
+					type_stack[sp]=GetLiteralValue(term,&i64data,base_type);
 Literal:
 					if((long)i64data==0&&index_stack[sp]==-1) index_stack[sp]=LITERAL_NULL;
@@ -617,5 +614,5 @@
 			case CALC_AND:
 				sp--;
-				type[sp-1]=NeutralizationType(type[sp-1],index_stack[sp-1],type[sp],index_stack[sp]);
+				type_stack[sp-1]=NeutralizationType(type_stack[sp-1],index_stack[sp-1],type_stack[sp],index_stack[sp]);
 				break;
 			case CALC_NOT:
@@ -632,5 +629,5 @@
 			case CALC_EQUAL:	//values[sp-2] =  values[sp-1]	
 				sp--;
-				type[sp-1]=DEF_LONG;
+				type_stack[sp-1]=DEF_LONG;
 				break;
 
@@ -646,5 +643,5 @@
 			case CALC_PRODUCT:
 				sp--;
-				type[sp-1]=NeutralizationType(type[sp-1],index_stack[sp-1],type[sp],index_stack[sp]);
+				type_stack[sp-1]=NeutralizationType(type_stack[sp-1],index_stack[sp-1],type_stack[sp],index_stack[sp]);
 				break;
 			case CALC_MOD:
@@ -652,5 +649,5 @@
 				//剰余演算
 				sp--;
-				type[sp-1]=NeutralizationType(type[sp-1],index_stack[sp-1],type[sp],index_stack[sp]);
+				type_stack[sp-1]=NeutralizationType(type_stack[sp-1],index_stack[sp-1],type_stack[sp],index_stack[sp]);
 				break;
 			case CALC_QUOTIENT:
@@ -658,5 +655,5 @@
 				//除算
 				sp--;
-				type[sp-1]=NeutralizationType(type[sp-1],index_stack[sp-1],type[sp],index_stack[sp]);
+				type_stack[sp-1]=NeutralizationType(type_stack[sp-1],index_stack[sp-1],type_stack[sp],index_stack[sp]);
 				break;
 			case CALC_INTQUOTIENT:
@@ -664,5 +661,5 @@
 				//整数除算
 				sp--;
-				type[sp-1]=NeutralizationType(type[sp-1],index_stack[sp-1],type[sp],index_stack[sp]);
+				type_stack[sp-1]=NeutralizationType(type_stack[sp-1],index_stack[sp-1],type_stack[sp],index_stack[sp]);
 				break;
 			case CALC_MINUSMARK:
@@ -677,5 +674,5 @@
 			case CALC_AS:
 				//キャスト
-				type[sp-2]=type[sp-1]&(~FLAG_CAST);
+				type_stack[sp-2]=type_stack[sp-1]&(~FLAG_CAST);
 				index_stack[sp-2]=index_stack[sp-1];
 
@@ -685,5 +682,5 @@
 			case CALC_BYVAL:
 				//ポインタ型→参照型
-				if( PTR_LEVEL( type[sp-1] ) <= 0 ){
+				if( PTR_LEVEL( type_stack[sp-1] ) <= 0 ){
 					//ポインタ型ではないとき
 					SetError( 3, NULL, cp );
@@ -691,5 +688,5 @@
 				}
 
-				type[sp-1] = PTR_LEVEL_DOWN( type[sp-1] );
+				type_stack[sp-1] = PTR_LEVEL_DOWN( type_stack[sp-1] );
 				break;
 		}
@@ -705,11 +702,11 @@
 	if(bLiteralCalculation){
 		//右辺値が数値の定数式の場合
-		LONG_PTR lpCalcIndex;
-		int base_type=0;
-		if(pBaseType) base_type=pBaseType->type;
-		i2=StaticCalculation(true, Command,base_type,&i64data,&lpCalcIndex);
-
-		type[0]=i2;
-		index_stack[0]=lpCalcIndex;
+		int base_type = 0;
+		if( !baseType.IsNull() ) base_type = baseType.GetBasicType();
+		Type tempType;
+		StaticCalculation(true, expression,base_type,&i64data,tempType);
+
+		type_stack[0]=tempType.GetBasicType();
+		index_stack[0]=tempType.GetIndex();
 	}
 	else{
@@ -718,8 +715,7 @@
 	}
 
-	if(plpIndex) *plpIndex=index_stack[0];
-
-	int RetType;
-	RetType=type[0];
+	resultType.SetType( type_stack[0], index_stack[0] );
+
+	bool isSuccessful = true;
 	goto finish;
 
@@ -730,5 +726,5 @@
 
 error:
-	RetType=-1;
+	isSuccessful = false;
 	goto finish;
 
@@ -738,20 +734,4 @@
 		if(values[i]) HeapDefaultFree(values[i]);
 	}
-	return RetType;
+	return isSuccessful;
 }
-
-bool NumOpe_GetType( const char *expression, const Type &baseType, Type &resultType ){
-	TYPEINFO baseTypeInfo = {
-		baseType.GetBasicType(),
-		baseType.GetIndex()
-	};
-	LONG_PTR lpIndex;
-	int basicType = NumOpe_GetType_Old( expression,
-		baseType.IsNull() ? NULL:&baseTypeInfo,
-		&lpIndex );
-
-	resultType.SetBasicType( basicType );
-	resultType.SetIndex( lpIndex );
-
-	return ( basicType != -1 );
-}
