Index: BasicCompiler32/Compile_ProcOp.cpp
===================================================================
--- BasicCompiler32/Compile_ProcOp.cpp	(revision 36)
+++ BasicCompiler32/Compile_ProcOp.cpp	(revision 40)
@@ -374,5 +374,5 @@
 		else temp=psi->name;
 
-		if(psi->ReturnType==DEF_OBJECT){
+		if(psi->ReturnType==DEF_OBJECT && psi->isReturnRef == false){
 			//戻り値用オブジェクトのコンストラクタを呼び出す
 			if(psi->u.Return_pobj_c->ConstructorMemberSubIndex!=-1){
@@ -383,6 +383,12 @@
 		else{
 			//戻り値用の変数の定義
-			sprintf(temporary,"%s%c%c",temp,1,ESC_AS);
+			if( psi->isReturnRef ){
+				sprintf(temporary,"%c%c",1,ESC_BYREF);
+			}
+			else temporary[0]=0;
+
+			sprintf(temporary+lstrlen(temporary),"%s%c%c",temp,1,ESC_AS);
 			GetTypeName(psi->ReturnType,psi->u.ReturnIndex,temporary+lstrlen(temporary));
+
 			OpcodeDim(temporary,0);
 		}
@@ -514,17 +520,19 @@
 			else offset=0;
 			for(i3=0;i3<pobj_CompilingClass->iMemberNum;i3++){
-				offset=GetSizeOfClassMember(pobj_CompilingClass,pobj_CompilingClass->ppobj_Member[i3]->name,NULL);
-
-				if(pobj_CompilingClass->ppobj_Member[i3]->TypeInfo.type==DEF_OBJECT){
-					if(pobj_CompilingClass->ppobj_Member[i3]->TypeInfo.u.pobj_Class->ConstructorMemberSubIndex!=-1){
-						i5=pobj_CompilingClass->ppobj_Member[i3]->TypeInfo.u.pobj_Class->ConstructorMemberSubIndex;
-						if(pobj_CompilingClass->ppobj_Member[i3]->TypeInfo.u.pobj_Class->ppobj_Method[i5]->psi->RealParmNum==1){	//Thisポインタを第一引数に持ち合わせるため、引数なしの場合はこの値が1になる
+				CMember *pMember = pobj_CompilingClass->ppobj_Member[i3];
+
+				offset=GetSizeOfClassMember(pobj_CompilingClass,pMember->name,NULL);
+
+				if(pMember->TypeInfo.type==DEF_OBJECT){
+					if(pMember->TypeInfo.u.pobj_Class->ConstructorMemberSubIndex!=-1){
+						i5=pMember->TypeInfo.u.pobj_Class->ConstructorMemberSubIndex;
+						if(pMember->TypeInfo.u.pobj_Class->ppobj_Method[i5]->psi->RealParmNum==1){	//Thisポインタを第一引数に持ち合わせるため、引数なしの場合はこの値が1になる
 
 							MemberTypeSize=
-								GetTypeSize(pobj_CompilingClass->ppobj_Member[i3]->TypeInfo.type,
-									pobj_CompilingClass->ppobj_Member[i3]->TypeInfo.u.lpIndex);
+								GetTypeSize(pMember->TypeInfo.type,
+									pMember->TypeInfo.u.lpIndex);
 
 							MemberObjectNum=
-								JumpSubScripts(pobj_CompilingClass->ppobj_Member[i3]->SubScripts);
+								JumpSubScripts(pMember->SubScripts);
 
 							for(i4=0;i4<MemberObjectNum;i4++){
@@ -542,5 +550,5 @@
 
 								//call constructor
-								op_call(pobj_CompilingClass->ppobj_Member[i3]->TypeInfo.u.pobj_Class->ppobj_Method[i5]->psi);
+								op_call(pMember->TypeInfo.u.pobj_Class->ppobj_Method[i5]->psi);
 							}
 						}
@@ -624,15 +632,17 @@
 			offset=GetTypeSize(DEF_OBJECT,(LONG_PTR)pobj_CompilingClass);
 			for(i3=pobj_CompilingClass->iMemberNum-1;i3>=0;i3--){
+				CMember *pMember = pobj_CompilingClass->ppobj_Member[i3];
+
 				MemberTypeSize=
-					GetTypeSize(pobj_CompilingClass->ppobj_Member[i3]->TypeInfo.type,
-						pobj_CompilingClass->ppobj_Member[i3]->TypeInfo.u.lpIndex);
+					GetTypeSize(pMember->TypeInfo.type,
+						pMember->TypeInfo.u.lpIndex);
 
 				MemberObjectNum=
-					JumpSubScripts(pobj_CompilingClass->ppobj_Member[i3]->SubScripts);
+					JumpSubScripts(pMember->SubScripts);
 
 				offset-=MemberTypeSize*MemberObjectNum;
 
-				if(pobj_CompilingClass->ppobj_Member[i3]->TypeInfo.type==DEF_OBJECT){
-					if(pobj_CompilingClass->ppobj_Member[i3]->TypeInfo.u.pobj_Class->DestructorMemberSubIndex!=-1){
+				if(pMember->TypeInfo.type==DEF_OBJECT){
+					if(pMember->TypeInfo.u.pobj_Class->DestructorMemberSubIndex!=-1){
 						for(i4=MemberObjectNum-1;i4>=0;i4--){
 							//Thisポインタをecxにコピー
@@ -649,6 +659,6 @@
 
 							//call destructor
-							i5=pobj_CompilingClass->ppobj_Member[i3]->TypeInfo.u.pobj_Class->DestructorMemberSubIndex;
-							op_call(pobj_CompilingClass->ppobj_Member[i3]->TypeInfo.u.pobj_Class->ppobj_Method[i5]->psi);
+							i5=pMember->TypeInfo.u.pobj_Class->DestructorMemberSubIndex;
+							op_call(pMember->TypeInfo.u.pobj_Class->ppobj_Method[i5]->psi);
 						}
 					}
