Index: BasicCompiler_Common/calculation.cpp
===================================================================
--- BasicCompiler_Common/calculation.cpp	(revision 73)
+++ BasicCompiler_Common/calculation.cpp	(revision 75)
@@ -390,6 +390,5 @@
 }
 
-int StaticCalculation(bool enableerror, const char *Command,int BaseType,_int64 *pi64data,LONG_PTR *plpIndex,BOOL bDebuggingWatchList){
-	extern HANDLE hHeap;
+bool StaticCalculation(bool enableerror, const char *Command,int BaseType,_int64 *pi64data,Type &resultType,BOOL bDebuggingWatchList, bool *pIsMemoryAccessError){
 	extern int cp;
 	int i,i2,i3,PareNum;
@@ -406,6 +405,8 @@
 	int sp,pnum;
 
+	if( pIsMemoryAccessError ) *pIsMemoryAccessError = false;
+
 	*pi64data=0;
-	if(Command[0]=='\0') return 0;
+	if(Command[0]=='\0') return false;
 
 	for(i=0,i2=0,sp=0,pnum=0,PareNum=0;;i++,i2++){
@@ -487,5 +488,5 @@
 							extern int cp;
 							if(enableerror) SetError(3,temp2,cp);
-							return 0;
+							return false;
 						}
 						i64nums[pnum]=GetTypeSize(i3,lpIndex);
@@ -497,10 +498,13 @@
 						if(!GetConstCalcBuffer(temporary,temp2,Parms)){
 							if(enableerror) SetError(3,temporary,cp);
-							return 0;
+							return false;
 						}
 
-						type[pnum]=StaticCalculation(true, Parms,BaseType,&i64data,&before_index[pnum]);
-						if(IsRealNumberType(type[pnum])){
-							//整数型
+						Type tempType;
+						StaticCalculation(true, Parms,BaseType,&i64data,tempType);
+						type[pnum] = tempType.GetBasicType();
+						before_index[pnum] = tempType.GetIndex();
+						if(tempType.IsReal()){
+							//実数型
 							memcpy(&nums[pnum],&i64data,sizeof(double));
 						}
@@ -548,5 +552,4 @@
 
 							RELATIVE_VAR RelativeVar;
-							LONG_PTR lpIndex;
 							int ss[MAX_ARRAYDIM];
 							void *offset;
@@ -557,12 +560,14 @@
 							extern HANDLE hDebugProcess;
 
-							i3=Debugging_GetVarOffset(Parms,&i2,&RelativeVar,&lpIndex,ss);
+							Type tempType;
+							i3=Debugging_GetVarOffset(Parms,&RelativeVar,tempType,ss);
 							if(i3==0){
 								//式エラー
-								return 0;
+								return false;
 							}
 							if(i3==-1){
 								//メモリにアクセスできないとき
-								return -1;
+								if( pIsMemoryAccessError ) *pIsMemoryAccessError = true;
+								return false;
 							}
 
@@ -571,15 +576,15 @@
 								offset=(void *)Debugging_GetVarPtr(&RelativeVar);
 
-								type[pnum]=i2;
-
-								if(i2==DEF_DOUBLE){
+								type[pnum]=tempType.GetBasicType();
+
+								if(tempType.IsDouble()){
 									i3=ReadProcessMemory(hDebugProcess,offset,&nums[pnum],sizeof(double),&stAccBytes);
 								}
-								else if(i2==DEF_SINGLE){
+								else if(tempType.IsSingle()){
 									if(i3=ReadProcessMemory(hDebugProcess,offset,&flt,sizeof(float),&stAccBytes)){
 										nums[pnum]=(double)flt;
 									}
 								}
-								else if(IsPtrType(i2)){
+								else if(tempType.IsPointer()){
 									LONG_PTR lpData;
 									if(i3=ReadProcessMemory(hDebugProcess,offset,&lpData,sizeof(LONG_PTR),&stAccBytes)){
@@ -587,5 +592,5 @@
 									}
 								}
-								else if(Is64Type(i2)){
+								else if(tempType.Is64()){
 									type[pnum]=DEF_INT64;
 
@@ -593,5 +598,5 @@
 								}
 
-								else if(i2==DEF_LONG){
+								else if(tempType.IsLong()){
 									long lData;
 									if(i3=ReadProcessMemory(hDebugProcess,offset,&lData,sizeof(long),&stAccBytes)){
@@ -599,10 +604,10 @@
 									}
 								}
-								else if(i2==DEF_DWORD){
+								else if(tempType.IsDWord()){
 									if(i3=ReadProcessMemory(hDebugProcess,offset,&dwData,sizeof(DWORD),&stAccBytes)){
 										i64nums[pnum]=(_int64)dwData;
 									}
 								}
-								else if(i2==DEF_INTEGER || (isUnicode&&i2==DEF_CHAR)){
+								else if(tempType.IsInteger()){
 									short shortData;
 									if(i3=ReadProcessMemory(hDebugProcess,offset,&shortData,sizeof(short),&stAccBytes)){
@@ -610,5 +615,5 @@
 									}
 								}
-								else if(i2==DEF_WORD){
+								else if(tempType.IsWord()){
 									WORD wData;
 									if(i3=ReadProcessMemory(hDebugProcess,offset,&wData,sizeof(WORD),&stAccBytes)){
@@ -616,5 +621,5 @@
 									}
 								}
-								else if(i2==DEF_SBYTE || (isUnicode==false&&i2==DEF_CHAR)){
+								else if(tempType.IsSByte()){
 									char charData;
 									if(i3=ReadProcessMemory(hDebugProcess,offset,&charData,sizeof(char),&stAccBytes)){
@@ -622,5 +627,5 @@
 									}
 								}
-								else if(i2==DEF_BYTE){
+								else if(tempType.IsByte()){
 									BYTE byteData;
 									if(i3=ReadProcessMemory(hDebugProcess,offset,&byteData,sizeof(BYTE),&stAccBytes)){
@@ -628,5 +633,5 @@
 									}
 								}
-								else if(i2==DEF_BOOLEAN){
+								else if(tempType.IsBoolean()){
 									BYTE byteData;
 									if(i3=ReadProcessMemory(hDebugProcess,offset,&byteData,sizeof(BYTE),&stAccBytes)){
@@ -634,9 +639,10 @@
 									}
 								}
-								else return 0;
+								else return false;
 
 								if(!i3){
 									//読み込みに失敗
-									return -1;
+									if( pIsMemoryAccessError ) *pIsMemoryAccessError = true;
+									return false;
 								}
 								goto JumpConst;
@@ -672,5 +678,5 @@
 								//エラー
 								if(enableerror) SetError(300,NULL,cp);
-								return -1;
+								return 0;
 							}
 							goto JumpConst;
@@ -685,8 +691,11 @@
 
 						if(type[pnum]==-1){
-							if(bDebuggingWatchList) return -1;
+							if(bDebuggingWatchList){
+								if( pIsMemoryAccessError ) *pIsMemoryAccessError = true;
+								return false;
+							}
 							//エラー
 							if(enableerror) SetError(3,Parms,cp);
-							return 0;
+							return false;
 						}
 JumpConst:;
@@ -713,5 +722,5 @@
 				if(!(Command[i]=='+'||Command[i]=='-'||(Command[i]==1&&Command[i+1]==ESC_NOT))){
 					if(enableerror) SetError(1,NULL,cp);
-					return 0;
+					return false;
 				}
 				if(Command[i]=='+'){
@@ -898,6 +907,6 @@
 		//文字列ポインタ
 		*pi64data=(_int64)stack[0];
-		*plpIndex=index_stack[0];
-		return type_stack[0];
+		resultType.SetType( type_stack[0], index_stack[0] );
+		return true;
 	}
 
@@ -905,5 +914,6 @@
 		//実数
 		memcpy(pi64data,&dbl_stack[0],sizeof(double));
-		return type_stack[0];
+		resultType.SetType( type_stack[0], index_stack[0] );
+		return true;
 	}
 
@@ -911,17 +921,18 @@
 	*pi64data=i64stack[0];
 
-	if(plpIndex){
-		*plpIndex=index_stack[0];
-		if(*plpIndex==-1){
-			if(Is64Type(type_stack[0])==0&&IsRealNumberType(type_stack[0])==0){
-				//整数（符号有り/無し）
-				i64data=*pi64data;
-
-				*plpIndex=GetLiteralIndex(i64data);
-			}
-		}
-	}
-
-	return type_stack[0];
+	if(index_stack[0]==-1){
+		if(Is64Type(type_stack[0])==0&&IsRealNumberType(type_stack[0])==0){
+			//整数（符号有り/無し）
+			i64data=*pi64data;
+
+			resultType.SetIndex( GetLiteralIndex(i64data) );
+		}
+	}
+	else{
+		resultType.SetIndex( index_stack[0] );
+	}
+
+	resultType.SetBasicType( type_stack[0] );
+	return true;
 }
 
@@ -1187,14 +1198,6 @@
 	return -1;
 }
-bool IsStringObjectType(const TYPEINFO &TypeInfo){
-	if(TypeInfo.type==DEF_OBJECT){
-		if(lstrcmp(TypeInfo.u.pobj_Class->name,"String")==0){
-			return 1;
-		}
-	}
-	return 0;
-}
 int IsStrCalculation(char *Command){
-	int i,i2,i3,i4,type,PareNum;
+	int i,i2,i3,i4,PareNum;
 	char temporary[VN_SIZE],temp2[8192];
 
@@ -1245,23 +1248,22 @@
 				}
 				if(Command[i2+i3]=='('){
-					TYPEINFO TypeInfo;
 
 					//DLL関数の場合
-					DECLAREINFO *pdi;
-					pdi=GetDeclareHash(temporary);
-					if(pdi){
-						TypeInfo.type=pdi->ReturnType;
-						TypeInfo.u.lpIndex=pdi->u.ReturnIndex;
-						if(IsStringObjectType( TypeInfo )) return 1;
+					DllProc *pDllProc;
+					pDllProc=GetDeclareHash(temporary);
+					if(pDllProc){
+						if( pDllProc->ReturnType().IsStringObject() ){
+							return 1;
+						}
 						return 0;
 					}
 
 					//ユーザー定義関数
-					SubInfo *psi;
-					psi=GetSubHash(temporary);
-					if(psi){
-						TypeInfo.type=psi->ReturnType;
-						TypeInfo.u.lpIndex=psi->u.ReturnIndex;
-						if(IsStringObjectType(TypeInfo)) return 1;
+					UserProc *pUserProc;
+					pUserProc=GetSubHash(temporary);
+					if(pUserProc){
+						if( pUserProc->ReturnType().IsStringObject() ){
+							return 1;
+						}
 						return 0;
 					}
@@ -1297,15 +1299,11 @@
 
 				//変数
-				CClass *pobj_Class;
-				type = GetVarType(Command+i2,(LONG_PTR *)&pobj_Class,1);
-				if(type==-1 || type ==0){
+				Type varType;
+				if( !GetVarType(Command+i2,varType,1) ){
 					//エラー
 					return -1;
 				}
-				if(type==DEF_OBJECT){
-					if(lstrcmp(pobj_Class->name,"String")==0){
-						return 1;
-					}
-					return 0;
+				if( varType.IsStringObject() ){
+					return 1;
 				}
 			}
