Index: /trunk/abdev/BasicCompiler32/Compile_ProcOp.cpp
===================================================================
--- /trunk/abdev/BasicCompiler32/Compile_ProcOp.cpp	(revision 245)
+++ /trunk/abdev/BasicCompiler32/Compile_ProcOp.cpp	(revision 246)
@@ -425,8 +425,5 @@
 
 	//Gotoラベルスケジュール
-	extern GOTOLABELSCHEDULE *pGotoLabelSchedule;
-	extern int GotoLabelScheduleNum;
-	pGotoLabelSchedule=(GOTOLABELSCHEDULE *)HeapAlloc(hHeap,0,1);
-	GotoLabelScheduleNum=0;
+	compiler.codeGenerator.gotoLabelSchedules.clear();
 
 	//With情報のメモリを確保
@@ -608,17 +605,4 @@
 	HeapDefaultFree(pLabelNames);
 
-	//Goto未知ラベルスケジュールを解放
-	for(i3=0;i3<GotoLabelScheduleNum;i3++){
-		if(pGotoLabelSchedule[i3].pName){
-			SetError(6,pGotoLabelSchedule[i3].pName,pGotoLabelSchedule[i3].now_cp);
-			HeapDefaultFree(pGotoLabelSchedule[i3].pName);
-		}
-		else{
-			sprintf(temporary,"%d",pGotoLabelSchedule[i3].line);
-			SetError(6,temporary,pGotoLabelSchedule[i3].now_cp);
-		}
-	}
-	HeapDefaultFree(pGotoLabelSchedule);
-
 	//With情報のメモリを解放
 	for(i3=0;i3<WithInfo.num;i3++){
Index: /trunk/abdev/BasicCompiler32/Compile_Statement.cpp
===================================================================
--- /trunk/abdev/BasicCompiler32/Compile_Statement.cpp	(revision 245)
+++ /trunk/abdev/BasicCompiler32/Compile_Statement.cpp	(revision 246)
@@ -300,6 +300,4 @@
 void OpcodeGoto(char *Parameter){
 	extern HANDLE hHeap;
-	extern GOTOLABELSCHEDULE *pGotoLabelSchedule;
-	extern int GotoLabelScheduleNum;
 	int i,LineNum;
 
@@ -307,16 +305,14 @@
 		i=GetLabelAddress(Parameter+1,0);
 
-		//jmp ...
-		OpBuffer[obp++]=(char)0xE9;
-		if(i==-1){
-			pGotoLabelSchedule=(GOTOLABELSCHEDULE *)HeapReAlloc(hHeap,0,pGotoLabelSchedule,(GotoLabelScheduleNum+1)*sizeof(GOTOLABELSCHEDULE));
-			pGotoLabelSchedule[GotoLabelScheduleNum].pName=(char *)HeapAlloc(hHeap,0,lstrlen(Parameter+1)+1);
-			lstrcpy(pGotoLabelSchedule[GotoLabelScheduleNum].pName,Parameter+1);
-			pGotoLabelSchedule[GotoLabelScheduleNum].pos=obp;
-			pGotoLabelSchedule[GotoLabelScheduleNum].now_cp=cp;
-			GotoLabelScheduleNum++;
-		}
-		*((long *)(OpBuffer+obp))=i-(obp+sizeof(long));
-		obp+=sizeof(long);
+		if( i == -1 )
+		{
+			//jmp ...(schedule)
+			compiler.codeGenerator.op_jmp_goto_schedule( GotoLabelSchedule( (const std::string)(Parameter + 1), obp, cp ) );
+		}
+		else
+		{
+			//jmp ...
+			compiler.codeGenerator.op_jmp( i-obp, sizeof(long), false, true );
+		}
 	}
 	else{
@@ -324,16 +320,14 @@
 		i=GetLabelAddress(0,LineNum);
 
-		//jmp ...
-		OpBuffer[obp++]=(char)0xE9;
-		if(i==-1){
-			pGotoLabelSchedule=(GOTOLABELSCHEDULE *)HeapReAlloc(hHeap,0,pGotoLabelSchedule,(GotoLabelScheduleNum+1)*sizeof(GOTOLABELSCHEDULE));
-			pGotoLabelSchedule[GotoLabelScheduleNum].pName=0;
-			pGotoLabelSchedule[GotoLabelScheduleNum].line=LineNum;
-			pGotoLabelSchedule[GotoLabelScheduleNum].pos=obp;
-			pGotoLabelSchedule[GotoLabelScheduleNum].now_cp=cp;
-			GotoLabelScheduleNum++;
-		}
-		*((long *)(OpBuffer+obp))=i-(obp+sizeof(long));
-		obp+=sizeof(long);
+		if( i == -1 )
+		{
+			//jmp ...(schedule)
+			compiler.codeGenerator.op_jmp_goto_schedule( GotoLabelSchedule( LineNum, obp, cp ) );
+		}
+		else
+		{
+			//jmp ...
+			compiler.codeGenerator.op_jmp( i-obp, sizeof(long), false, true );
+		}
 	}
 }
