Index: trunk/abdev/BasicCompiler64/NumOpe.cpp
===================================================================
--- trunk/abdev/BasicCompiler64/NumOpe.cpp	(revision 430)
+++ trunk/abdev/BasicCompiler64/NumOpe.cpp	(revision 436)
@@ -130,5 +130,5 @@
 	return true;
 }
-bool TermMemberOpe( const Type &leftType, const Type &baseType, Type &resultType, const char *termFull, const char *termLeft, const char *member, bool &isVariable, RELATIVE_VAR &relativeVar )
+bool TermMemberOpe( const Type &leftType, bool &isNeedHeapFreeStructure, const Type &baseType, Type &resultType, const char *termFull, const char *termLeft, const char *member, bool &isVariable, RELATIVE_VAR &relativeVar )
 {
 	const CClass &objClass = leftType.GetClass();
@@ -218,4 +218,20 @@
 		// メンバが見つかったとき
 
+		if( isNeedHeapFreeStructure )
+		{
+			if( !leftType.IsStruct() )
+			{
+				SetError();
+			}
+
+			pobj_reg->LockReg();
+
+			// 親となる構造体が一時メモリに存在していた場合、後ほど解放する必要がある
+			compiler.codeGenerator.op_AddNeedFreeTempStructure( useReg );
+			isNeedHeapFreeStructure = false;
+
+			pobj_reg->UnlockReg();
+		}
+
 		//オブジェクトポインタをr11にコピー
 		compiler.codeGenerator.op_mov_RR( REG_R11, useReg );
@@ -267,5 +283,5 @@
 				bool dummyIsVariable;
 				RELATIVE_VAR dummyRelativeVar;
-				TermMemberOpe( leftType, baseType, resultType, termFull, termLeft, methodName, dummyIsVariable, dummyRelativeVar );
+				TermMemberOpe( leftType, isNeedHeapFreeStructure, baseType, resultType, termFull, termLeft, methodName, dummyIsVariable, dummyRelativeVar );
 
 				// 戻り値のオブジェクトインスタンスのインデクサを呼び出す
@@ -274,5 +290,5 @@
 				sprintf( temp2, "%s.%s", termLeft, methodName );
 				Type classType = resultType;
-				return TermMemberOpe( classType, baseType, resultType, termFull, temp2, temporary, isVariable, relativeVar );
+				return TermMemberOpe( classType, isNeedHeapFreeStructure, baseType, resultType, termFull, temp2, temporary, isVariable, relativeVar );
 			}
 
@@ -344,5 +360,5 @@
 	return false;
 }
-bool _TermOpe( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, BOOL *pbUseHeap, bool *pIsClassName, bool isProcedureCallOnly, bool &isVariable, RELATIVE_VAR &relativeVar, bool isWriteAccess )
+bool _TermOpe( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, bool &isNeedHeapFreeStructure, bool *pIsClassName, bool isProcedureCallOnly, bool &isVariable, RELATIVE_VAR &relativeVar, bool isWriteAccess )
 {
 	char parameter[VN_SIZE];
@@ -385,5 +401,5 @@
 		}
 
-		if( !TermOpe( termLeft, baseType, leftType, isLiteral, pbUseHeap, &isClassName ) ){
+		if( !TermOpe( termLeft, baseType, leftType, isLiteral, isNeedHeapFreeStructure, &isClassName ) ){
 			goto globalArea;
 		}
@@ -403,5 +419,5 @@
 		}
 
-		return TermMemberOpe( leftType, baseType, resultType, termFull, termLeft, member, isVariable, relativeVar );
+		return TermMemberOpe( leftType, isNeedHeapFreeStructure, baseType, resultType, termFull, termLeft, member, isVariable, relativeVar );
 	}
 globalArea:
@@ -500,9 +516,10 @@
 			}////////////////////////////////////////////
 
-			if(resultType.IsStruct()){
+			if(resultType.IsStruct())
+			{
 				//構造体が戻ったときはヒープ領域にインスタンスが格納されている
 				//※後にfreeする必要あり
 				// TODO: 解放はGCに任せる
-				*pbUseHeap = 1;
+				isNeedHeapFreeStructure = true;
 			}
 
@@ -628,9 +645,10 @@
 		}////////////////////////////////////////////
 
