Index: trunk/abdev/BasicCompiler_Common/error.cpp
===================================================================
--- trunk/abdev/BasicCompiler_Common/error.cpp	(revision 287)
+++ trunk/abdev/BasicCompiler_Common/error.cpp	(revision 290)
@@ -388,11 +388,15 @@
 
 #define STRING_SYSTEM_DECLAREHANDLE "*_System_DeclareHandle_"
-void DifferentTypeError(const int VarType,LONG_PTR VarIndex,const int CalcType,LONG_PTR CalcIndex,const int iWarning,const char *pszFuncName,const int ParmNum){
+void DifferentTypeError( const Type &varType, const Type &calcFormalType, const int iWarning,const char *pszFuncName,const int ParmNum){
 	//////////////////////////
 	// キャストに関する警告
 	//////////////////////////
-	char temporary[255],temp2[255],temp3[255];
-
-	if(IS_LITERAL(CalcIndex)) CalcIndex=-1;
+	char temporary[255];
+	Type calcType( calcFormalType );
+
+	if(IS_LITERAL(calcType.GetIndex()))
+	{
+		calcType.SetIndex( -1 );
+	}
 
 	if(pszFuncName)
@@ -400,17 +404,16 @@
 	else temporary[0]=0;
 
-	if(!GetTypeName(VarType,VarIndex,temp2)) lstrcpy(temp2,"Any");
-	if(memcmp(temp2,STRING_SYSTEM_DECLAREHANDLE,lstrlen(STRING_SYSTEM_DECLAREHANDLE))==0){
-		memmove(temp2,
-			temp2+lstrlen(STRING_SYSTEM_DECLAREHANDLE),
-			lstrlen(temp2+lstrlen(STRING_SYSTEM_DECLAREHANDLE))+1);
-	}
-	if(!GetTypeName(CalcType,CalcIndex,temp3)) lstrcpy(temp3,"Any");
-	if(memcmp(temp3,STRING_SYSTEM_DECLAREHANDLE,lstrlen(STRING_SYSTEM_DECLAREHANDLE))==0){
-		memmove(temp3,
-			temp3+lstrlen(STRING_SYSTEM_DECLAREHANDLE),
-			lstrlen(temp3+lstrlen(STRING_SYSTEM_DECLAREHANDLE))+1);
-	}
-	sprintf(temporary+lstrlen(temporary),"%sから%s",temp3,temp2);
+	std::string varTypeName = Compiler::TypeToString( varType );
+	if(memcmp( varTypeName.c_str(),STRING_SYSTEM_DECLAREHANDLE,lstrlen(STRING_SYSTEM_DECLAREHANDLE))==0)
+	{
+		varTypeName = varTypeName.substr( lstrlen(STRING_SYSTEM_DECLAREHANDLE) );
+	}
+
+	std::string calcTypeName = Compiler::TypeToString( calcType );
+	if(memcmp( calcTypeName.c_str(),STRING_SYSTEM_DECLAREHANDLE,lstrlen(STRING_SYSTEM_DECLAREHANDLE))==0)
+	{
+		calcTypeName = calcTypeName.substr( lstrlen(STRING_SYSTEM_DECLAREHANDLE) );
+	}
+	sprintf(temporary+lstrlen(temporary),"%sから%s",calcTypeName.c_str(),varTypeName.c_str());
 
 	extern int cp;
@@ -420,25 +423,31 @@
 }
 
-bool CheckDifferentType(const int VarType,const LONG_PTR lpVarIndex,int CalcType,const LONG_PTR lpCalcIndex,const char *pszFuncName,const int ParmNum){
-
-	if(VarType==DEF_STRUCT||CalcType==DEF_STRUCT){
+bool CheckDifferentType( const Type &varType,const Type &calcFormalType,const char *pszFuncName,const int ParmNum)
+{
+	Type calcType( calcFormalType );
+
+	if( varType.IsStruct() || calcType.IsStruct() )
+	{
 		//いずれかが構造体場合
-		if( VarType != CalcType || lpVarIndex != lpCalcIndex ){
-			DifferentTypeError(VarType,lpVarIndex,CalcType,lpCalcIndex,3,pszFuncName,ParmNum);
+		if( !varType.Equals( calcType ) )
+		{
+			DifferentTypeError( varType, calcType,3,pszFuncName,ParmNum);
 			return false;
 		}
 	}
 
-	if(VarType==DEF_OBJECT||CalcType==DEF_OBJECT){
-		//いずれかがオブジェクトインスタンスの場合
-		if( VarType != CalcType ){
-			DifferentTypeError(VarType,lpVarIndex,CalcType,lpCalcIndex,3,pszFuncName,ParmNum);
+	if( varType.IsObject() || calcType.IsObject() )
+	{
+		//いずれかがオブジェクトの場合
+		if( varType.GetBasicType() != calcType.GetBasicType() )
+		{
+			DifferentTypeError( varType, calcType,3,pszFuncName,ParmNum);
 			return false;
 		}
 
-		CClass *pClass = (CClass *)lpVarIndex;
-		if( !pClass->IsEqualsOrSubClass( (CClass *)lpCalcIndex ) ){
+		if( !varType.GetClass().IsEqualsOrSubClass( &calcType.GetClass() ) )
+		{
 			//等しくなく、派生クラスでもないとき
-			DifferentTypeError(VarType,lpVarIndex,CalcType,lpCalcIndex,3,pszFuncName,ParmNum);
+			DifferentTypeError( varType, calcType,3,pszFuncName,ParmNum);
 			return false;
 		}
@@ -449,48 +458,62 @@
 	if(bStrict==0) return true;
 
-	if(CalcType&FLAG_PTR){
+	if( calcType.GetBasicType() & FLAG_PTR )
+	{
 		//配列先頭フラグがたっている場合は、ポインタ型として扱う
-		CalcType=MAKE_PTR_TYPE(NATURAL_TYPE(CalcType),PTR_LEVEL(CalcType)+1);
-	}
-
-	if(IsPtrType(VarType)||IsPtrType(CalcType)){
+		calcType.SetBasicType( MAKE_PTR_TYPE(NATURAL_TYPE(calcType.GetBasicType()),PTR_LEVEL(calcType.GetBasicType())+1) );
+	}
+
+	if( varType.IsPointer() || calcType.IsPointer() )
+	{
 		/* 右辺及び左辺のいずれかがポインタ型の場合は、
 			型チェックを行う。
 		・同一の種類のポインタ型以外はエラーとする */
 
-		if(IsPtrType(VarType)&&lpCalcIndex==LITERAL_NULL){
+		if( varType.IsPointer() && calcType.GetIndex() == LITERAL_NULL )
+		{
 			//リテラルNULL値の場合
 			return true;
 		}
 
-		if(VarType==DEF_PTR_VOID){
+		if( varType.IsVoidPtr() )
+		{
 			//左辺がVoidPtr型の場合は、ポインタ型すべてを受け入れる
-			if(IsPtrType(CalcType)) return true;
-		}
-
-		if(CalcType==DEF_PTR_VOID){
+			if( calcType.IsPointer() )
+			{
+				return true;
+			}
+		}
+
+		if( calcType.IsVoidPtr() )
+		{
 			//右辺がVoidPtr型の場合は、ポインタ型すべてを受け入れる
-			if(IsPtrType(VarType)) return true;
-		}
-
-		if(VarType!=CalcType){
-			DifferentTypeError(VarType,lpVarIndex,CalcType,lpCalcIndex,2,pszFuncName,ParmNum);
+			if( varType.IsPointer() )
+			{
+				return true;
+			}
+		}
+
+		if( varType.GetBasicType() != calcType.GetBasicType() )
+		{
+			DifferentTypeError( varType, calcType, 2,pszFuncName,ParmNum);
 			return true;
 		}
 
-		if(VarType==DEF_PTR_OBJECT){
+		if( varType.IsObjectPtr() )
+		{
 			//双方がオブジェクトポインタ型の場合
-			if(lpVarIndex!=lpCalcIndex){
-				const CClass *pobj_tempClass;
-				pobj_tempClass=(CClass *)lpCalcIndex;
+			if( varType.GetIndex() != calcType.GetIndex() )
+			{
+				const CClass *pobj_tempClass = &calcType.GetClass();
 				while(pobj_tempClass&&(!IS_LITERAL((LONG_PTR)pobj_tempClass))){
 					pobj_tempClass=&pobj_tempClass->GetSuperClass();
 
-					if(lpVarIndex==(LONG_PTR)pobj_tempClass){
+					if( &varType.GetClass() == pobj_tempClass )
+					{
 						//継承先が等しいとき
 						return true;
 					}
 				}
-				DifferentTypeError(VarType,lpVarIndex,CalcType,lpCalcIndex,2,pszFuncName,ParmNum);
+				DifferentTypeError( varType, calcType, 2,pszFuncName,ParmNum);
 				return true;
 			}
@@ -498,51 +521,60 @@
 	}
 
-	if(VarType==DEF_DOUBLE){
-		if(Is64Type(CalcType)){
+	if( varType.IsDouble() )
+	{
+		if( calcType.Is64() )
+		{
 			//64ビット整数値の場合は警告を出す
-			DifferentTypeError(VarType,lpVarIndex,CalcType,lpCalcIndex,1,pszFuncName,ParmNum);
-		}
-	}
-	else if(VarType==DEF_SINGLE){
-		if(Is64Type(CalcType)||CalcType==DEF_DOUBLE){
+			DifferentTypeError( varType, calcType, 1,pszFuncName,ParmNum);
+		}
+	}
+	else if( varType.IsSingle() )
+	{
+		if( calcType.Is64() || calcType.IsDouble() )
+		{
 			//64ビット整数値、またはDouble型の場合は警告を出す
-			DifferentTypeError(VarType,lpVarIndex,CalcType,lpCalcIndex,1,pszFuncName,ParmNum);
-		}
-	}
-	else if(GetTypeSize(VarType,lpVarIndex)==sizeof(char)){
-		if(GetTypeSize(CalcType,lpCalcIndex)>sizeof(char)&&
-			lpCalcIndex!=LITERAL_NULL&&
-			lpCalcIndex!=LITERAL_M128_0&&
-			lpCalcIndex!=LITERAL_0_255){
+			DifferentTypeError( varType, calcType, 1,pszFuncName,ParmNum);
+		}
+	}
+	else if( varType.GetSize() == sizeof(char) )
+	{
+		if( calcType.GetSize() > sizeof(char)
+			&& calcType.GetIndex() != LITERAL_NULL
+			&& calcType.GetIndex() != LITERAL_M128_0
+			&& calcType.GetIndex() != LITERAL_0_255 )
+		{
 			//8ビット整数値より大きな型で、リテラル値でもない場合は警告を出す
-			DifferentTypeError(VarType,lpVarIndex,CalcType,lpCalcIndex,1,pszFuncName,ParmNum);
-		}
-	}
-	else if(GetTypeSize(VarType,lpVarIndex)==sizeof(short)){
-		if(GetTypeSize(CalcType,lpCalcIndex)>sizeof(short)&&
-			lpCalcIndex!=LITERAL_NULL&&
-			lpCalcIndex!=LITERAL_M128_0&&
-			lpCalcIndex!=LITERAL_0_255&&
-			lpCalcIndex!=LITERAL_M32768_0&&
-			lpCalcIndex!=LITERAL_0_65535){
+			DifferentTypeError( varType, calcType, 1,pszFuncName,ParmNum);
+		}
+	}
+	else if( varType.GetSize() == sizeof(short) )
+	{
+		if( calcType.GetSize() > sizeof(short)
+			&& calcType.GetIndex() != LITERAL_NULL
+			&& calcType.GetIndex() != LITERAL_M128_0
+			&& calcType.GetIndex() != LITERAL_0_255
+			&& calcType.GetIndex() != LITERAL_M32768_0
+			&& calcType.GetIndex() != LITERAL_0_65535 )
+		{
 			//16ビット整数値より大きな型で、リテラル値でもない場合は警告を出す
-			DifferentTypeError(VarType,lpVarIndex,CalcType,lpCalcIndex,1,pszFuncName,ParmNum);
-		}
-	}
-	else if(GetTypeSize(VarType,lpVarIndex)==sizeof(long)){
-		if(IsRealNumberType(CalcType)||
-			(IsWholeNumberType(CalcType)&&
-			GetTypeSize(CalcType,lpCalcIndex)>sizeof(long)&&
-			lpCalcIndex!=LITERAL_NULL)
-			){
+			DifferentTypeError( varType, calcType, 1,pszFuncName,ParmNum);
+		}
+	}
+	else if( varType.GetSize() == sizeof(long) )
+	{
+		if( calcType.IsReal()
+			|| ( calcType.IsWhole() && calcType.GetSize() > sizeof(long) && calcType.GetIndex() != LITERAL_NULL ) )
+		{
 			/* 32ビット整数値より大きな型、または実数、
 					またはリテラル値でもない場合は警告を出す */
-			DifferentTypeError(VarType,lpVarIndex,CalcType,lpCalcIndex,1,pszFuncName,ParmNum);
-		}
-	}
-	else if(GetTypeSize(VarType,lpVarIndex)==sizeof(_int64)){
-		if(IsRealNumberType(CalcType)){
+			DifferentTypeError( varType, calcType, 1,pszFuncName,ParmNum);
+		}
+	}
+	else if( varType.GetSize() == sizeof(_int64) )
+	{
+		if( calcType.IsReal() )
+		{
 			//実数の場合は警告を出す
-			DifferentTypeError(VarType,lpVarIndex,CalcType,lpCalcIndex,1,pszFuncName,ParmNum);
+			DifferentTypeError( varType, calcType, 1,pszFuncName,ParmNum);
 		}
 	}
@@ -550,11 +582,2 @@
 	return true;
 }
-bool CheckDifferentType( const Type &varType,const Type &calcType,const char *pszFuncName,const int ParmNum){
-	return CheckDifferentType(
-		varType.GetBasicType(),
-		varType.GetIndex(),
-		calcType.GetBasicType(),
-		calcType.GetIndex(),
-		pszFuncName,
-		ParmNum );
-}