@@ -1126,6 +1120,4 @@
 void OpcodeGosub(char *Parameter){
 	extern HANDLE hHeap;
-	extern GOTOLABELSCHEDULE *pGotoLabelSchedule;
-	extern int GotoLabelScheduleNum;
 	int i,LineNum;
 
@@ -1133,16 +1125,14 @@
 		i=GetLabelAddress(Parameter+1,0);
 
-		//call ...
-		OpBuffer[obp++]=(char)0xE8;
-		if(i==-1){
-			pGotoLabelSchedule=(GOTOLABELSCHEDULE *)HeapReAlloc(hHeap,0,pGotoLabelSchedule,(GotoLabelScheduleNum+1)*sizeof(GOTOLABELSCHEDULE));
-			pGotoLabelSchedule[GotoLabelScheduleNum].pName=(char *)HeapAlloc(hHeap,0,lstrlen(Parameter+1)+1);
-			lstrcpy(pGotoLabelSchedule[GotoLabelScheduleNum].pName,Parameter+1);
-			pGotoLabelSchedule[GotoLabelScheduleNum].pos=obp;
-			pGotoLabelSchedule[GotoLabelScheduleNum].now_cp=cp;
-			GotoLabelScheduleNum++;
-		}
-		*((long *)(OpBuffer+obp))=i-(obp+sizeof(long));
-		obp+=sizeof(long);
+		if( i == -1 )
+		{
+			//jmp ...(schedule)
+			compiler.codeGenerator.op_jmp_goto_schedule( GotoLabelSchedule( (const std::string)(Parameter + 1), obp, cp ) );
+		}
+		else
+		{
+			//jmp ...
+			compiler.codeGenerator.op_jmp( i-obp, sizeof(long), false, true );
+		}
 	}
 	else{
@@ -1150,16 +1140,14 @@
 		i=GetLabelAddress(0,LineNum);
 
-		//call ...
-		OpBuffer[obp++]=(char)0xE8;
-		if(i==-1){
-			pGotoLabelSchedule=(GOTOLABELSCHEDULE *)HeapReAlloc(hHeap,0,pGotoLabelSchedule,(GotoLabelScheduleNum+1)*sizeof(GOTOLABELSCHEDULE));
-			pGotoLabelSchedule[GotoLabelScheduleNum].pName=0;
-			pGotoLabelSchedule[GotoLabelScheduleNum].line=LineNum;
-			pGotoLabelSchedule[GotoLabelScheduleNum].pos=obp;
-			pGotoLabelSchedule[GotoLabelScheduleNum].now_cp=cp;
-			GotoLabelScheduleNum++;
-		}
-		*((long *)(OpBuffer+obp))=i-(obp+sizeof(long));
-		obp+=sizeof(long);
+		if( i == -1 )
+		{
+			//jmp ...(schedule)
+			compiler.codeGenerator.op_jmp_goto_schedule( GotoLabelSchedule( LineNum, obp, cp ) );
+		}
+		else
+		{
+			//jmp ...
+			compiler.codeGenerator.op_jmp( i-obp, sizeof(long), false, true );
+		}
 	}
 }
Index: /trunk/abdev/BasicCompiler32/MakePeHdr.cpp
===================================================================
--- /trunk/abdev/BasicCompiler32/MakePeHdr.cpp	(revision 245)
+++ /trunk/abdev/BasicCompiler32/MakePeHdr.cpp	(revision 246)
@@ -422,8 +422,5 @@
 
 		//Gotoラベルスケジュール