-		if(resultType.IsStruct()){
+		if(resultType.IsStruct())
+		{
 			//構造体が戻ったときはヒープ領域にインスタンスが格納されている
 			//※後にfreeする必要あり
 			// TODO: 解放はGCに任せる
-			*pbUseHeap = 1;
+			isNeedHeapFreeStructure = true;
 		}
 
@@ -648,5 +666,5 @@
 }
 
-bool TermOpe( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, BOOL *pbUseHeap, bool *pIsClassName, bool isProcedureCallOnly, bool isWriteAccess )
+bool TermOpe( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, bool &isNeedHeapFreeStructure, bool *pIsClassName, bool isProcedureCallOnly, bool isWriteAccess )
 {
 	bool isInitRegSwitch = false;
@@ -665,5 +683,5 @@
 	RELATIVE_VAR relativeVar;
 	bool isVariable = false;
-	bool result = _TermOpe( term, baseType, resultType, isLiteral, pbUseHeap, pIsClassName, isProcedureCallOnly, isVariable, relativeVar, isWriteAccess );
+	bool result = _TermOpe( term, baseType, resultType, isLiteral, isNeedHeapFreeStructure, pIsClassName, isProcedureCallOnly, isVariable, relativeVar, isWriteAccess );
 
 	if( isVariable )
@@ -705,6 +723,6 @@
 	pobj_reg = new CRegister( REG_NON );
 
-	bool isLiteral, isVariable = false;
-	bool result = _TermOpe( term, Type(), resultType, isLiteral, NULL, NULL, false, isVariable, relativeVar, isWriteAccess );
+	bool isLiteral, isVariable = false, isNeedHeapFreeStructure = false;
+	bool result = _TermOpe( term, Type(), resultType, isLiteral, isNeedHeapFreeStructure, NULL, false, isVariable, relativeVar, isWriteAccess );
 
 	if( !isVariable )
@@ -731,5 +749,5 @@
 			const Type &baseType,
 			Type &resultType,
-			BOOL *pbUseHeap )
+			bool *pbIsNeedHeapFreeStructure )
 {
 	int i,i2,i3;
@@ -892,5 +910,5 @@
 	LONG_PTR index_stack[255];
 	bool isNothing_stack[255];
-	BOOL bUseHeap[255];
+	bool isNeedHeapFreeStructureStack[255];
 	_int64 i64data;
 	int UseReg,XmmReg;
@@ -916,5 +934,5 @@
 				else{
 					//オーバーロードされたオペレータを呼び出す
-					i2=CallOperatorProc(idCalc,baseType,type_stack,index_stack,bUseHeap,sp);
+					i2=CallOperatorProc(idCalc,baseType,type_stack,index_stack,isNeedHeapFreeStructureStack,sp);
 					if(i2==0){
 						if(idCalc==CALC_EQUAL) lstrcpy(temp2,"==");
@@ -938,5 +956,5 @@
 				index_stack[sp]=-1;
 				isNothing_stack[sp] = false;
-				bUseHeap[sp]=0;
+				isNeedHeapFreeStructureStack[sp] = false;
 
 				UseReg=pobj_reg->GetNextReg();
@@ -1041,5 +1059,5 @@
 
 					bool isLiteral;
-					if( TermOpe( term, baseType, resultType, isLiteral, &bUseHeap[sp] ) ){
+					if( TermOpe( term, baseType, resultType, isLiteral, isNeedHeapFreeStructureStack[sp] ) ){
 						if(resultType.IsNull()){
 							//戻り値が存在しないとき
@@ -1346,5 +1364,8 @@
 	}
 
-	if(pbUseHeap) *pbUseHeap=bUseHeap[0];
+	if( pbIsNeedHeapFreeStructure )
+	{
+		*pbIsNeedHeapFreeStructure = isNeedHeapFreeStructureStack[0];
+	}
 
 	if(IsRealNumberType(type_stack[0]))
@@ -1386,5 +1407,5 @@
 			const Type &baseType,
 			Type &resultType,
-			BOOL *pbUseHeap )
+			bool *pbIsNeedHeapFreeStructure )
 {
 	bool isInitRegSwitch = false;
@@ -1403,5 +1424,5 @@
 
 
-	bool result = _numope( pReg, expression, baseType, resultType, pbUseHeap );
+	bool result = _numope( pReg, expression, baseType, resultType, pbIsNeedHeapFreeStructure );
 
 
