Index: BasicCompiler32/Compile_Func.cpp
===================================================================
--- BasicCompiler32/Compile_Func.cpp	(revision 75)
+++ BasicCompiler32/Compile_Func.cpp	(revision 76)
@@ -44,10 +44,11 @@
 }
 
-void Opcode_Func_Fix(const char *Parameter){
-	int i;
-
-	i=NumOpe(Parameter,0,0,0);
-
-	if(i==DEF_DOUBLE){
+void Opcode_Func_Fix(const char *lpszParms){
+	Type resultType;
+	if( !NumOpe( lpszParms, Type(), resultType ) ){
+		return;
+	}
+
+	if( resultType.IsDouble() ){
 		//fld qword ptr[esp]
 		op_fld_ptr_esp(DEF_DOUBLE);
@@ -96,5 +97,5 @@
 		op_add_esp(4);
 	}
-	else if(i==DEF_SINGLE){
+	else if( resultType.IsSingle() ){
 		//fld dword ptr[esp]
 		op_fld_ptr_esp(DEF_SINGLE);
@@ -146,5 +147,5 @@
 		op_add_esp(4);
 	}
-	else if(Is64Type(i)){
+	else if( resultType.Is64() ){
 		//pop eax
 		op_pop(REG_EAX);
@@ -162,8 +163,9 @@
 
 void Opcode_Func_CUDbl(const char *Parameter){
-	int i;
-
-	i=NumOpe(Parameter,0,0,0);
-	ChangeTypeToLong(i);
+	Type resultType;
+	if( !NumOpe(Parameter,Type(),resultType) ){
+		return;
+	}
+	ChangeTypeToLong(resultType.GetBasicType());
 
 	//pop eax
@@ -186,14 +188,11 @@
 }
 void Opcode_Func_Len(const char *Parameter){
-	int type,TypeSize;
-	LONG_PTR lpIndex;
 	BOOL bArrayHead;
-
-	type=GetVarType(Parameter,&lpIndex,0);
 
 	const char *tempParm=Parameter;
 	char temporary[VN_SIZE];
 	char temp2[32];
-	if(type==-1){
+	Type type;
+	if( !GetVarType(Parameter,type,0) ){
 		sprintf(temporary,"_System_DummyStr2=%s",Parameter);
 		OpcodeCalc(temporary);
@@ -203,15 +202,13 @@
 
 		extern CClass *pobj_StringClass;
-		type=DEF_OBJECT;
-		lpIndex=(LONG_PTR)pobj_StringClass;
-	}
-
-	Type TypeInfo={type,lpIndex};
-	if(IsStringObjectType(TypeInfo)){
+		type.SetType( DEF_OBJECT, pobj_StringClass );
+	}
+
+	if( type.IsStringObject() ){
 		//Stringオブジェクトの場合
-		char temporary[VN_SIZE];
 		sprintf(temporary,"%s.Length",tempParm);
 
-		NumOpe(temporary,0,0,NULL,NULL);
+		int reg=REG_RAX;
+		NumOpe(temporary,Type(),Type());
 
 		//pop eax
@@ -223,8 +220,8 @@
 	int SubScripts[MAX_ARRAYDIM];
 	RELATIVE_VAR RelativeVar;
-	if(!GetVarOffsetReadOnly(tempParm,&type,&RelativeVar,&lpIndex,SubScripts)) return;
-
-	if(type&FLAG_PTR){
-		type&=~FLAG_PTR;
+	if(!GetVarOffsetReadOnly(tempParm,&RelativeVar,type,SubScripts)) return;
+
+	if(type.GetBasicType()&FLAG_PTR){
+		type.SetBasicType( type.GetBasicType() & ( ~FLAG_PTR ) );
 
 		bArrayHead=1;
@@ -232,14 +229,14 @@
 	else bArrayHead=0;
 
-	TypeSize=GetTypeSize(type,lpIndex);
-
-	if(bArrayHead) TypeSize*=JumpSubScripts(SubScripts);
+	int typeSize = type.GetSize();
+
+	if(bArrayHead) typeSize*=JumpSubScripts(SubScripts);
 
 	//mov eax,TypeSize
 	OpBuffer[obp++]=(char)0xB8;
-	*((long *)(OpBuffer+obp))=TypeSize;
+	*((long *)(OpBuffer+obp))=typeSize;
 	obp+=sizeof(long);
 }
-void Opcode_Func_AddressOf(const char *name){
+void Opcode_Func_AddressOf( const char *name ){
 	extern int cp;
 	UserProc *pUserProc;
@@ -257,6 +254,6 @@
 
 		//オーバーロードを解決
-		extern ProcPointer **ppProcPtrInfo;
-		pUserProc=OverloadSolution(name,subs,ppProcPtrInfo[ProcPtr_BaseIndex]->Params(), Type() );
+		extern ProcPointer **ppProcPointer;
+		pUserProc=OverloadSolution(name,subs,ppProcPointer[ProcPtr_BaseIndex]->Params(), Type() );
 
 		if(!pUserProc){
@@ -289,6 +286,6 @@
 			else{
 				RELATIVE_VAR RelativeVar;
-				int type;
-				if(!GetVarOffsetReadOnly(ObjectName,&type,&RelativeVar,(LONG_PTR *)&pobj_c)) return;
+				Type type;
+				if(!GetVarOffsetReadOnly(ObjectName,&RelativeVar,type)) return;
 				SetVarPtrToEax(&RelativeVar);
 
@@ -297,7 +294,7 @@
 
 				//参照タイプが整合しているかをチェック
-				if(type!=RefType) SetError(104,ObjectName,cp);
-
-				if(type==DEF_PTR_OBJECT){
+				if(type.GetBasicType()!=RefType) SetError(104,ObjectName,cp);
+
+				if(type.IsObjectPtr()){
 					//mov ecx,dword ptr[ecx]
 					op_mov_RM(sizeof(long),REG_ECX,REG_ECX,0,MOD_BASE);
@@ -360,13 +357,24 @@
 	op_mov_RV( REG_EAX, size );
 }
-void Opcode_Func_VarPtr( const char *Parameter, Type &ReturnTypeInfo ){
+void Opcode_Func_VarPtr( const char *Parameter, Type &resultType, bool isCallOn ){
+	if( isCallOn == false ){
+		// 戻り値の型を取得するだけ
+
+		//変数のアドレスを取得
+		if(!GetVarType( Parameter, resultType, true )) return;
+
+		resultType.PtrLevelUp();
+
+		return;
+	}
+
 	RELATIVE_VAR RelativeVar;
 
 	//変数のアドレスを取得
-	if(!GetVarOffsetReadOnly( Parameter, &ReturnTypeInfo.type, &RelativeVar, &ReturnTypeInfo.u.lpIndex )) return;
-
-	int beforeType = ReturnTypeInfo.type;
-
-	PTR_LEVEL_UP( ReturnTypeInfo.type );
+	if(!GetVarOffsetReadOnly( Parameter, &RelativeVar, resultType )) return;
+
+	int beforeType = resultType.GetBasicType();
+
+	resultType.PtrLevelUp();
 
 	SetVarPtrToEax(&RelativeVar);
@@ -380,8 +388,13 @@
 }
 void Opcode_Func_GetPtrData(const char *Parameter,const int type){
-	int i2;
-
-	i2=NumOpe(Parameter,0,0,0);
-	ChangeTypeToLong(i2);
+	Type tempType;
+	if( !NumOpe(Parameter,Type(),tempType) ){
+		return;
+	}
+	if(!tempType.IsWhole()){
+		SetError(11,Parameter,cp);
+		return;
+	}
+	ChangeTypeToLong(tempType.GetBasicType());
 
 	if(type==DEF_DOUBLE){
@@ -438,54 +451,57 @@
 }
 
-void Opcode_CallFunc( const char *Parameter, const int FuncNum, Type &ReturnTypeInfo ){
+bool Opcode_CallFunc( const char *Parameter, const int FuncNum, Type &resultType, bool isCallOn ){
 	switch(FuncNum){
 		case FUNC_FIX:
-			Opcode_Func_Fix(Parameter);
-			ReturnTypeInfo.type = DEF_LONG;
+			if( isCallOn ) Opcode_Func_Fix(Parameter);
+			resultType.SetBasicType( DEF_LONG );
 			break;
 		case FUNC_CUDBL:
-			Opcode_Func_CUDbl(Parameter);
-			ReturnTypeInfo.type = DEF_DOUBLE;
+			if( isCallOn ) Opcode_Func_CUDbl(Parameter);
+			resultType.SetBasicType( DEF_DOUBLE );
 			break;
 		case FUNC_LEN:
-			Opcode_Func_Len(Parameter);
-			ReturnTypeInfo.type = DEF_LONG;
+			if( isCallOn ) Opcode_Func_Len(Parameter);
+			resultType.SetBasicType( DEF_LONG );
 			break;
 		case FUNC_ADDRESSOF:
-			Opcode_Func_AddressOf(Parameter);
-			ReturnTypeInfo.type = DEF_PTR_VOID;
+			if( isCallOn ) Opcode_Func_AddressOf(Parameter);
+			resultType.SetBasicType( DEF_PTR_VOID );
 			break;
 		case FUNC_SIZEOF:
-			Opcode_Func_SizeOf(Parameter);
-			ReturnTypeInfo.type = DEF_LONG;
+			if( isCallOn ) Opcode_Func_SizeOf(Parameter);
+			resultType.SetBasicType( DEF_LONG );
 			break;
 		case FUNC_VARPTR:
-			Opcode_Func_VarPtr( Parameter, ReturnTypeInfo );
+			Opcode_Func_VarPtr( Parameter, resultType, isCallOn );
 			break;
 
 		case FUNC_GETDOUBLE:
-			Opcode_Func_GetPtrData(Parameter,DEF_DOUBLE);
-			ReturnTypeInfo.type = DEF_DOUBLE;
+			if( isCallOn ) Opcode_Func_GetPtrData(Parameter,DEF_DOUBLE);
+			resultType.SetBasicType( DEF_DOUBLE );
 			break;
 		case FUNC_GETSINGLE:
-			Opcode_Func_GetPtrData(Parameter,DEF_SINGLE);
-			ReturnTypeInfo.type = DEF_SINGLE;
+			if( isCallOn ) Opcode_Func_GetPtrData(Parameter,DEF_SINGLE);
+			resultType.SetBasicType( DEF_SINGLE );
 			break;
 		case FUNC_GETQWORD:
-			Opcode_Func_GetPtrData(Parameter,DEF_QWORD);
-			ReturnTypeInfo.type = DEF_QWORD;
+			if( isCallOn ) Opcode_Func_GetPtrData(Parameter,DEF_QWORD);
+			resultType.SetBasicType( DEF_QWORD );
 			break;
 		case FUNC_GETDWORD:
-			Opcode_Func_GetPtrData(Parameter,DEF_DWORD);
-			ReturnTypeInfo.type = DEF_DWORD;
+			if( isCallOn ) Opcode_Func_GetPtrData(Parameter,DEF_DWORD);
+			resultType.SetBasicType( DEF_DWORD );
 			break;
 		case FUNC_GETWORD:
-			Opcode_Func_GetPtrData(Parameter,DEF_WORD);
-			ReturnTypeInfo.type = DEF_WORD;
+			if( isCallOn ) Opcode_Func_GetPtrData(Parameter,DEF_WORD);
+			resultType.SetBasicType( DEF_WORD );
 			break;
 		case FUNC_GETBYTE:
-			Opcode_Func_GetPtrData(Parameter,DEF_BYTE);
-			ReturnTypeInfo.type = DEF_BYTE;
-			break;
-	}
-}
+			if( isCallOn ) Opcode_Func_GetPtrData(Parameter,DEF_BYTE);
+			resultType.SetBasicType( DEF_BYTE );
+			break;
+		default:
+			return false;
+	}
+	return true;
+}
