Index: BasicCompiler32/Compile_ProcOp.cpp
===================================================================
--- BasicCompiler32/Compile_ProcOp.cpp	(revision 63)
+++ BasicCompiler32/Compile_ProcOp.cpp	(revision 64)
@@ -293,13 +293,14 @@
 
 		LocalVar[MaxLocalVarNum].type=psi->pRealParmInfo[i3].type;
-		if(LocalVar[MaxLocalVarNum].type==DEF_OBJECT){
-			if(psi->bExport)
-				SetError(24,NULL,cp);
+		if(LocalVar[MaxLocalVarNum].type==DEF_OBJECT
+			||LocalVar[MaxLocalVarNum].type==DEF_STRUCT){
+				if(psi->bExport)
+					SetError(24,NULL,cp);
 		}
 
 		LocalVar[MaxLocalVarNum].u.index=psi->pRealParmInfo[i3].u.index;
 
-		if(psi->pRealParmInfo[i3].bByVal&&psi->pRealParmInfo[i3].type==DEF_OBJECT){
-			//実態オブジェクトのByValパラメータ
+		if(psi->pRealParmInfo[i3].bByVal&&psi->pRealParmInfo[i3].type==DEF_STRUCT){
+			//構造体のByValパラメータ
 			LocalVar[MaxLocalVarNum].fRef=REF_PARAMETER | OBJECT_PARAMETER;
 			VarSize=PTR_SIZE;
@@ -370,5 +371,5 @@
 	OpBuffer[obp++]=(char)0x57;
 
-	if(psi->ReturnType!=-1){
+	if(psi->ReturnType!=DEF_NON){
 		//戻り値が存在するとき
 
@@ -377,10 +378,6 @@
 		else temp=psi->name;
 
-		if(psi->ReturnType==DEF_OBJECT && psi->isReturnRef == false){
-			//戻り値用オブジェクトのコンストラクタを呼び出す
-			if( psi->u.Return_pobj_c->GetConstructorMethod() ){
-				sprintf(temporary,"%s.%s()",temp,psi->u.Return_pobj_c->name);
-				OpcodeOthers(temporary);
-			}
+		if(psi->ReturnType==DEF_STRUCT && psi->isReturnRef == false){
+			//戻り値用の構造体（値型）はパラメータで引き渡される
 		}
 		else{
@@ -517,35 +514,12 @@
 			for(i3=0;i3<pobj_CompilingClass->iMemberNum;i3++){
 				CMember *pMember = pobj_CompilingClass->ppobj_Member[i3];
-				int MemberTypeSize=
-					GetTypeSize(pMember->TypeInfo.type,
-						pMember->TypeInfo.u.lpIndex);
-
-				int MemberObjectNum=
-					JumpSubScripts(pMember->SubScripts);
-
-				int offset = pobj_CompilingClass->GetMemberOffset( pMember->name, NULL );
-
-				if(pMember->TypeInfo.type==DEF_OBJECT && pMember->IsRef() == false){
-					CMethod *method = pMember->TypeInfo.u.pobj_Class->GetConstructorMethod();
-					if( method ){
-						if( method->psi->RealParmNum == 1 ){	//Thisポインタを第一引数に持ち合わせるため、引数なしの場合はこの値が1になる
-							for(i4=0;i4<MemberObjectNum;i4++){
-								//Thisポインタをecxにコピー
-								SetThisPtrToReg(REG_ECX);
-
-								//add ecx,offset
-								OpBuffer[obp++]=(char)0x81;
-								OpBuffer[obp++]=(char)0xC1;
-								*((long *)(OpBuffer+obp))=offset+i4*MemberTypeSize;
-								obp+=sizeof(long);
-
-								//push ecx
-								op_push(REG_ECX);
-
-								//call constructor
-								op_call( method->psi );
-							}
-						}
-					}
+				if(pMember->TypeInfo.type==DEF_OBJECT){
+					// オブジェクトメンバを発見したとき
+
+					sprintf(temporary, "This.%s=%c%c%s()",
+						pMember->name,
+						1, ESC_NEW,
+						pMember->TypeInfo.u.pobj_Class->name );
+					OpcodeCalc( temporary );
 				}
 			}
@@ -619,5 +593,6 @@
 			}
 
-			//実体クラスを持つメンバのデストラクタを呼び出す
+			//実体クラスを持つメンバのデストラクタ呼び出しはGCに任せる
+			/*
 			//※コンストラクタと逆順序で呼び出す
 			int offset;
@@ -658,5 +633,5 @@
 					}
 				}
-			}
+			}*/
 		}
 	}
@@ -706,5 +681,5 @@
 
 	if(bDebugCompile&&bDebugSupportProc==0){
-		*((long *)(OpBuffer+EspOffsetSchedule))=AllLocalVarSize-BaseOffset;
+		*((long *)(OpBuffer+EspOffsetSchedule))=AllLocalVarSize-BaseOffset-sizeof(long);
 
 		//call _DebugSys_EndProc
@@ -713,5 +688,5 @@
 	}
 
-	if(psi->ReturnType!=-1){
+	if(psi->ReturnType!=DEF_NON){
 		//戻り値をeax、edxに設定
 		RELATIVE_VAR RelativeVar;
@@ -726,6 +701,10 @@
 		i3=psi->ReturnType;
 
-		if(i3==DEF_OBJECT){
+		if(i3==DEF_OBJECT || i3==DEF_STRUCT){
 			SetVarPtrToEax(&RelativeVar);
+			if( i3==DEF_OBJECT ){
+				//mov eax,dword ptr[eax]
+				op_mov_RM( sizeof(long), REG_EAX, REG_EAX, 0, MOD_BASE );
+			}
 		}
 		else if(i3==DEF_DOUBLE){
@@ -818,4 +797,19 @@
 	op_pop(REG_EBX);
 
+	if(bDebugCompile){
+		//cmp esp,ebp
+		op_cmp_RR( REG_ESP, REG_EBP );
+
+		//jz 6（次のcallとbreakpointを飛び越す）
+		OpBuffer[obp++]=(char)0x74;
+		OpBuffer[obp++]=(char)0x06;
+
+		//call _esp_error
+		extern SUBINFO *pSub_esp_error;
+		op_call( pSub_esp_error );
+
+		breakpoint;
+	}
+
 	//mov esp,ebp
 	OpBuffer[obp++]=(char)0x8B;
