Index: trunk/abdev/BasicCompiler_Common/Compile.cpp
===================================================================
--- trunk/abdev/BasicCompiler_Common/Compile.cpp	(revision 252)
+++ trunk/abdev/BasicCompiler_Common/Compile.cpp	(revision 253)
@@ -88,4 +88,5 @@
 	extern LINEINFO *pLineInfo;
 	if(MaxLineInfoNum){
+		extern int obp;
 		if(pLineInfo[MaxLineInfoNum-1].TopObp==obp){
 			pLineInfo[MaxLineInfoNum-1].TopCp=cp;
@@ -95,4 +96,5 @@
 	pLineInfo=(LINEINFO *)HeapReAlloc(hHeap,0,pLineInfo,(MaxLineInfoNum+1)*sizeof(LINEINFO));
 	pLineInfo[MaxLineInfoNum].TopCp=cp;
+	extern int obp;
 	pLineInfo[MaxLineInfoNum].TopObp=obp;
 
@@ -123,14 +125,15 @@
 		pLabelNames[MaxLabelNum].pName=(char *)HeapAlloc(hHeap,0,lstrlen(Command+1)+1);
 		lstrcpy(pLabelNames[MaxLabelNum].pName,Command+1);
+		extern int obp;
 		pLabelNames[MaxLabelNum].address=obp;
 		MaxLabelNum++;
 
 		//書き込みスケジュール
-		std::vector<GotoLabelSchedule>::iterator it = compiler.codeGenerator.gotoLabelSchedules.begin();
+		GotoLabelSchedules::iterator it = compiler.codeGenerator.gotoLabelSchedules.begin();
 		while( it != compiler.codeGenerator.gotoLabelSchedules.end() )
 		{
-			if( it->GetName() == Command+1 )
+			if( (*it)->GetName() == Command+1 )
 			{
-				*((long *)( OpBuffer + it->GetNativeCodePos() ))=obp-(it->GetNativeCodePos()+sizeof(long));
+				compiler.codeGenerator.opfix_JmpPertialSchedule( (*it) );
 				
 				//詰める
@@ -335,7 +338,13 @@
 			extern BOOL bDebugCompile;
 			//int 3
-			if(bDebugCompile) OpBuffer[obp++]=(char)0xCC;
+			if(bDebugCompile)
+			{
+				breakpoint;
+			}
 #if defined(_DEBUG)
-			else OpBuffer[obp++]=(char)0xCC;
+			else
+			{
+				breakpoint;
+			}
 #endif
 			break;
@@ -532,15 +541,16 @@
 				pLabelNames[MaxLabelNum].pName=0;
 				pLabelNames[MaxLabelNum].line=i3;
+				extern int obp;
 				pLabelNames[MaxLabelNum].address=obp;
 				MaxLabelNum++;
 
 				//書き込みスケジュール
-				std::vector<GotoLabelSchedule>::iterator it = compiler.codeGenerator.gotoLabelSchedules.begin();
+				GotoLabelSchedules::iterator it = compiler.codeGenerator.gotoLabelSchedules.begin();
 				while( it != compiler.codeGenerator.gotoLabelSchedules.end() )
 				{
-					if( it->GetName().size() == 0 && it->GetLineNum() == i3 )
+					if( (*it)->GetName().size() == 0 && (*it)->GetLineNum() == i3 )
 					{
-						*((long *)( OpBuffer + it->GetNativeCodePos() ))=obp-(it->GetNativeCodePos()+sizeof(long));
-						
+						compiler.codeGenerator.opfix_JmpPertialSchedule( (*it) );
+
 						//詰める
 						it = compiler.codeGenerator.gotoLabelSchedules.erase( it );
Index: trunk/abdev/BasicCompiler_Common/PESchedule.cpp
===================================================================
--- trunk/abdev/BasicCompiler_Common/PESchedule.cpp	(revision 252)
+++ trunk/abdev/BasicCompiler_Common/PESchedule.cpp	(revision 253)
@@ -154,4 +154,5 @@
 void CSchedule::add(){
 	pObpValues=(int *)HeapReAlloc(hHeap,0,pObpValues,(num+1)*sizeof(int));
+	extern int obp;
 	pObpValues[num]=obp;
 	num++;
@@ -227,4 +228,5 @@
 	if(!bCall){
 		//リロケーション情報を追加する
+		extern int obp;
 		pobj_Reloc->AddSchedule_CodeSection(obp);
 	}
Index: trunk/abdev/BasicCompiler_Common/include/CodeGenerator.h
===================================================================
--- trunk/abdev/BasicCompiler_Common/include/CodeGenerator.h	(revision 252)
+++ trunk/abdev/BasicCompiler_Common/include/CodeGenerator.h	(revision 253)
@@ -12,43 +12,4 @@
 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 PertialSchedule
@@ -85,4 +46,39 @@
 typedef std::vector<const PertialSchedule *> PertialSchedules;
 
+//Goto未知ラベル
+class GotoLabelSchedule : public PertialSchedule
+{
+	std::string name;
+	int line;
+	int sourceCodePos;
+public:
+	GotoLabelSchedule( const std::string &name, int nativeCodePos, int sourceCodePos )
+		: PertialSchedule( nativeCodePos, sizeof(long) )
+		, name( name )
+		, line( -1 )
+		, sourceCodePos( sourceCodePos )
+	{
+	}
+	GotoLabelSchedule( int line, int nativeCodePos, int sourceCodePos )
+		: PertialSchedule( nativeCodePos, sizeof(long) )
+		, line( line )
+		, sourceCodePos( sourceCodePos )
+	{
+	}
+	const std::string &GetName() const
+	{
+		return name;
+	}
+	int GetLineNum() const
+	{
+		return line;
+	}
+	int GetSourceCodePos() const
+	{
+		return sourceCodePos;
+	}
+};
+typedef std::vector<const GotoLabelSchedule *> GotoLabelSchedules;
+
 class LexicalScope
 {
@@ -186,4 +182,7 @@
 public:
 
+	// ローカル変数用スケジュールの管理
+	PertialSchedules localVarPertialSchedules;
+
 	// Exit Subスケジュールの管理
 	std::vector<long> exitSubCodePositions;
@@ -191,5 +190,5 @@
 
 	// Gotoスケジュールの管理
-	std::vector<GotoLabelSchedule> gotoLabelSchedules;
+	GotoLabelSchedules gotoLabelSchedules;
 
 	// レキシカルスコープの管理
@@ -256,4 +255,5 @@
 
 	void opfix( const PertialSchedule *pPertialSchedule, long newValue );
+	void opfix_offset( const PertialSchedule *pPertialSchedule, long offset );
 	void opfix_JmpPertialSchedule( const PertialSchedule *pPertialSchedule );
 
@@ -279,5 +279,5 @@
 	void op_jmp_continue();
 	void op_jmp_exitsub();
-	void op_jmp_goto_schedule( const GotoLabelSchedule &gotoLabelSchedule );
+	void op_jmp_goto_schedule( const std::string &name, int lineNum, int sourceCodePos );
 
 
@@ -370,21 +370,21 @@
 	const PertialSchedule *__op_format(char op_prefix,char opcode1,char opcode2,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
 public:
-	void op_mov_MV			( int op_size, int base_reg, long offset, Schedule::Type offsetScheduleType, long value, Schedule::Type valueScheduleType = Schedule::None );
-	void op_mov_RV			(int reg,long offset, Schedule::Type scheduleType = Schedule::None );
-	void op_mov_RR			(int reg1,int reg2);
-	void op_mov_RM			(int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None );
-	void op_mov_RM_ex		(int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType = Schedule::None );
-	void op_mov_MR			(int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None );
-	void op_mov_MR_ex		(int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType = Schedule::None );
-	void op_movsx_R32R16	(int reg32,int reg16 = REG_NON);
-	void op_movsx_R32R8		(int reg32,int reg8 = REG_NON);
-	void op_movsx_R16R8		(int reg16,int reg8 = REG_NON);
-	void op_lea_RM			( int reg, int base_reg, long offset, char mod, Schedule::Type scheduleType = Schedule::None );
-	void op_inc				(int reg);
-	void op_dec				(int reg);
-	void op_add_RV8			(int reg,char cValue);
-	void op_add_RV			( int reg, long offset, Schedule::Type scheduleType = Schedule::None );
-	void op_add_RR			( int reg1, int reg2 );
-	void op_add_RM			(int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None );
+	const PertialSchedule *op_mov_MV		( int op_size, int base_reg, long offset, Schedule::Type offsetScheduleType, bool isPertialSchedule, long value, Schedule::Type valueScheduleType = Schedule::None );
+	void op_mov_RV							( int reg,long offset, Schedule::Type scheduleType = Schedule::None );
+	void op_mov_RR							( int reg1,int reg2);
+	const PertialSchedule *op_mov_RM		( int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
+	const PertialSchedule *op_mov_RM_ex		( int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
+	const PertialSchedule *op_mov_MR		( int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
+	const PertialSchedule *op_mov_MR_ex		( int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
+	void op_movsx_R32R16					( int reg32,int reg16 = REG_NON);
+	void op_movsx_R32R8						( int reg32,int reg8 = REG_NON);
+	void op_movsx_R16R8						( int reg16,int reg8 = REG_NON);
+	const PertialSchedule *op_lea_RM		( int reg, int base_reg, long offset, char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
+	void op_inc								(int reg);
+	void op_dec								(int reg);
+	void op_add_RV8							(int reg,char cValue);
+	const PertialSchedule *op_add_RV		( int reg, long offset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
+	void op_add_RR							( int reg1, int reg2 );
+	const PertialSchedule *op_add_RM		(int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
 	void op_adc_RV8			(int reg,char cValue);
 	void op_adc_RR			( int reg1, int reg2 );
@@ -413,5 +413,5 @@
 	void op_pop(int reg = REG_NON);
 	void op_add_esp(long num);
-	void op_sub_esp(long num);
+	const PertialSchedule *op_sub_esp( long num, bool isPertialSchedule = false );
 	void op_cmp_RR( int reg1, int reg2 );
 	void op_cmp_value(int op_size,int reg,char byte_data);
@@ -421,9 +421,9 @@
 	void op_fld_ptr_esp(int type);
 	void op_fld_basereg			(int type,int base_reg);
-	void op_fld_base_offset		(int type,int base_reg,long offset, Schedule::Type scheduleType = Schedule::None );
-	void op_fld_base_offset_ex	(int type,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType = Schedule::None);
+	const PertialSchedule *op_fld_base_offset		(int type,int base_reg,long offset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
+	const PertialSchedule *op_fld_base_offset_ex	(int type,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
 	void op_fstp_basereg		(int type,int base_reg);
-	void op_fstp_base_offset	(int type,int base_reg,long offset, Schedule::Type scheduleType = Schedule::None);
-	void op_fstp_base_offset_ex	(int type,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType = Schedule::None);
+	const PertialSchedule *op_fstp_base_offset		(int type,int base_reg,long offset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
+	const PertialSchedule *op_fstp_base_offset_ex	(int type,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
 	void op_fistp_ptr_esp		( int typeSize );
 	void op_fstp_push			( Type &type );
@@ -452,4 +452,8 @@
 		pNativeCode->Put( nativeCode );
 	}
+	void PutOld( char c )
+	{
+		pNativeCode->Put( c );
+	}
 	void PutOld( char c1, char c2 )
 	{
Index: trunk/abdev/BasicCompiler_Common/include/NativeCode.h
===================================================================
--- trunk/abdev/BasicCompiler_Common/include/NativeCode.h	(revision 252)
+++ trunk/abdev/BasicCompiler_Common/include/NativeCode.h	(revision 253)
@@ -7,5 +7,4 @@
 #include <BoostSerializationSupport.h>
 
-void AddLocalVarAddrSchedule();
 void ObpPlus( int step = 1 );
 
@@ -19,5 +18,4 @@
 		None = 10000,
 		GlobalVar,		// グローバル変数スケジュール
-		LocalVar,		// ローカル変数スケジュール
 		DataTable,		// データテーブル スケジュール
 		Relocation,		// リロケーション情報スケジュール
@@ -172,4 +170,14 @@
 	}
 
+	long GetLong( int codePos ) const
+	{
+		return *(long *)(this->codeBuffer+codePos);
+	}
+	long _GetLong_ObpOld( int _obpOld ) const
+	{
+		extern char *OpBuffer;
+		return *(long *)(OpBuffer+_obpOld);
+	}
+
 	void Overwrite( int codePos, char c )
 	{
@@ -236,7 +244,4 @@
 			pobj_GlobalVarSchedule->add();
 			break;
-		case Schedule::LocalVar:
-			AddLocalVarAddrSchedule();
-			break;
 		case Schedule::DataTable:
 			extern CSchedule *pobj_DataTableSchedule;
Index: trunk/abdev/BasicCompiler_Common/src/CommonCodeGenerator.cpp
===================================================================
--- trunk/abdev/BasicCompiler_Common/src/CommonCodeGenerator.cpp	(revision 252)
+++ trunk/abdev/BasicCompiler_Common/src/CommonCodeGenerator.cpp	(revision 253)
@@ -65,4 +65,50 @@
 
 			isSuccessful = true;
+			break;
+		}
+		else
+		{
+			it++;
+		}
+	}
+
+	if( isSuccessful == false )
+	{
+		SetError();
+	}
+}
+
+void CodeGenerator::opfix_offset( const PertialSchedule *pPertialSchedule, long offset )
+{
+	bool isSuccessful = false;
+
+	PertialSchedules::iterator it = pertialSchedules.begin();
+	while( it != pertialSchedules.end() )
+	{
+		if( (*it) == pPertialSchedule )
+		{
+			if( pPertialSchedule->GetTypeSize() == sizeof(long) )
+			{
+				pNativeCode->Overwrite(
+					pPertialSchedule->GetCodePos(),
+					pNativeCode->GetLong(pPertialSchedule->GetCodePos()) + offset
+				);
+
+				// TODO: 未完成（用が無くなったら消す）
+				pNativeCode->OverwriteOld(
+					pPertialSchedule->GetObpOld(),
+					pNativeCode->_GetLong_ObpOld(pPertialSchedule->GetObpOld()) + offset
+				);
+			}
+			else
+			{
+				SetError();
+			}
+
+			it = pertialSchedules.erase( it );
+			delete pPertialSchedule;
+
+			isSuccessful = true;
+			break;
 		}
 		else
@@ -280,10 +326,21 @@
 	pNativeCode->Put( (long)0 );
 }
-void CodeGenerator::op_jmp_goto_schedule( const GotoLabelSchedule &gotoLabelSchedule )
+void CodeGenerator::op_jmp_goto_schedule( const std::string &name, int lineNum, int sourceCodePos )
 {
 	// オペコード
 	pNativeCode->Put( (char)0xE9 );
 
-	gotoLabelSchedules.push_back( gotoLabelSchedule );
+	const GotoLabelSchedule *pGotoLabelSchedule = NULL;
+	if( name.size() == 0 )
+	{
+		pGotoLabelSchedule = new GotoLabelSchedule( name, pNativeCode->GetSize(), sourceCodePos );
+	}
+	else
+	{
+		pGotoLabelSchedule = new GotoLabelSchedule( name, pNativeCode->GetSize(), sourceCodePos );
+	}
+	gotoLabelSchedules.push_back( pGotoLabelSchedule );
+
+	pertialSchedules.push_back( pGotoLabelSchedule );
 
 	pNativeCode->Put( (long)0 );
Index: trunk/abdev/BasicCompiler_Common/src/LexicalScope.cpp
===================================================================
--- trunk/abdev/BasicCompiler_Common/src/LexicalScope.cpp	(revision 252)
+++ trunk/abdev/BasicCompiler_Common/src/LexicalScope.cpp	(revision 253)
@@ -136,5 +136,7 @@
 
 			//mov ecx,dword ptr[ebp+offset]
-			compiler.codeGenerator.op_mov_RM(sizeof(long),REG_ECX,REG_EBP,-pVar->GetOffsetAddress(),MOD_BASE_DISP32, Schedule::LocalVar );
+			compiler.codeGenerator.localVarPertialSchedules.push_back(
+				compiler.codeGenerator.op_mov_RM(sizeof(long),REG_ECX,REG_EBP,-pVar->GetOffsetAddress(),MOD_BASE_DISP32, Schedule::None, true )
+			);
 
 			//push ecx
