Index: BasicCompiler32/Compile_Object.cpp
===================================================================
--- BasicCompiler32/Compile_Object.cpp	(revision 51)
+++ BasicCompiler32/Compile_Object.cpp	(revision 64)
@@ -2,5 +2,5 @@
 #include "opcode.h"
 
-void _call_constructor(CClass *pobj_c,char *CreateParameter,int ObjectSize,BOOL bSomeObjects){
+void _call_constructor(CClass *pobj_c, const char *CreateParameter,int ObjectSize,BOOL bSomeObjects){
 	////////////////////////////
 	// コンストラクタの呼び出し
@@ -74,6 +74,146 @@
 	}
 }
-int Operator_New(const char *Parameter,LONG_PTR *plpIndex){
-	char TypeName[VN_SIZE],CreateParameter[VN_SIZE],ObjectSize[VN_SIZE];
+void Operator_New( CClass &classObj, const char *objectSizeStr, const char *parameter, const TYPEINFO &baseTypeInfo ){
+	int typeSize = classObj.GetSize();
+
+	if(classObj.IsAbstract()){
+		//抽象クラスだったとき
+		SetError(125,classObj.name,cp);
+	}
+
+	if(objectSizeStr[0]){
+		int type = NumOpe(objectSizeStr,0,0,0);
+		ChangeTypeToLong(type);
+
+		//pop eax
+		op_pop(REG_EAX);
+
+		//※添え字上限値であることを考慮
+		//add eax,1
+		OpBuffer[obp++]=(char)0x83;
+		OpBuffer[obp++]=(char)0xC0;
+		OpBuffer[obp++]=(char)0x01;
+
+		//オブジェクトの個数をebxに一時保持
+		//※ebxは関数が呼ばれても不変
+		//mov ebx,eax
+		OpBuffer[obp++]=(char)0x8B;
+		OpBuffer[obp++]=(char)0xD8;
+
+		//imul eax,size
+		OpBuffer[obp++]=(char)0x69;
+		OpBuffer[obp++]=(char)0xC0;
+		*((long *)(OpBuffer+obp))=typeSize;
+		obp+=sizeof(long);
+
+		//add eax,sizeof(DWORD)*2
+		OpBuffer[obp++]=(char)0x05;
+		*((long *)(OpBuffer+obp))=sizeof(DWORD)*3;
+		obp+=sizeof(long);
+
+		//push eax
+		op_push(REG_EAX);
+	}
+	else{
+		//オブジェクトの個数をebxに一時保持
+		//※ebxは関数が呼ばれても不変
+		//mov ebx,1
+		OpBuffer[obp++]=(char)0xBB;
+		*((long *)(OpBuffer+obp))=1;
+		obp+=sizeof(long);
+
+		//push size
+		OpBuffer[obp++]=(char)0x68;
+		*((long *)(OpBuffer+obp))=typeSize+sizeof(DWORD)*3;
+		obp+=sizeof(long);
+	}
+
+	if( baseTypeInfo.type == DEF_OBJECT ){
+		//DeleteはGCで処理
+
+		//call _System_GC_malloc_ForObject
+		extern SUBINFO *pSub_System_GC_malloc_ForObject;
+		op_call(pSub_System_GC_malloc_ForObject);
+	}
+	else{
+		//明示的なDeleteが必要
+
+		//call _System_GC_malloc_ForObjectPtr
+		extern SUBINFO *pSub_System_GC_malloc_ForObjectPtr;
+		op_call(pSub_System_GC_malloc_ForObjectPtr);
+	}
+
+
+	/*
+	確保されたヒープ領域のポインタ（callocの戻り値eax）をpPtrとすると、
+	pPtr-=sizeof(DWORD)*3
+	pPtr[0]=オブジェクトの個数
+	pPtr[1]=オブジェクトのサイズ
+	pPtr[2]=デストラクタの関数ポインタ
+	*/
+
+
+	//mov dword ptr[eax],ebx（オブジェクトの個数）
+	OpBuffer[obp++]=(char)0x89;
+	OpBuffer[obp++]=(char)0x18;
+
+	//add eax,sizeof(DWORD)
+	OpBuffer[obp++]=(char)0x05;
+	*((long *)(OpBuffer+obp))=sizeof(DWORD);
+	obp+=sizeof(long);
+
+
+	//mov ecx,TypeSize
+	OpBuffer[obp++]=(char)0xB9;
+	*((long *)(OpBuffer+obp))=typeSize;
+	obp+=sizeof(long);
+
+	//mov dword ptr[eax],ecx
+	OpBuffer[obp++]=(char)0x89;
+	OpBuffer[obp++]=(char)0x08;
+
+	//add eax,sizeof(DWORD)
+	OpBuffer[obp++]=(char)0x05;
+	*((long *)(OpBuffer+obp))=sizeof(DWORD);
+	obp+=sizeof(long);
+
+
+	CMethod *method = classObj.GetDestructorMethod();
+	if( method == NULL ) return;
+
+	//mov ecx,DestructorProcAddr
+	OpBuffer[obp++]=(char)0xB9;
+	pobj_SubAddrSchedule->add(method->psi,0);
+	method->psi->bUse=1;
+	obp+=sizeof(long);
+
+	//mov dword ptr[eax],ecx
+	OpBuffer[obp++]=(char)0x89;
+	OpBuffer[obp++]=(char)0x08;
+
+	//add eax,sizeof(DWORD)
+	OpBuffer[obp++]=(char)0x05;
+	*((long *)(OpBuffer+obp))=sizeof(DWORD);
+	obp+=sizeof(long);
+
+
+	// ※ここでプッシュされた値はNew演算子の戻り値となる
+	//push eax
+	op_push(REG_EAX);
+
+
+	/////////////////////////////////////////////////////////////////////
+
+	////////////////////////////
+	// コンストラクタの呼び出し
+	////////////////////////////
+
+	BOOL bSomeObjects;
+	if(objectSizeStr[0]) bSomeObjects=1;
+	else bSomeObjects=0;
+	_call_constructor(&classObj,parameter,typeSize,bSomeObjects);
+}
+int Operator_New(const char *Parameter,LONG_PTR *plpIndex,const TYPEINFO &baseTypeInfo ){
+	char TypeName[VN_SIZE],CreateParameter[VN_SIZE],objectSizeStr[VN_SIZE];
 	int i,i2;
 
@@ -81,10 +221,10 @@
 
 	if(Parameter[0]=='['){
-		i=GetStringInBracket(ObjectSize,Parameter);
-
-		SlideString(ObjectSize+1,-1);
-		ObjectSize[i-2]=0;
-	}
-	else ObjectSize[0]=0;
+		i=GetStringInBracket(objectSizeStr,Parameter);
+
+		SlideString(objectSizeStr+1,-1);
+		objectSizeStr[i-2]=0;
+	}
+	else objectSizeStr[0]=0;
 
 	for(i2=0;;i++,i2++){
@@ -129,134 +269,13 @@
 	pobj_c=(CClass *)*plpIndex;
 
-	if(pobj_c->IsAbstract()){
-		//抽象クラスだったとき
-		SetError(125,pobj_c->name,cp);
-	}
-
-	if(ObjectSize[0]){
-		i2=NumOpe(ObjectSize,0,0,0);
-		ChangeTypeToLong(i2);
-
-		//pop eax
-		op_pop(REG_EAX);
-
-		//※添え字上限値であることを考慮
-		//add eax,1
-		OpBuffer[obp++]=(char)0x83;
-		OpBuffer[obp++]=(char)0xC0;
-		OpBuffer[obp++]=(char)0x01;
-
-		//オブジェクトの個数をebxに一時保持
-		//※ebxは関数が呼ばれても不変
-		//mov ebx,eax
-		OpBuffer[obp++]=(char)0x8B;
-		OpBuffer[obp++]=(char)0xD8;
-
-		//imul eax,size
-		OpBuffer[obp++]=(char)0x69;
-		OpBuffer[obp++]=(char)0xC0;
-		*((long *)(OpBuffer+obp))=TypeSize;
-		obp+=sizeof(long);
-
-		//add eax,sizeof(DWORD)*2
-		OpBuffer[obp++]=(char)0x05;
-		*((long *)(OpBuffer+obp))=sizeof(DWORD)*3;
-		obp+=sizeof(long);
-
-		//push eax
-		op_push(REG_EAX);
-	}
-	else{
-		//オブジェクトの個数をebxに一時保持
-		//※ebxは関数が呼ばれても不変
-		//mov ebx,1
-		OpBuffer[obp++]=(char)0xBB;
-		*((long *)(OpBuffer+obp))=1;
-		obp+=sizeof(long);
-
-		//push size
-		OpBuffer[obp++]=(char)0x68;
-		*((long *)(OpBuffer+obp))=TypeSize+sizeof(DWORD)*3;
-		obp+=sizeof(long);
-	}
-
-	//call calloc
-	extern SUBINFO *pSub_calloc;
-	op_call(pSub_calloc);
-
-
-	/*
-	確保されたヒープ領域のポインタ（callocの戻り値eax）をpPtrとすると、
-	pPtr-=sizeof(DWORD)*3
-	pPtr[0]=オブジェクトの個数
-	pPtr[1]=オブジェクトのサイズ
-	pPtr[2]=デストラクタの関数ポインタ
-	*/
-
-
-	//mov dword ptr[eax],ebx（オブジェクトの個数）
-	OpBuffer[obp++]=(char)0x89;
-	OpBuffer[obp++]=(char)0x18;
-
-	//add eax,sizeof(DWORD)
-	OpBuffer[obp++]=(char)0x05;
-	*((long *)(OpBuffer+obp))=sizeof(DWORD);
-	obp+=sizeof(long);
-
-
-	//mov ecx,TypeSize
-	OpBuffer[obp++]=(char)0xB9;
-	*((long *)(OpBuffer+obp))=TypeSize;
-	obp+=sizeof(long);
-
-	//mov dword ptr[eax],ecx
-	OpBuffer[obp++]=(char)0x89;
-	OpBuffer[obp++]=(char)0x08;
-
-	//add eax,sizeof(DWORD)
-	OpBuffer[obp++]=(char)0x05;
-	*((long *)(OpBuffer+obp))=sizeof(DWORD);
-	obp+=sizeof(long);
-
-
-	CMethod *method = pobj_c->GetDestructorMethod();
-	if( method == NULL ) return 0;
-
-	//mov ecx,DestructorProcAddr
-	OpBuffer[obp++]=(char)0xB9;
-	pobj_SubAddrSchedule->add(method->psi,0);
-	method->psi->bUse=1;
-	obp+=sizeof(long);
-
-	//mov dword ptr[eax],ecx
-	OpBuffer[obp++]=(char)0x89;
-	OpBuffer[obp++]=(char)0x08;
-
-	//add eax,sizeof(DWORD)
-	OpBuffer[obp++]=(char)0x05;
-	*((long *)(OpBuffer+obp))=sizeof(DWORD);
-	obp+=sizeof(long);
-
-
-	// ※ここでプッシュされた値はNew演算子の戻り値となる
-	//push eax
-	op_push(REG_EAX);
-
-
-	/////////////////////////////////////////////////////////////////////
-
-	////////////////////////////
-	// コンストラクタの呼び出し
-	////////////////////////////
-
-	BOOL bSomeObjects;
-	if(ObjectSize[0]) bSomeObjects=1;
-	else bSomeObjects=0;
-	_call_constructor(pobj_c,CreateParameter,TypeSize,bSomeObjects);
-
+	Operator_New( *pobj_c, objectSizeStr, CreateParameter, baseTypeInfo );
+
+	if( baseTypeInfo.type == DEF_OBJECT ){
+		return DEF_OBJECT;
+	}
 	return DEF_PTR_OBJECT;
 }
 
-void OpcodeDelete(char *Parameter){
+void OpcodeDelete(const char *Parameter, bool isSweeping){
 	int type;
 
@@ -355,6 +374,13 @@
 	//////////////////////////////////////////
 
-	//call free
-	extern SUBINFO *pSub_free;
-	op_call(pSub_free);
+	if( isSweeping ){
+		//call _System_GC_free_for_SweepingDelete
+		extern SUBINFO *pSub_System_GC_free_for_SweepingDelete;
+		op_call(pSub_System_GC_free_for_SweepingDelete);
+	}
+	else{
+		//call free
+		extern SUBINFO *pSub_free;
+		op_call(pSub_free);
+	}
 }
