Index: trunk/abdev/BasicCompiler32/CParameter.cpp
===================================================================
--- trunk/abdev/BasicCompiler32/CParameter.cpp	(revision 435)
+++ trunk/abdev/BasicCompiler32/CParameter.cpp	(revision 436)
@@ -65,6 +65,6 @@
 				//変数ではないとき
 				Type calcType;
-				BOOL bUseHeap;
-				NumOpe( Parms[i2], dummyType, calcType, &bUseHeap );
+				bool isNeedHeapFreeStructure;
+				NumOpe( Parms[i2], dummyType, calcType, &isNeedHeapFreeStructure );
 				//↑ここでスタックに積む
 
@@ -86,6 +86,8 @@
 					i2);
 
-				if( result && bUseHeap ){
+				if( result )
+				{
 					useTempParameters[i2] = true;
+					isNeedFreeStructures[i2] = true;
 					useTempObject = true;
 
@@ -107,15 +109,26 @@
 	for(int i2=ParmsNum-1;i2>=0;i2--){
 		if( useTempParameters[i2] ){
-			if( types[i2].IsStruct() ){
+			if( types[i2].IsStruct() )
+			{
 				// 構造体の一時メモリ
 
-				//メモリを解放する
-
-				//call free
-				extern const UserProc *pSub_free;
-				compiler.codeGenerator.op_call(pSub_free);
-			}
-			else{
-				if( types[i2].Is64() ){
+				if( isNeedFreeStructures[i2] )
+				{
+					//メモリを解放する
+
+					//call free
+					extern const UserProc *pSub_free;
+					compiler.codeGenerator.op_call(pSub_free);
+				}
+				else
+				{
+					//pop ... 参照を消す
+					compiler.codeGenerator.op_add_esp( PTR_SIZE );
+				}
+			}
+			else
+			{
+				if( types[i2].Is64() )
+				{
 					//pop ... 参照を消す
 					//pop ... 上位32ビット
@@ -123,5 +136,6 @@
 					compiler.codeGenerator.op_add_esp( PTR_SIZE * 3 );
 				}
-				else{
+				else
+				{
 					//pop ... 参照を消す
 					//pop ... 値を消す
@@ -150,12 +164,12 @@
 
 	Type calcType;
-	BOOL bUseHeap;
+	bool isNeedHeapFreeStructure;
 	NumOpe( expression,
 		baseType,
 		calcType,
-		&bUseHeap );
+		&isNeedHeapFreeStructure );
 
 	// ※スタックにある二つのデータ（コピー先、コピー元）の値を必要とする
-	SetStructVariable( baseType, calcType, bUseHeap );
+	SetStructVariable( baseType, calcType, isNeedHeapFreeStructure );
 }
 
@@ -234,17 +248,20 @@
 			}
 
-			BOOL bCalcUseHeap;
 			Type calcType;
-			if( !NumOpe( Parms[i2], dummyType, calcType, &bCalcUseHeap ) ){
+			bool isNeedHeapFreeStructure;
+			if( !NumOpe( Parms[i2], dummyType, calcType, &isNeedHeapFreeStructure ) )
+			{
 				break;
 			}
 
-			if( calcType.IsObject() ){
+			if( calcType.IsObject() )
+			{
 				if( !dummyType.IsObject()
 					||
 					dummyType.IsObject() &&
-					!dummyType.GetClass().IsEqualsOrSubClass( &calcType.GetClass() ) ){
+					!dummyType.GetClass().IsEqualsOrSubClass( &calcType.GetClass() ) )
+				{
 						//キャスト演算子のオーバーロードに対応する
-						CallCastOperatorProc( calcType, bCalcUseHeap,dummyType );
+						CallCastOperatorProc( calcType, isNeedHeapFreeStructure,dummyType );
 				}
 			}
Index: trunk/abdev/BasicCompiler32/Compile_Calc.cpp
===================================================================
--- trunk/abdev/BasicCompiler32/Compile_Calc.cpp	(revision 435)
+++ trunk/abdev/BasicCompiler32/Compile_Calc.cpp	(revision 436)
@@ -573,7 +573,7 @@
 
 	//NumOpe...（スタックに答えが格納される）
-	BOOL bCalcUseHeap;
 	Type calcType;
-	if( !NumOpe(Command+i+1,varType,calcType,&bCalcUseHeap) ){
+	bool isNeedHeapFreeStructure;
+	if( !NumOpe(Command+i+1,varType,calcType,&isNeedHeapFreeStructure) ){
 		return;
 	}
@@ -588,5 +588,5 @@
 		if( !isUpCast ){
 			//キャスト演算子のオーバーロードに対応する
-			CallCastOperatorProc(calcType,bCalcUseHeap,varType);
+			CallCastOperatorProc(calcType,isNeedHeapFreeStructure,varType);
 		}
 	}
@@ -606,5 +606,5 @@
 	if( varType.IsStruct() ){
 		//構造体インスタンスへの代入
-		SetStructVariable(varType,calcType,bCalcUseHeap);
+		SetStructVariable(varType,calcType,isNeedHeapFreeStructure);
 		return;
 	}
Index: trunk/abdev/BasicCompiler32/Compile_Var.cpp
===================================================================
--- trunk/abdev/BasicCompiler32/Compile_Var.cpp	(revision 435)
+++ trunk/abdev/BasicCompiler32/Compile_Var.cpp	(revision 436)
@@ -116,11 +116,12 @@
 	for(i=i3-1;i>=0;i--){
 		Type tempType;
-		BOOL bUseHeap;
-		NumOpe( pParm[i], Type( DEF_LONG ), tempType, &bUseHeap );
-		if( tempType.IsObject() ){
+		bool isNeedHeapFreeStructure;
+		NumOpe( pParm[i], Type( DEF_LONG ), tempType, &isNeedHeapFreeStructure );
+		if( tempType.IsObject() )
+		{
 			//キャスト演算子のオーバーロードに対応する
 			CallCastOperatorProc(
 				tempType,
-				bUseHeap, Type(DEF_LONG) );
+				isNeedHeapFreeStructure, Type(DEF_LONG) );
 			tempType.SetBasicType( DEF_LONG );
 		}
@@ -130,5 +131,8 @@
 		compiler.codeGenerator.op_pop(REG_EAX);
 
-		for(i2=i+1,i4=1;i2<i3;i2++) i4*=subscripts[i2]+1;
+		for( i2=i+1, i4=1; i2<i3; i2++ )
+		{
+			i4*=subscripts[i2]+1;
+		}
 
 		//imul eax,i4
Index: trunk/abdev/BasicCompiler32/NumOpe.cpp
===================================================================
--- trunk/abdev/BasicCompiler32/NumOpe.cpp	(revision 435)
+++ trunk/abdev/BasicCompiler32/NumOpe.cpp	(revision 436)
@@ -671,7 +671,8 @@
 			const Type &baseType,
 			Type &resultType,
-			BOOL *pbUseHeap ){
-
-	if( !NumOpe( expression, baseType, resultType, pbUseHeap ) ){
+			bool *pbIsNeedHeapFreeStructure ){
+
+	if( !NumOpe( expression, baseType, resultType, pbIsNeedHeapFreeStructure ) )
+	{
 		return false;
 	}
@@ -703,5 +704,5 @@
 			const Type &baseType,
 			Type &resultType,
-			BOOL *pbUseHeap )
+			bool *pbIsNeedHeapFreeStructure )
 {
 	int i,i2,i3;
@@ -1274,5 +1275,8 @@
 	}
 
-	if(pbUseHeap) *pbUseHeap = isNeedHeapFreeStructureStack[0];
+	if(pbIsNeedHeapFreeStructure)
+	{
+		*pbIsNeedHeapFreeStructure = isNeedHeapFreeStructureStack[0];
+	}
 
 	resultType.SetType( type_stack[0], index_stack[0] );
Index: trunk/abdev/BasicCompiler32/Opcode.h
===================================================================
--- trunk/abdev/BasicCompiler32/Opcode.h	(revision 435)
+++ trunk/abdev/BasicCompiler32/Opcode.h	(revision 436)
@@ -73,9 +73,9 @@
 			const Type &baseType,
 			Type &resultType,
-			BOOL *pbUseHeap = NULL );
+			bool *pbIsNeedHeapFreeStructure = NULL );
 bool NumOpe( const char *Command,
 		   const Type &baseType,
 		   Type &resultType,
-		   BOOL *pbUseHeap = NULL );
+		   bool *pbIsNeedHeapFreeStructure = NULL );
 
 //NumOpe_Arithmetic.cpp
@@ -177,4 +177,5 @@
 	bool useTempObject;
 	bool useTempParameters[255];
+	bool isNeedFreeStructures[255];
 	int nCountOfTempObjects;
 
Index: trunk/abdev/BasicCompiler64/CParameter.cpp
===================================================================
--- trunk/abdev/BasicCompiler64/CParameter.cpp	(revision 435)
+++ trunk/abdev/BasicCompiler64/CParameter.cpp	(revision 436)
@@ -65,5 +65,6 @@
 				int reg = REG_RAX;
 				Type calcType;
-				NumOpe( &reg, Parms[i2], dummyType, calcType );
+				bool isNeedHeapFreeStructure;
+				NumOpe( &reg, Parms[i2], dummyType, calcType, &isNeedHeapFreeStructure );
 
 				if( !calcType.IsStruct() ){
@@ -86,6 +87,8 @@
 					i2);
 
-				if( result ){
+				if( result )
+				{
 					useTempParameters[i2] = true;
+					isNeedFreeStructures[i2] = isNeedHeapFreeStructure;
 					useTempObject = true;
 
@@ -109,13 +112,21 @@
 				// 構造体の一時メモリ
 
-				//メモリを解放する
-
-				pobj_sf->pop( REG_RCX );
-
-				//call free
-				extern const UserProc *pSub_free;
-				compiler.codeGenerator.op_call(pSub_free);
-			}
-			else{
+				if( isNeedFreeStructures[i2] )
+				{
+					//メモリを解放する
+
+					pobj_sf->pop( REG_RCX );
+
+					//call free
+					extern const UserProc *pSub_free;
+					compiler.codeGenerator.op_call(pSub_free);
+				}
+				else
+				{
+					pobj_sf->pop();
+				}
+			}
+			else
+			{
 				pobj_sf->pop();
 				pobj_sf->pop();
@@ -148,5 +159,5 @@
 
 		Type calcType;
-		BOOL bUseHeap;
+		bool isNeedHeapFreeStructure;
 		int temp_reg=REG_RAX;
 		NumOpe( &temp_reg,
@@ -154,5 +165,5 @@
 			baseType,
 			calcType,
-			&bUseHeap );
+			&isNeedHeapFreeStructure );
 
 
@@ -169,5 +180,5 @@
 			baseType,
 			calcType,
-			&RelativeVar,bUseHeap);
+			&RelativeVar,isNeedHeapFreeStructure);
 
 
@@ -282,7 +293,7 @@
 			temp_reg=reg;
 
-			BOOL bCalcUseHeap;
 			Type calcType;
-			if( !NumOpe( &temp_reg, Parms[i2], dummyType, calcType, &bCalcUseHeap ) ){
+			bool isNeedHeapFreeStructure;
+			if( !NumOpe( &temp_reg, Parms[i2], dummyType, calcType, &isNeedHeapFreeStructure ) ){
 				break;
 			}
@@ -294,5 +305,5 @@
 					!dummyType.GetClass().IsEqualsOrSubClass( &calcType.GetClass() ) ){
 						//キャスト演算子のオーバーロードに対応する
-						CallCastOperatorProc( reg, calcType, bCalcUseHeap,dummyType );
+						CallCastOperatorProc( reg, calcType, isNeedHeapFreeStructure,dummyType );
 				}
 			}
Index: trunk/abdev/BasicCompiler64/Compile_Calc.cpp
===================================================================
--- trunk/abdev/BasicCompiler64/Compile_Calc.cpp	(revision 435)
+++ trunk/abdev/BasicCompiler64/Compile_Calc.cpp	(revision 436)
@@ -190,7 +190,7 @@
 	//NumOpe...（rax、またはxmm0に答えが格納される）
 	int reg=REG_RAX;
-	BOOL bCalcUseHeap;
 	Type calcType;
-	if( !NumOpe(&reg,Command+i+1,varType,calcType,&bCalcUseHeap) ){
+	bool isNeedHeapFreeStructure;
+	if( !NumOpe(&reg,Command+i+1,varType,calcType,&isNeedHeapFreeStructure) ){
 		return;
 	}
@@ -222,5 +222,5 @@
 	if( varType.IsStruct() ){
 		//構造体インスタンスへの代入
-		SetStructVariableFromRax(varType,calcType,&VarRelativeVar,bCalcUseHeap);
+		SetStructVariableFromRax(varType,calcType,&VarRelativeVar,isNeedHeapFreeStructure);
 		return;
 	}
@@ -235,5 +235,5 @@
 		if( !isUpCast ){
 			//キャスト演算子のオーバーロードに対応する
-			CallCastOperatorProc(REG_RAX,calcType,bCalcUseHeap,varType);
+			CallCastOperatorProc(REG_RAX,calcType,isNeedHeapFreeStructure,varType);
 		}
 	}
@@ -269,3 +269,7 @@
 	/////////////////////////////////////////////////
 	SetVariableFromRax(varType,calcType.GetBasicType(),&VarRelativeVar);
+
+
+	// コード生成過程で発生した構造体の一時メモリを破棄する
+	compiler.codeGenerator.op_FreeTempStructure();
 }
Index: trunk/abdev/BasicCompiler64/Compile_CallProc.cpp
===================================================================
--- trunk/abdev/BasicCompiler64/Compile_CallProc.cpp	(revision 435)
+++ trunk/abdev/BasicCompiler64/Compile_CallProc.cpp	(revision 436)
@@ -322,9 +322,13 @@
 			if(lstrcmpi(ObjectName,"Super")==0) goto InClassMember;
 			else{
-				bool isLiteral;
+				bool isLiteral, isNeedHeapFreeStructure = false;
 				Type baseType( DEF_OBJECT, *pUserProc->GetParentClassPtr() ) , resultType;
-				if( !TermOpe( ObjectName, baseType, resultType, isLiteral, NULL, NULL, false, !pMethod->IsConst() ) )
+				if( !TermOpe( ObjectName, baseType, resultType, isLiteral, isNeedHeapFreeStructure, NULL, false, !pMethod->IsConst() ) )
 				{
 					return false;
+				}
+				if( !resultType.IsObject() )
+				{
+					SetError();
 				}
 
Index: trunk/abdev/BasicCompiler64/Compile_Statement.cpp
===================================================================
--- trunk/abdev/BasicCompiler64/Compile_Statement.cpp	(revision 435)
+++ trunk/abdev/BasicCompiler64/Compile_Statement.cpp	(revision 436)
@@ -95,7 +95,6 @@
 
 	Type resultType;
-	bool isLiteral;
-	BOOL bUseHeap;
-	bool result = TermOpe( leftTerm, Type(), resultType, isLiteral, &bUseHeap, NULL, true );
+	bool isLiteral, isNeedHeapFreeStructure = false;
+	bool result = TermOpe( leftTerm, Type(), resultType, isLiteral, isNeedHeapFreeStructure, NULL, true );
 
 	delete pobj_reg;
Index: trunk/abdev/BasicCompiler64/Compile_Var.cpp
===================================================================
--- trunk/abdev/BasicCompiler64/Compile_Var.cpp	(revision 435)
+++ trunk/abdev/BasicCompiler64/Compile_Var.cpp	(revision 436)
@@ -142,15 +142,17 @@
 		int reg=REG_NON;
 		Type type;
-		BOOL bUseHeap;
-		NumOpe( &reg, pParm[i], Type( DEF_LONG ), type, &bUseHeap );
-		if( type.IsObject() ){
+		bool isNeedHeapFreeStructure;
+		NumOpe( &reg, pParm[i], Type( DEF_LONG ), type, &isNeedHeapFreeStructure );
+		if( type.IsObject() )
+		{
 			//キャスト演算子のオーバーロードに対応する
 			CallCastOperatorProc(reg,
 				type,
-				bUseHeap, Type(DEF_LONG) );
+				isNeedHeapFreeStructure, Type(DEF_LONG) );
 			type.SetBasicType( DEF_LONG );
 		}
 
-		if( !type.IsWhole() ){
+		if( !type.IsWhole() )
+		{
 			SetError(46,NULL,cp);
 		}
Index: trunk/abdev/BasicCompiler64/MakePeHdr.cpp
===================================================================
--- trunk/abdev/BasicCompiler64/MakePeHdr.cpp	(revision 435)
+++ trunk/abdev/BasicCompiler64/MakePeHdr.cpp	(revision 436)
@@ -33,4 +33,6 @@
 	*pSub_System_GC_malloc_ForObjectPtr,
 	*pSub_System_GC_free_for_SweepingDelete,
+	*pSub_System_AddNeedFreeTempStructure,
+	*pSub_System_FreeTempStructure,
 	*pSubStaticMethod_System_TypeBase_InitializeUserTypes,
 	*pSubStaticMethod_System_TypeBase_InitializeUserTypesForBaseType;
@@ -266,4 +268,13 @@
 	if( pSub_System_GC_free_for_SweepingDelete = GetSubHash( "_System_GC_free_for_SweepingDelete",1 ) )
 		pSub_System_GC_free_for_SweepingDelete->Using();
+
+	if( pSub_System_AddNeedFreeTempStructure = GetSubHash( "_System_AddNeedFreeTempStructure",1 ) )
+	{
+		pSub_System_AddNeedFreeTempStructure->Using();
+	}
+	if( pSub_System_FreeTempStructure = GetSubHash( "_System_FreeTempStructure",1 ) )
+	{
+		pSub_System_FreeTempStructure->Using();
+	}
 
 	if( pSubStaticMethod_System_TypeBase_InitializeUserTypes = GetSubHash( "ActiveBasic.Core._System_TypeBase.InitializeUserTypes",1 ) ){
Index: trunk/abdev/BasicCompiler64/NumOpe.cpp
===================================================================
--- trunk/abdev/BasicCompiler64/NumOpe.cpp	(revision 435)
+++ 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 );
 
 
Index: trunk/abdev/BasicCompiler64/Opcode.h
===================================================================
--- trunk/abdev/BasicCompiler64/Opcode.h	(revision 435)
+++ trunk/abdev/BasicCompiler64/Opcode.h	(revision 436)
@@ -191,5 +191,5 @@
 			 Type &resultType,
 			 bool &isLiteral,
-			 BOOL *pbUseHeap,
+			 bool &isNeedHeapFreeStructure,
 			 bool *pIsClassName = NULL,
 			 bool isProcedureCallOnly = false,
@@ -199,5 +199,5 @@
 		   const Type &baseType,
 		   Type &resultType,
-		   BOOL *pbUseHeap = NULL );
+		   bool *pbIsNeedHeapFreeStructure = NULL );
 
 //NumOpe_Arithmetic.cpp
@@ -276,4 +276,5 @@
 	bool useTempObject;
 	bool useTempParameters[255];
+	bool isNeedFreeStructures[255];
 	int StackOffsetOfTempObject[255];
 
@@ -337,5 +338,5 @@
 //OperatorProc.cpp
 void FreeTempObject(int reg,const CClass *pobj_c);
-int CallOperatorProc(BYTE idCalc, const Type &baseType, int *type_stack,LONG_PTR *index_stack,BOOL *bUseHeap,int &sp);
+int CallOperatorProc(BYTE idCalc, const Type &baseType, int *type_stack,LONG_PTR *index_stack,bool isNeedHeapFreeStructureStack[],int &sp);
 void CallCastOperatorProc(int reg,Type &calcType,BOOL bCalcUseHeap,const Type &toType);
 void CallIndexerGetterProc(int reg, const Type &classType, const char *ObjectName,char *Parameter,Type &resultType, DWORD dwProcFlags = 0 );
Index: trunk/abdev/BasicCompiler64/OperatorProc.cpp
===================================================================
--- trunk/abdev/BasicCompiler64/OperatorProc.cpp	(revision 435)
+++ trunk/abdev/BasicCompiler64/OperatorProc.cpp	(revision 436)
@@ -31,5 +31,5 @@
 }
 
-int CallOperatorProc(BYTE idCalc, const Type &baseType, int *type_stack,LONG_PTR *index_stack,BOOL *bUseHeap,int &sp)
+int CallOperatorProc(BYTE idCalc, const Type &baseType, int *type_stack,LONG_PTR *index_stack,bool isNeedHeapFreeStructureStack[],int &sp)
 {
 	Type leftType( type_stack[sp-2], index_stack[sp-2] );
@@ -101,5 +101,5 @@
 		if( pUserProc->RealParams()[1]->IsStruct() &&pUserProc->RealParams()[1]->IsRef() == false ){
 			//一時オブジェクトはメソッド内で破棄される
-			bUseHeap[sp-1]=0;
+			isNeedHeapFreeStructureStack[sp-1] = false;
 		}
 	}
@@ -153,9 +153,9 @@
 
 	//ヒープ解放用に退避
-	if(bUseHeap[sp-1]){
+	if(isNeedHeapFreeStructureStack[sp-1]){
 		//mov qword ptr[rsp+offset],reg2     ※スタックフレームを利用
 		pobj_sf->push(reg2);
 	}
-	if(bUseHeap[sp-2]){
+	if(isNeedHeapFreeStructureStack[sp-2]){
 		//mov qword ptr[rsp+offset],reg1     ※スタックフレームを利用
 		pobj_sf->push(reg1);
@@ -213,6 +213,6 @@
 
 
-	if(bUseHeap[sp-2]||bUseHeap[sp-1]){
-
+	if( isNeedHeapFreeStructureStack[sp-2] || isNeedHeapFreeStructureStack[sp-1] )
+	{
 		//////////////////////////////////////////////////////
 		/////    レジスタ資源のバックアップ
@@ -220,5 +220,6 @@
 		//////////////////////////////////////////////////////
 
-			if(bUseHeap[sp-2]){
+			if( isNeedHeapFreeStructureStack[sp-2] )
+			{
 				//mov r14,qword ptr[rsp+offset]     ※スタックフレームを利用
 				pobj_sf->pop(REG_R14);
@@ -226,5 +227,6 @@
 				FreeTempObject(REG_R14,(CClass *)index_stack[sp-2]);
 			}
-			if(bUseHeap[sp-1]){
+			if( isNeedHeapFreeStructureStack[sp-1] )
+			{
 				//mov r14,qword ptr[rsp+offset]     ※スタックフレームを利用
 				pobj_sf->pop(REG_R14);
@@ -258,10 +260,14 @@
 	index_stack[sp-1]=pUserProc->ReturnType().GetIndex();
 
-	if( pUserProc->ReturnType().IsStruct() ){
+	if( pUserProc->ReturnType().IsStruct() )
+	{
 		//構造体が戻ったときはヒープ領域にインスタンスが格納されている
 		//※後にfreeする必要あり
-		bUseHeap[sp-1]=1;
-	}
-	else bUseHeap[sp-1]=0;
+		isNeedHeapFreeStructureStack[sp-1] = true;
+	}
+	else
+	{
+		isNeedHeapFreeStructureStack[sp-1] = false;
+	}
 
 	return 1;
@@ -271,5 +277,5 @@
 	int type_stack[10];
 	LONG_PTR index_stack[10];
-	BOOL array_bUseHeap[10];
+	bool array_bUseHeap[10];
 	int sp=2;
 	int iRet;
Index: trunk/abdev/BasicCompiler_Common/src/CommonCodeGenerator.cpp
===================================================================
--- trunk/abdev/BasicCompiler_Common/src/CommonCodeGenerator.cpp	(revision 435)
+++ trunk/abdev/BasicCompiler_Common/src/CommonCodeGenerator.cpp	(revision 436)
@@ -2,4 +2,10 @@
 
 #include <CodeGenerator.h>
+
+#ifdef _AMD64_
+#include "../../BasicCompiler64/opcode.h"
+#else
+#include "../../BasicCompiler32/opcode.h"
+#endif
 
 
@@ -313,10 +319,10 @@
 	//////////////////////////////////////////////////////
 
-	//mov rcx,reg
-	compiler.codeGenerator.op_mov_RR( REG_RCX, reg );
-
-	//call _System_AddNeedFreeTempStructure
-	extern const UserProc *pSub_System_AddNeedFreeTempStructure;
-	compiler.codeGenerator.op_call( pSub_System_AddNeedFreeTempStructure );
+		//mov rcx,reg
+		op_mov_RR( REG_RCX, reg );
+
+		//call _System_AddNeedFreeTempStructure
+		extern const UserProc *pSub_System_AddNeedFreeTempStructure;
+		op_call( pSub_System_AddNeedFreeTempStructure );
 
 	/////////////////////////////////////////////
