Index: trunk/abdev/BasicCompiler64/NumOpe_TypeOperation.cpp
===================================================================
--- trunk/abdev/BasicCompiler64/NumOpe_TypeOperation.cpp	(revision 266)
+++ trunk/abdev/BasicCompiler64/NumOpe_TypeOperation.cpp	(revision 308)
@@ -8,53 +8,65 @@
 #include "Opcode.h"
 
-void ExtendTypeTo64(int type,int reg){
-	if(type==DEF_LONG){
+void ExtendTypeTo64( const Type &oldType, int reg ){
+	if( oldType.IsLong() )
+	{
 		//movsxd reg64,reg32
 		compiler.codeGenerator.op_movsxd(reg,reg);
 	}
-	else if(type==DEF_DWORD){
+	else if( oldType.IsDWord() )
+	{
 		//and reg,00000000FFFFFFFFh
 	}
-	else if(type==DEF_INTEGER || (Smoothie::IsUnicode()&&type==DEF_CHAR)){
+	else if( oldType.IsInteger() )
+	{
 		//movsx reg64,reg16
 		compiler.codeGenerator.op_movsx64_FromReg16(reg,reg);
 	}
-	else if(type==DEF_WORD){
+	else if( oldType.IsWord() )
+	{
 		//and reg,000000000000FFFFh
 		compiler.codeGenerator.op_and64_value(reg,(int)0xFFFF);
 	}
-	else if(type==DEF_SBYTE || (Smoothie::IsUnicode()==false&&type==DEF_CHAR)){
+	else if( oldType.IsSByte() )
+	{
 		//movsx reg64,reg8
 		compiler.codeGenerator.op_movsx64_FromReg8(reg,reg);
 	}
-	else if(type==DEF_BYTE || type==DEF_BOOLEAN){
+	else if( oldType.IsByte() || oldType.IsBoolean() )
+	{
 		//and reg,00000000000000FFh
 		compiler.codeGenerator.op_and64_value(reg,(int)0x00FF);
 	}
 }
-void ExtendTypeTo32(int type,int reg){
-	if(type==DEF_INTEGER || (Smoothie::IsUnicode()&&type==DEF_CHAR)){
+void ExtendTypeTo32( const Type &oldType, int reg ){
+	if( oldType.IsInteger() )
+	{
 		//movsx reg32,reg16
 		compiler.codeGenerator.op_movsx32_FromReg16(reg,reg);
 	}
-	else if(type==DEF_WORD){
+	else if( oldType.IsWord() )
+	{
 		//and reg,0000FFFFh
 		compiler.codeGenerator.op_and32_value(reg,(int)0xFFFF);
 	}
-	else if(type==DEF_SBYTE || (Smoothie::IsUnicode()==false&&type==DEF_CHAR)){
+	else if( oldType.IsSByte() )
+	{
 		//movsx reg32,reg8
 		compiler.codeGenerator.op_movsx32_FromReg8(reg,reg);
 	}
-	else if(type==DEF_BYTE || type==DEF_BOOLEAN){
+	else if( oldType.IsByte() || oldType.IsBoolean() )
+	{
 		//and reg,000000FFh
 		compiler.codeGenerator.op_and32_value(reg,(int)0xFF);
 	}
 }
-void ExtendTypeTo16(int type,int reg){
-	if(type==DEF_SBYTE || (Smoothie::IsUnicode()==false&&type==DEF_CHAR)){
+void ExtendTypeTo16( const Type &oldType, int reg ){
+	if( oldType.IsSByte() )
+	{
 		//movsx reg16,reg8
 		compiler.codeGenerator.op_movsx16_FromReg8(reg,reg);
 	}
-	else if(type==DEF_BYTE){
+	else if( oldType.IsByte() || oldType.IsBoolean() )
+	{
 		//and reg,000000FFh
 		compiler.codeGenerator.op_and32_value(reg,(int)0xFF);
@@ -183,21 +195,28 @@
 }
 
-void ChangeTypeToWhole(int OldType,int NewType,int reg,int xmm_reg){
-	if(OldType==DEF_DOUBLE){
-		if(Is64Type(NewType)){
+void ChangeTypeToWhole( const Type &oldType, const Type &newType, int reg, int xmm_reg )
+{
+	if( oldType.IsDouble() )
+	{
+		if( newType.Is64() )
+		{
 			//cvttsd2si reg,xmm_reg
 			compiler.codeGenerator.op_cvttsd2si_xmm(sizeof(_int64),reg,xmm_reg);
 		}
-		else{
+		else
+		{
 			//cvttsd2si reg,xmm_reg
 			compiler.codeGenerator.op_cvttsd2si_xmm(sizeof(long),reg,xmm_reg);
 		}
 	}
-	else if(OldType==DEF_SINGLE){
-		if(Is64Type(NewType)){
+	if( oldType.IsSingle() )
+	{
+		if( newType.Is64() )
+		{
 			//cvttss2si reg,xmm_reg
 			compiler.codeGenerator.op_cvttss2si_xmm(sizeof(_int64),reg,xmm_reg);
 		}
-		else{
+		else
+		{
 			//cvttss2si reg,xmm_reg
 			compiler.codeGenerator.op_cvttss2si_xmm(sizeof(long),reg,xmm_reg);
@@ -207,12 +226,15 @@
 		//整数から整数へ変換
 
-		if(Is64Type(NewType)){
-			ExtendTypeTo64(OldType,reg);
-		}
-		else if(GetTypeSize(NewType,-1)==sizeof(long)){
-			ExtendTypeTo32(OldType,reg);
-		}
-		else if(GetTypeSize(NewType,-1)==sizeof(short)){
-			ExtendTypeTo16(OldType,reg);
+		if( newType.Is64() )
+		{
+			ExtendTypeTo64(oldType,reg);
+		}
+		if( newType.GetSize() == sizeof(long) )
+		{
+			ExtendTypeTo32(oldType,reg);
+		}
+		if( newType.GetSize() == sizeof(short) )
+		{
+			ExtendTypeTo16(oldType,reg);
 		}
 	}
@@ -477,25 +499,33 @@
 	sp=*pStackPointer;
 
-	int CastType;
-	CastType=type[sp-1];
-	if((CastType&FLAG_CAST)==0){
+	int castBasicType = type[sp-1];
+	if((castBasicType&FLAG_CAST)==0){
 		SetError(47,NULL,cp);
 		return 0;
 	}
-	CastType=CastType&(~FLAG_CAST);
+	castBasicType = castBasicType&(~FLAG_CAST);
+
+	Type oldType( type[sp-2], index_stack[sp-2] );
+	Type castType( castBasicType, index_stack[sp-1] );
 
 	int xmm_reg,reg;
-
-	if(IsRealNumberType(CastType)){
+	if( castType.IsReal() )
+	{
 		//実数型へキャスト
 
-		if(IsRealNumberType(type[sp-2])){
-			SetOneTermToReg_RealCalc(type[sp-2],&xmm_reg);
-		}
-		else{
-			if(Is64Type(type[sp-2]))
-				SetOneTermToReg_Whole64Calc(type[sp-2],&reg);
-			else if(IsWholeNumberType(type[sp-2]))
-				SetOneTermToReg_Whole32Calc(type[sp-2],&reg);
+		if( oldType.IsReal() )
+		{
+			SetOneTermToReg_RealCalc(oldType.GetBasicType(),&xmm_reg);
+		}
+		else
+		{
+			if( oldType.Is64() )
+			{
+				SetOneTermToReg_Whole64Calc(oldType.GetBasicType(),&reg);
+			}
+			else if( oldType.IsWhole() )
+			{
+				SetOneTermToReg_Whole32Calc(oldType.GetBasicType(),&reg);
+			}
 
 			pobj_reg->UnlockReg();
@@ -504,11 +534,13 @@
 		}
 
-		if(CastType==DEF_DOUBLE){
+		if( castType.IsDouble() )
+		{
 			//Double型にデータ変換
-			ChangeTypeToXmm_Double(type[sp-2],xmm_reg,reg);
-		}
-		else if(CastType==DEF_SINGLE){
+			ChangeTypeToXmm_Double(oldType.GetBasicType(),xmm_reg,reg);
+		}
+		else if( castType.IsSingle() )
+		{
 			//Single型にデータ変換
-			ChangeTypeToXmm_Single(type[sp-2],xmm_reg,reg);
+			ChangeTypeToXmm_Single(oldType.GetBasicType(),xmm_reg,reg);
 		}
 
@@ -521,6 +553,7 @@
 		//その他整数型へ変換
 
-		if(IsRealNumberType(type[sp-2])){
-			SetOneTermToReg_RealCalc(type[sp-2],&xmm_reg);
+		if( oldType.IsReal() )
+		{
+			SetOneTermToReg_RealCalc(oldType.GetBasicType(),&xmm_reg);
 
 			pobj_reg->UnlockXmmReg();
@@ -529,5 +562,5 @@
 
 			//整数型へデータ変換
-			ChangeTypeToWhole(type[sp-2],CastType,reg,xmm_reg);
+			ChangeTypeToWhole(oldType,castType,reg,xmm_reg);
 
 			if(reg==REG_R14){
@@ -545,5 +578,5 @@
 
 			//整数型へデータ変換
-			ChangeTypeToWhole(type[sp-2],CastType,reg,0);
+			ChangeTypeToWhole(oldType,castType,reg,0);
 
 			if(reg==REG_R14){
@@ -554,6 +587,6 @@
 	}
 
-	type[sp-2]=CastType;
-	index_stack[sp-2]=index_stack[sp-1];
+	type[sp-2] = castType.GetBasicType();
+	index_stack[sp-2] = castType.GetIndex();
 
 	sp--;