-		extern GOTOLABELSCHEDULE *pGotoLabelSchedule;
-		extern int GotoLabelScheduleNum;
-		pGotoLabelSchedule=(GOTOLABELSCHEDULE *)HeapAlloc(hHeap,0,1);
-		GotoLabelScheduleNum=0;
+		compiler.codeGenerator.gotoLabelSchedules.clear();
 
 		//With情報のメモリを確保
@@ -473,16 +470,15 @@
 		HeapDefaultFree(pLabelNames);
 
-		//Goto未知ラベルスケジュールを解放
-		for(i=0;i<GotoLabelScheduleNum;i++){
-			if(pGotoLabelSchedule[i].pName){
-				SetError(6,pGotoLabelSchedule[i].pName,pGotoLabelSchedule[i].now_cp);
-				HeapDefaultFree(pGotoLabelSchedule[i].pName);
+		//Goto未知ラベルスケジュールが存在したらエラーにする
+		BOOST_FOREACH( const GotoLabelSchedule &gotoLabelSchedule, compiler.codeGenerator.gotoLabelSchedules )
+		{
+			if(gotoLabelSchedule.GetName().size()>0){
+				SetError(6,gotoLabelSchedule.GetName(),gotoLabelSchedule.GetSourceCodePos());
 			}
 			else{
-				sprintf(temporary,"%d",pGotoLabelSchedule[i].line);
-				SetError(6,temporary,pGotoLabelSchedule[i].now_cp);
+				sprintf(temporary,"%d",gotoLabelSchedule.GetLineNum());
+				SetError(6,temporary,gotoLabelSchedule.GetSourceCodePos());
 			}
 		}
-		HeapDefaultFree(pGotoLabelSchedule);
 
 
Index: /trunk/abdev/BasicCompiler32/Opcode.h
===================================================================
--- /trunk/abdev/BasicCompiler32/Opcode.h	(revision 245)
+++ /trunk/abdev/BasicCompiler32/Opcode.h	(revision 246)
@@ -27,12 +27,4 @@
 	int line;
 	DWORD address;
-};
-
-//Goto未知ラベル
-struct GOTOLABELSCHEDULE{
-	char *pName;
-	int line;
-	DWORD pos;
-	DWORD now_cp;
 };
 
Index: /trunk/abdev/BasicCompiler_Common/Compile.cpp
===================================================================
--- /trunk/abdev/BasicCompiler_Common/Compile.cpp	(revision 245)
+++ /trunk/abdev/BasicCompiler_Common/Compile.cpp	(revision 246)
@@ -32,8 +32,4 @@
 DWORD *pExitSubSchedule;
 int ExitSubScheduleNum;
-
-//Goto未知ラベル スケジュール
-GOTOLABELSCHEDULE *pGotoLabelSchedule;
-int GotoLabelScheduleNum;
 
 //グローバル変数初期バッファ
@@ -123,5 +119,4 @@
 void ChangeOpcode(char *Command){
 	extern HANDLE hHeap;
-	int i,i2;
 
 	if(Command[0]=='\0')
@@ -141,19 +136,17 @@
 
 		//書き込みスケジュール
-		for(i=0;i<GotoLabelScheduleNum;i++){
-			if(lstrcmp(pGotoLabelSchedule[i].pName,Command+1)==0){
-				*((long *)(OpBuffer+pGotoLabelSchedule[i].pos))=obp-(pGotoLabelSchedule[i].pos+sizeof(long));
-
-				HeapDefaultFree(pGotoLabelSchedule[i].pName);
-
+		std::vector<GotoLabelSchedule>::iterator it = compiler.codeGenerator.gotoLabelSchedules.begin();
+		while( it != compiler.codeGenerator.gotoLabelSchedules.end() )
+		{
+			if( it->GetName() == Command+1 )
+			{
+				*((long *)( OpBuffer + it->GetNativeCodePos() ))=obp-(it->GetNativeCodePos()+sizeof(long));
+				
 				//詰める
-				GotoLabelScheduleNum--;
-				for(i2=i;i2<GotoLabelScheduleNum;i2++){
-					pGotoLabelSchedule[i2].pName=pGotoLabelSchedule[i2+1].pName;
-					pGotoLabelSchedule[i2].line=pGotoLabelSchedule[i2+1].line;
-					pGotoLabelSchedule[i2].pos=pGotoLabelSchedule[i2+1].pos;
-				}
-				i--;
-				continue;
+				it = compiler.codeGenerator.gotoLabelSchedules.erase( it );
+			}
+			else
+			{
+				it++;
 			}
 		}
@@ -552,17 +545,17 @@
 
 				//書き込みスケジュール
-				for(i=0;i<GotoLabelScheduleNum;i++){
-					if(pGotoLabelSchedule[i].pName==0&&
-						pGotoLabelSchedule[i].line==i3){
-						*((long *)(OpBuffer+pGotoLabelSchedule[i].pos))=obp-(pGotoLabelSchedule[i].pos+sizeof(long));
-
+				std::vector<GotoLabelSchedule>::iterator it = compiler.codeGenerator.gotoLabelSchedules.begin();
+				while( it != compiler.codeGenerator.gotoLabelSchedules.end() )
+				{
+					if( it->GetName().size() == 0 && it->GetLineNum() == i3 )
+					{
+						*((long *)( OpBuffer + it->GetNativeCodePos() ))=obp-(it->GetNativeCodePos()+sizeof(long));
+						
 						//詰める
-						GotoLabelScheduleNum--;
-						for(i2=i;i2<GotoLabelScheduleNum;i2++){
-							pGotoLabelSchedule[i2].pName=pGotoLabelSchedule[i2+1].pName;
-							pGotoLabelSchedule[i2].line=pGotoLabelSchedule[i2+1].line;
-							pGotoLabelSchedule[i2].pos=pGotoLabelSchedule[i2+1].pos;
-						}
-						i--;
+						it = compiler.codeGenerator.gotoLabelSchedules.erase( it );
+					}
+					else
+					{
+						it++;
 					}
 				}
Index: /trunk/abdev/BasicCompiler_Common/include/CodeGenerator.h
===================================================================
--- /trunk/abdev/BasicCompiler_Common/include/CodeGenerator.h	(revision 245)
+++ /trunk/abdev/BasicCompiler_Common/include/CodeGenerator.h	(revision 246)
@@ -12,4 +12,43 @@
 void ReallocNativeCodeBuffer();
 
+//Goto未知ラベル
+class GotoLabelSchedule
+{
+	std::string name;
+	int line;
+	int nativeCodePos;
+	int sourceCodePos;
+public:
+	GotoLabelSchedule( const std::string &name, int nativeCodePos, int sourceCodePos )
+		: name( name )
+		, line( -1 )
+		, nativeCodePos( nativeCodePos )
+		, sourceCodePos( sourceCodePos )
+	{
+	}
+	GotoLabelSchedule( int line, int nativeCodePos, int sourceCodePos )
+		: line( line )
+		, nativeCodePos( nativeCodePos )
+		, sourceCodePos( sourceCodePos )
+	{
+	}
+	const std::string &GetName() const
+	{
+		return name;
+	}
+	int GetLineNum() const
+	{
+		return line;
+	}
+	int GetNativeCodePos() const
+	{
+		return nativeCodePos;
+	}
+	int GetSourceCodePos() const
+	{
+		return sourceCodePos;
+	}
+};
+
 class CodeGenerator
 {
@@ -61,4 +100,7 @@
 
 public:
+
+	// Gotoスケジュールの管理
+	std::vector<GotoLabelSchedule> gotoLabelSchedules;
 
 	CodeGenerator()
@@ -141,4 +183,5 @@
 	const PertialSchedule *op_jmp( long offset, int op_size = sizeof(char), bool isPertialSchedule = false, bool isSelfOpcodeOffset = false );
 	void op_jmp_continue();
+	void op_jmp_goto_schedule( const GotoLabelSchedule &gotoLabelSchedule );
 
 
Index: /trunk/abdev/BasicCompiler_Common/src/CommonCodeGenerator.cpp
===================================================================
--- /trunk/abdev/BasicCompiler_Common/src/CommonCodeGenerator.cpp	(revision 245)
+++ /trunk/abdev/BasicCompiler_Common/src/CommonCodeGenerator.cpp	(revision 246)
@@ -202,2 +202,11 @@
 	op_jmp( GetContinueCodePosOld()-obp, sizeof(long), false, true );
 }
+void CodeGenerator::op_jmp_goto_schedule( const GotoLabelSchedule &gotoLabelSchedule )
+{
+	// オペコード
+	pNativeCode->Put( (char)0xE9 );
+
+	gotoLabelSchedules.push_back( gotoLabelSchedule );
+
+	pNativeCode->Put( (long)0 );
+}
