Index: trunk/abdev/BasicCompiler64/BasicCompiler.vcproj
===================================================================
--- trunk/abdev/BasicCompiler64/BasicCompiler.vcproj	(revision 243)
+++ trunk/abdev/BasicCompiler64/BasicCompiler.vcproj	(revision 254)
@@ -317,5 +317,5 @@
 				</File>
 				<File
-					RelativePath="..\BasicCompiler_Common\include\LexicalScopingImpl.h"
+					RelativePath="..\BasicCompiler_Common\include\LexicalScope.h"
 					>
 				</File>
@@ -1124,5 +1124,5 @@
 					</File>
 					<File
-						RelativePath="..\BasicCompiler_Common\src\LexicalScopingImpl.cpp"
+						RelativePath="..\BasicCompiler_Common\src\LexicalScope.cpp"
 						>
 					</File>
Index: trunk/abdev/BasicCompiler64/CodeGenerator.cpp
===================================================================
--- trunk/abdev/BasicCompiler64/CodeGenerator.cpp	(revision 243)
+++ trunk/abdev/BasicCompiler64/CodeGenerator.cpp	(revision 254)
@@ -79,5 +79,8 @@
 #define INDEX_NON	0x04
 
-void CodeGenerator::set_mod_rm_sib_disp(char mod,int reg,int scale,int index_reg,int base_reg,long disp, Schedule::Type scheduleType ){
+const PertialSchedule *CodeGenerator::set_mod_rm_sib_disp(char mod,int reg,int scale,int index_reg,int base_reg,long disp, Schedule::Type scheduleType, bool isPertialSchedule )
+{
+	const PertialSchedule *pPertialSchedule = NULL;
+
 	if(mod==MOD_DISP32){
 		//ModR/Mバイト
@@ -94,5 +97,5 @@
 
 	//レジスタモードの場合は、ここで終了
-	if(mod==MOD_REG) return;
+	if(mod==MOD_REG) return pPertialSchedule;
 
 
@@ -106,5 +109,5 @@
 
 	//ディスプレースメントを必要としない場合は、ここで終了
-	if(mod==MOD_BASE) return;
+	if(mod==MOD_BASE) return pPertialSchedule;
 
 
@@ -113,13 +116,25 @@
 	//////////////////////////
 
-	if(mod==MOD_BASE_DISP8) pNativeCode->Put( (char)disp );
-	else{
+	if(mod==MOD_BASE_DISP8)
+	{
+		pNativeCode->Put( (char)disp );
+	}
+	else
+	{
+		if( isPertialSchedule )
+		{
+			pertialSchedules.push_back( new PertialSchedule( pNativeCode->GetSize(), sizeof(long) ) );
+			pPertialSchedule = pertialSchedules.back();
+		}
+
 		pNativeCode->Put( disp, scheduleType );
 	}
-}
-
-
-
-void CodeGenerator::__op_format(int op_size,char op_prefix,char opcode1,char opcode2,int reg,int base_reg,long offset,char mod, Schedule::Type scheduleType ){
+
+	return pPertialSchedule;
+}
+
+
+
+const PertialSchedule *CodeGenerator::__op_format(int op_size,char op_prefix,char opcode1,char opcode2,int reg,int base_reg,long offset,char mod, Schedule::Type scheduleType, bool isPertialSchedule ){
 	//命令プリフィックス
 	if(op_prefix) pNativeCode->Put( op_prefix );
@@ -133,5 +148,5 @@
 
 	//ModR/M, SIB, disp
-	set_mod_rm_sib_disp(mod,reg,SCALE_NON,INDEX_NON,base_reg,offset, scheduleType );
+	return set_mod_rm_sib_disp(mod,reg,SCALE_NON,INDEX_NON,base_reg,offset, scheduleType, isPertialSchedule );
 }
 
@@ -175,5 +190,5 @@
 	pNativeCode->Put( i64data );
 }
-void CodeGenerator::op_mov_RM(int op_size,int reg,int base_reg,long offset,char mod, Schedule::Type scheduleType ){
+const PertialSchedule *CodeGenerator::op_mov_RM(int op_size,int reg,int base_reg,long offset,char mod, Schedule::Type scheduleType, bool isPertialSchedule ){
 	//mov reg64,qword ptr[base_reg+offset]
 	//mov reg32,dword ptr[base_reg+offset]
@@ -190,11 +205,12 @@
 	else opcode=(char)0x8B;
 
-	__op_format(op_size,op_prefix,opcode,0,reg,base_reg,offset,mod, scheduleType);
-}
-void CodeGenerator::op_mov_RM_ex(int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType ){
+	return __op_format(op_size,op_prefix,opcode,0,reg,base_reg,offset,mod, scheduleType, isPertialSchedule );
+}
+const PertialSchedule *CodeGenerator::op_mov_RM_ex(int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType, bool isPertialSchedule ){
 	//mov reg64,qword ptr[base_reg1+base_reg2+offset]
 	//mov reg32,dword ptr[base_reg1+base_reg2+offset]
 	//mov reg16,word ptr[base_reg1+base_reg2+offset]
 	//mov reg8,byte ptr[base_reg1+base_reg2+offset]
+	const PertialSchedule *pPertialSchedule = NULL;
 
 	if(base_reg1==REG_RSP){
@@ -226,4 +242,9 @@
 
 		//オフセット値
+		if( isPertialSchedule )
+		{
+			pertialSchedules.push_back( new PertialSchedule( pNativeCode->GetSize(), sizeof(long) ) );
+			pPertialSchedule = pertialSchedules.back();
+		}
 		pNativeCode->Put( offset, scheduleType );
 	}
@@ -239,6 +260,8 @@
 		pNativeCode->Put( (char)(REGISTER_OPERAND(base_reg1)<<3 | REGISTER_OPERAND(base_reg2)) );
 	}
-}
-void CodeGenerator::op_mov_MR(int op_size,int reg,int base_reg,long offset,char mod, Schedule::Type scheduleType ){
+
+	return pPertialSchedule;
+}
+const PertialSchedule *CodeGenerator::op_mov_MR(int op_size,int reg,int base_reg,long offset,char mod, Schedule::Type scheduleType, bool isPertialSchedule ){
 	//mov qword ptr[base_reg+offset],reg64
 	//mov dword ptr[base_reg+offset],reg32
@@ -255,11 +278,12 @@
 	else opcode=(char)0x89;
 
-	__op_format(op_size,op_prefix,opcode,0,reg,base_reg,offset,mod, scheduleType );
-}
-void CodeGenerator::op_mov_MR_ex(int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType ){
+	return __op_format(op_size,op_prefix,opcode,0,reg,base_reg,offset,mod, scheduleType, isPertialSchedule );
+}
+const PertialSchedule *CodeGenerator::op_mov_MR_ex(int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType, bool isPertialSchedule ){
 	//mov qword ptr[base_reg1+base_reg2+offset],reg64
 	//mov dword ptr[base_reg1+base_reg2+offset],reg32
 	//mov word ptr[base_reg1+base_reg2+offset],reg16
 	//mov byte ptr[base_reg1+base_reg2+offset],reg8
+	const PertialSchedule *pPertialSchedule = NULL;
 
 	if(base_reg1==REG_RSP){
@@ -291,4 +315,9 @@
 
 		//オフセット値
+		if( isPertialSchedule )
+		{
+			pertialSchedules.push_back( new PertialSchedule( pNativeCode->GetSize(), sizeof(long) ) );
+			pPertialSchedule = pertialSchedules.back();
+		}
 		pNativeCode->Put( offset, scheduleType );
 	}
@@ -304,9 +333,12 @@
 		pNativeCode->Put( (char)(REGISTER_OPERAND(base_reg1)<<3 | REGISTER_OPERAND(base_reg2)) );
 	}
-}
-
-void CodeGenerator::op_mov_MV(int op_size,int base_reg,int offset, Schedule::Type offsetScheduleType, BOOL bUseOffset,long i32data){
+
+	return pPertialSchedule;
+}
+
+const PertialSchedule *CodeGenerator::op_mov_MV(int op_size,int base_reg,int offset, Schedule::Type offsetScheduleType, bool isPertialSchedule, BOOL bUseOffset,long i32data){
 	//mov ptr[base_reg+offset],i32data
 	//mov ptr[base_reg       ],i32data
+	const PertialSchedule *pPertialSchedule = NULL;
 
 	//16ビット演算のプリフィックス
@@ -326,5 +358,5 @@
 
 		//ModR/M, SIB, disp
-		set_mod_rm_sib_disp(MOD_BASE_DISP32,0,SCALE_NON,INDEX_NON,base_reg,offset, offsetScheduleType );
+		pPertialSchedule = set_mod_rm_sib_disp(MOD_BASE_DISP32,0,SCALE_NON,INDEX_NON,base_reg,offset, offsetScheduleType, isPertialSchedule );
 	}
 	else{
@@ -346,4 +378,6 @@
 		pNativeCode->Put( (char)i32data );
 	}
+
+	return pPertialSchedule;
 }
 
@@ -561,5 +595,5 @@
 /////////////////////
 
-void CodeGenerator::op_add_RM(int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType ){
+const PertialSchedule *CodeGenerator::op_add_RM(int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType, bool isPertialSchedule ){
 	//add reg64,qword ptr[base_reg+offset]
 	//add reg32,dword ptr[base_reg+offset]
@@ -576,9 +610,11 @@
 	else opcode=(char)0x03;
 
-	__op_format(op_size,op_prefix,opcode,0,reg,base_reg,offset,mod, scheduleType );
-}
-
-void CodeGenerator::op_add_RV(int reg,long offset, Schedule::Type scheduleType ){
+	return __op_format(op_size,op_prefix,opcode,0,reg,base_reg,offset,mod, scheduleType, isPertialSchedule );
+}
+
+const PertialSchedule *CodeGenerator::op_add_RV(int reg,long offset, Schedule::Type scheduleType, bool isPertialSchedule ){
 	//add reg,offset
+	const PertialSchedule *pPertialSchedule = NULL;
+
 	char RexByte=-1;
 
@@ -594,5 +630,4 @@
 		pNativeCode->Put( (char)RexByte );
 		pNativeCode->Put( (char)0x05 );
-		pNativeCode->Put( offset, scheduleType );
 	}
 	else{
@@ -603,6 +638,14 @@
 		pNativeCode->Put( (char)0x81 );
 		pNativeCode->Put( (char)(0xC0| REGISTER_OPERAND(reg)) );
-		pNativeCode->Put( offset, scheduleType );
-	}
+	}
+
+	if( isPertialSchedule )
+	{
+		pertialSchedules.push_back( new PertialSchedule( pNativeCode->GetSize(), sizeof(long) ) );
+		pPertialSchedule = pertialSchedules.back();
+	}
+	pNativeCode->Put( offset, scheduleType );
+
+	return pPertialSchedule;
 }
 void CodeGenerator::op_add_RR(int reg1,int reg2){
@@ -1303,11 +1346,11 @@
 ////////////////////
 
-void CodeGenerator::op_movlpd_MR(int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType ){
+const PertialSchedule *CodeGenerator::op_movlpd_MR(int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType, bool isPertialSchedule ){
 	//movlpd qword ptr[base_reg+offset],xmm_reg
-	__op_format(0,(char)0x66,(char)0x0F,(char)0x13,xmm_reg,base_reg,offset,mod, scheduleType );
-}
-void CodeGenerator::op_movlpd_RM(int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType ){
+	return __op_format(0,(char)0x66,(char)0x0F,(char)0x13,xmm_reg,base_reg,offset,mod, scheduleType, isPertialSchedule );
+}
+const PertialSchedule *CodeGenerator::op_movlpd_RM(int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType, bool isPertialSchedule ){
 	//movlpd xmm_reg,qword ptr[base_reg+offset]
-	__op_format(0,(char)0x66,(char)0x0F,(char)0x12,xmm_reg,base_reg,offset,mod, scheduleType );
+	return __op_format(0,(char)0x66,(char)0x0F,(char)0x12,xmm_reg,base_reg,offset,mod, scheduleType, isPertialSchedule );
 }
 void CodeGenerator::op_movsd_RR(int xmm_reg1,int xmm_reg2){
@@ -1317,8 +1360,8 @@
 	__op_format(0,(char)0xF2,(char)0x0F,(char)0x10,xmm_reg1,xmm_reg2,0,MOD_REG);
 }
-void CodeGenerator::op_movsd_MR(int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType ){
+const PertialSchedule *CodeGenerator::op_movsd_MR(int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType, bool isPertialSchedule ){
 	//movsd qword ptr[reg+offset],xmm_reg
 	//movsd qword ptr[reg],xmm_reg
-	__op_format(0,(char)0xF2,(char)0x0F,(char)0x11,xmm_reg,base_reg,offset,mod, scheduleType );
+	return __op_format(0,(char)0xF2,(char)0x0F,(char)0x11,xmm_reg,base_reg,offset,mod, scheduleType, isPertialSchedule );
 }
 void CodeGenerator::op_movss_RR(int xmm_reg1,int xmm_reg2){
@@ -1328,12 +1371,12 @@
 	__op_format(0,(char)0xF3,(char)0x0F,(char)0x10,xmm_reg1,xmm_reg2,0,MOD_REG);
 }
-void CodeGenerator::op_movss_RM(int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType ){
+const PertialSchedule *CodeGenerator::op_movss_RM(int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType, bool isPertialSchedule ){
 	//movss xmm_reg,dword ptr[base_reg+offset]
-	__op_format(0,(char)0xF3,(char)0x0F,(char)0x10,xmm_reg,base_reg,offset,mod, scheduleType );
-}
-void CodeGenerator::op_movss_MR(int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType ){
+	return __op_format(0,(char)0xF3,(char)0x0F,(char)0x10,xmm_reg,base_reg,offset,mod, scheduleType, isPertialSchedule );
+}
+const PertialSchedule *CodeGenerator::op_movss_MR(int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType, bool isPertialSchedule ){
 	//movss dword ptr[reg+offset],xmm_reg
 	//movss dword ptr[reg],xmm_reg
-	__op_format(0,(char)0xF3,(char)0x0F,(char)0x11,xmm_reg,base_reg,offset,mod, scheduleType );
+	return __op_format(0,(char)0xF3,(char)0x0F,(char)0x11,xmm_reg,base_reg,offset,mod, scheduleType, isPertialSchedule );
 }
 
Index: trunk/abdev/BasicCompiler64/Compile_Calc_PushVar.cpp
===================================================================
--- trunk/abdev/BasicCompiler64/Compile_Calc_PushVar.cpp	(revision 243)
+++ trunk/abdev/BasicCompiler64/Compile_Calc_PushVar.cpp	(revision 254)
@@ -32,12 +32,13 @@
 				(char)0x1C
 			);
-			compiler.codeGenerator.PutOld(
-				(long)pRelativeVar->offset,
-				Schedule::LocalVar
+			compiler.codeGenerator.localVarPertialSchedules.push_back(
+				compiler.codeGenerator.PutOld( (long)pRelativeVar->offset, true )
 			);
 		}
 		else{
 			//movlpd xmm_reg,qword ptr[rsp+offset]
-			compiler.codeGenerator.op_movlpd_RM( xmm_reg, REG_RSP, (long)pRelativeVar->offset, MOD_BASE_DISP32, Schedule::LocalVar );
+			compiler.codeGenerator.localVarPertialSchedules.push_back(
+				compiler.codeGenerator.op_movlpd_RM( xmm_reg, REG_RSP, (long)pRelativeVar->offset, MOD_BASE_DISP32, Schedule::None, true )
+			);
 		}
 	}
@@ -45,9 +46,13 @@
 		if(pRelativeVar->bOffsetOffset){
 			//add r11,qword ptr[rsp+offset]
-			compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar );
+			compiler.codeGenerator.localVarPertialSchedules.push_back(
+				compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::None, true )
+			);
 		}
 		else{
 			//mov r11,qword ptr[rsp+offset]
-			compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar );
+			compiler.codeGenerator.localVarPertialSchedules.push_back(
+				compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::None, true )
+			);
 		}
 
@@ -85,12 +90,13 @@
 				(char)0x1C
 			);
-			compiler.codeGenerator.PutOld(
-				(long)pRelativeVar->offset,
-				Schedule::LocalVar
+			compiler.codeGenerator.localVarPertialSchedules.push_back(
+				compiler.codeGenerator.PutOld( (long)pRelativeVar->offset, true )
 			);
 		}
 		else{
 			//movss xmm_reg,dword ptr[rsp+offset]
-			compiler.codeGenerator.op_movss_RM( xmm_reg, REG_RSP, (long)pRelativeVar->offset, MOD_BASE_DISP32, Schedule::LocalVar );
+			compiler.codeGenerator.localVarPertialSchedules.push_back(
+				compiler.codeGenerator.op_movss_RM( xmm_reg, REG_RSP, (long)pRelativeVar->offset, MOD_BASE_DISP32, Schedule::None, true )
+			);
 		}
 	}
@@ -98,9 +104,13 @@
 		if(pRelativeVar->bOffsetOffset){
 			//add r11,qword ptr[rsp+offset]
-			compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar );
+			compiler.codeGenerator.localVarPertialSchedules.push_back(
+				compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::None, true )
+			);
 		}
 		else{
 			//mov r11,qword ptr[rsp+offset]
-			compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar );
+			compiler.codeGenerator.localVarPertialSchedules.push_back(
+				compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::None, true )
+			);
 		}
 
@@ -145,9 +155,13 @@
 		if(pRelativeVar->bOffsetOffset){
 			//mov reg, ptr[rsp+r11+offset]
-			compiler.codeGenerator.op_mov_RM_ex(varSize,reg,REG_RSP,REG_R11,(int)pRelativeVar->offset,USE_OFFSET, Schedule::LocalVar );
+			compiler.codeGenerator.localVarPertialSchedules.push_back(
+				compiler.codeGenerator.op_mov_RM_ex(varSize,reg,REG_RSP,REG_R11,(int)pRelativeVar->offset,USE_OFFSET, Schedule::None, true )
+			);
 		}
 		else{
 			//mov reg, ptr[rsp+offset]
-			compiler.codeGenerator.op_mov_RM(varSize,reg,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar );
+			compiler.codeGenerator.localVarPertialSchedules.push_back(
+				compiler.codeGenerator.op_mov_RM(varSize,reg,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::None, true )
+			);
 		}
 	}
@@ -155,9 +169,13 @@
 		if(pRelativeVar->bOffsetOffset){
 			//add r11,qword ptr[rsp+offset]
-			compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar );
+			compiler.codeGenerator.localVarPertialSchedules.push_back(
+				compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::None, true )
+			);
 		}
 		else{
 			//mov r11,qword ptr[rsp+offset]
-			compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar );
+			compiler.codeGenerator.localVarPertialSchedules.push_back(
+				compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::None, true )
+			);
 		}
 
Index: trunk/abdev/BasicCompiler64/Compile_CallProc.cpp
===================================================================
--- trunk/abdev/BasicCompiler64/Compile_CallProc.cpp	(revision 243)
+++ trunk/abdev/BasicCompiler64/Compile_CallProc.cpp	(revision 254)
@@ -7,8 +7,4 @@
 #include "../BasicCompiler_Common/common.h"
 #include "Opcode.h"
-
-//ローカル変数アドレススケジュール
-DWORD *pLocalVarAddrSchedule;
-int LocalVarAddrScheduleNum;
 
 void Call_DebugSys_SaveContext(){
@@ -27,14 +23,4 @@
 	compiler.codeGenerator.op_call(pSub_DebugSys_SaveContext);
 }
-
-void AddLocalVarAddrSchedule(){
-	extern HANDLE hHeap;
-
-	//ローカル変数アドレススケジュールに追加する
-	pLocalVarAddrSchedule=(DWORD *)HeapReAlloc(hHeap,0,pLocalVarAddrSchedule,(LocalVarAddrScheduleNum+1)*sizeof(DWORD));
-	pLocalVarAddrSchedule[LocalVarAddrScheduleNum]=obp;
-	LocalVarAddrScheduleNum++;
-}
-
 
 bool Opcode_CallProcPtr( const char *variable, const char *lpszParms,ProcPointer *pProcPointer){
Index: trunk/abdev/BasicCompiler64/Compile_Object.cpp
===================================================================
--- trunk/abdev/BasicCompiler64/Compile_Object.cpp	(revision 243)
+++ trunk/abdev/BasicCompiler64/Compile_Object.cpp	(revision 254)
@@ -173,5 +173,5 @@
 
 	//mov qword ptr[rax],typeSize（オブジェクトのサイズ）
-	compiler.codeGenerator.op_mov_MV(sizeof(_int64),REG_RAX,0, Schedule::None, NON_OFFSET,typeSize);
+	compiler.codeGenerator.op_mov_MV(sizeof(_int64),REG_RAX,0, Schedule::None, false, NON_OFFSET,typeSize);
 
 	//add rax,PTR_SIZE
Index: trunk/abdev/BasicCompiler64/Compile_ProcOp.cpp
===================================================================
--- trunk/abdev/BasicCompiler64/Compile_ProcOp.cpp	(revision 243)
+++ trunk/abdev/BasicCompiler64/Compile_ProcOp.cpp	(revision 254)
@@ -6,5 +6,4 @@
 #include <Program.h>
 #include <Compiler.h>
-#include <LexicalScopingImpl.h>
 #include <Class.h>
 
@@ -116,5 +115,5 @@
 		UserProc::CompileStartForGlobalArea();
 
-		GetLexicalScopes().CallDestructorsOfScopeEnd();
+		compiler.codeGenerator.lexicalScopes.CallDestructorsOfScopeEnd();
 
 		UserProc::CompileStartForUserProc( pBackUserProc );
@@ -308,8 +307,6 @@
 
 	//プロシージャ抜け出しスケジュール（Exit Sub/Function）
-	extern DWORD *pExitSubSchedule;
-	extern int ExitSubScheduleNum;
-	pExitSubSchedule=(DWORD *)HeapAlloc(hHeap,0,1);
-	ExitSubScheduleNum=0;
+	compiler.codeGenerator.exitSubCodePositions.clear();
+	compiler.codeGenerator._exitSubCodePositions_ObpOld.clear();
 
 	//ラベル用のメモリを確保
@@ -320,8 +317,5 @@
 
 	//Gotoラベルスケジュール
-	extern GOTOLABELSCHEDULE *pGotoLabelSchedule;
-	extern int GotoLabelScheduleNum;
-	pGotoLabelSchedule=(GOTOLABELSCHEDULE *)HeapAlloc(hHeap,0,1);
-	GotoLabelScheduleNum=0;
+	compiler.codeGenerator.gotoLabelSchedules.clear();
 
 	//With情報のメモリを確保
@@ -344,12 +338,6 @@
 	AllLocalVarSize=0;
 
-	//ローカル変数アドレススケジュール
-	extern DWORD *pLocalVarAddrSchedule;
-	extern int LocalVarAddrScheduleNum;
-	pLocalVarAddrSchedule=(DWORD *)HeapAlloc(hHeap,0,1);
-	LocalVarAddrScheduleNum=0;
-
 	//レキシカルスコープ情報を初期化
-	GetLexicalScopes().Init(obp);
+	compiler.codeGenerator.lexicalScopes.Init(obp);
 
 
@@ -386,6 +374,6 @@
 
 		//レキシカルスコープ情報
-		pVar->SetScopeLevel( GetLexicalScopes().GetNowLevel() );
-		pVar->SetScopeStartAddress( GetLexicalScopes().GetStartAddress() );
+		pVar->SetScopeLevel( compiler.codeGenerator.lexicalScopes.GetNowLevel() );
+		pVar->SetScopeStartAddress( compiler.codeGenerator.lexicalScopes.GetStartAddress() );
 		pVar->bLiving=TRUE;
 
@@ -661,17 +649,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++){
@@ -683,11 +658,8 @@
 
 	//ローカルオブジェクト（レキシカルスコープレベル=0）の解放処理
-	GetLexicalScopes().CallDestructorsOfScopeEnd();
+	compiler.codeGenerator.lexicalScopes.CallDestructorsOfScopeEnd();
 
 	//プロシージャ抜け出しスケジュール（Exit Sub/Function）
-	for(i3=0;i3<ExitSubScheduleNum;i3++){
-		*((long *)(OpBuffer+pExitSubSchedule[i3]))=obp-(pExitSubSchedule[i3]+sizeof(long));
-	}
-	HeapDefaultFree(pExitSubSchedule);
+	compiler.codeGenerator.ResolveExitSubSchedule();
 
 	if(bDebugCompile&&bDebugSupportProc==0){
@@ -739,8 +711,9 @@
 
 	//ローカル変数アドレススケジュール
-	for(i3=0;i3<LocalVarAddrScheduleNum;i3++){
-		*((long *)(OpBuffer+pLocalVarAddrSchedule[i3])) += AllLocalVarSize + stackFrameSize;
-	}
-	HeapDefaultFree(pLocalVarAddrSchedule);
+	BOOST_FOREACH( const PertialSchedule *pPertialSchedule, compiler.codeGenerator.localVarPertialSchedules )
+	{
+		compiler.codeGenerator.opfix_offset( pPertialSchedule, AllLocalVarSize );
+	}
+	compiler.codeGenerator.localVarPertialSchedules.clear();
 	BOOST_FOREACH( Variable *pVar, pUserProc->GetLocalVars() ){
 		//後にデバッグで利用する
Index: trunk/abdev/BasicCompiler64/Compile_Set_Var.cpp
===================================================================
--- trunk/abdev/BasicCompiler64/Compile_Set_Var.cpp	(revision 243)
+++ trunk/abdev/BasicCompiler64/Compile_Set_Var.cpp	(revision 254)
@@ -126,12 +126,13 @@
 				(char)0x1C
 			);
-			compiler.codeGenerator.PutOld(
-				(long)pRelative->offset,
-				Schedule::LocalVar
+			compiler.codeGenerator.localVarPertialSchedules.push_back(
+				compiler.codeGenerator.PutOld( (long)pRelative->offset, true )
 			);
 		}
 		else{
 			//movsd qword ptr[rsp+offset],xmm0
-			compiler.codeGenerator.op_movsd_MR( REG_XMM0, REG_RSP, (long)pRelative->offset, MOD_BASE_DISP32, Schedule::LocalVar );
+			compiler.codeGenerator.localVarPertialSchedules.push_back(
+				compiler.codeGenerator.op_movsd_MR( REG_XMM0, REG_RSP, (long)pRelative->offset, MOD_BASE_DISP32, Schedule::None, true )
+			);
 		}
 	}
@@ -139,9 +140,13 @@
 		if(pRelative->bOffsetOffset){
 			//add r11,qword ptr[rsp+offset]
-			compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelative->offset,MOD_BASE_DISP32, Schedule::LocalVar );
+			compiler.codeGenerator.localVarPertialSchedules.push_back(
+				compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelative->offset,MOD_BASE_DISP32, Schedule::None, true )
+			);
 		}
 		else{
 			//mov r11,qword ptr[rsp+offset]
-			compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelative->offset,MOD_BASE_DISP32, Schedule::LocalVar );
+			compiler.codeGenerator.localVarPertialSchedules.push_back(
+				compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelative->offset,MOD_BASE_DISP32, Schedule::None, true )
+			);
 		}
 
@@ -186,12 +191,13 @@
 				(char)0x1C
 			);
-			compiler.codeGenerator.PutOld(
-				(long)pRelative->offset,
-				Schedule::LocalVar
+			compiler.codeGenerator.localVarPertialSchedules.push_back(
+				compiler.codeGenerator.PutOld( (long)pRelative->offset, true )
 			);
 		}
 		else{
 			//movss dword ptr[rsp+offset],xmm0
-			compiler.codeGenerator.op_movss_MR( REG_XMM0, REG_RSP, (long)pRelative->offset, MOD_BASE_DISP32, Schedule::LocalVar );
+			compiler.codeGenerator.localVarPertialSchedules.push_back(
+				compiler.codeGenerator.op_movss_MR( REG_XMM0, REG_RSP, (long)pRelative->offset, MOD_BASE_DISP32, Schedule::None, true )
+			);
 		}
 	}
@@ -199,9 +205,13 @@
 		if(pRelative->bOffsetOffset){
 			//add r11,qword ptr[rsp+offset]
-			compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelative->offset,MOD_BASE_DISP32, Schedule::LocalVar );
+			compiler.codeGenerator.localVarPertialSchedules.push_back(
+				compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelative->offset,MOD_BASE_DISP32, Schedule::None, true )
+			);
 		}
 		else{
 			//mov r11,qword ptr[rsp+offset]
-			compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelative->offset,MOD_BASE_DISP32, Schedule::LocalVar );
+			compiler.codeGenerator.localVarPertialSchedules.push_back(
+				compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelative->offset,MOD_BASE_DISP32, Schedule::None, true )
+			);
 		}
 
@@ -302,9 +312,13 @@
 		if(pRelative->bOffsetOffset){
 			//mov ptr[rsp+r11+offset],rax/eax/ax/al
-			compiler.codeGenerator.op_mov_MR_ex(varSize,REG_RAX,REG_RSP,REG_R11,(int)pRelative->offset,USE_OFFSET, Schedule::LocalVar );
+			compiler.codeGenerator.localVarPertialSchedules.push_back(
+				compiler.codeGenerator.op_mov_MR_ex(varSize,REG_RAX,REG_RSP,REG_R11,(int)pRelative->offset,USE_OFFSET, Schedule::None, true )
+			);
 		}
 		else{
 			//mov ptr[rsp+offset],rax/eax/ax/al
-			compiler.codeGenerator.op_mov_MR(varSize,REG_RAX,REG_RSP,(int)pRelative->offset,MOD_BASE_DISP32, Schedule::LocalVar );
+			compiler.codeGenerator.localVarPertialSchedules.push_back(
+				compiler.codeGenerator.op_mov_MR(varSize,REG_RAX,REG_RSP,(int)pRelative->offset,MOD_BASE_DISP32, Schedule::None, true )
+			);
 		}
 	}
@@ -312,9 +326,13 @@
 		if(pRelative->bOffsetOffset){
 			//add r11,qword ptr[rsp+offset]
-			compiler.codeGenerator.op_add_RM( sizeof(_int64), REG_R11, REG_RSP, (int)pRelative->offset, MOD_BASE_DISP32, Schedule::LocalVar );
+			compiler.codeGenerator.localVarPertialSchedules.push_back(
+				compiler.codeGenerator.op_add_RM( sizeof(_int64), REG_R11, REG_RSP, (int)pRelative->offset, MOD_BASE_DISP32, Schedule::None, true )
+			);
 		}
 		else{
 			//mov r11,qword ptr[rsp+offset]
-			compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelative->offset,MOD_BASE_DISP32, Schedule::LocalVar );
+			compiler.codeGenerator.localVarPertialSchedules.push_back(
+				compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelative->offset,MOD_BASE_DISP32, Schedule::None, true )
+			);
 		}
 
Index: trunk/abdev/BasicCompiler64/Compile_Statement.cpp
===================================================================
--- trunk/abdev/BasicCompiler64/Compile_Statement.cpp	(revision 243)
+++ trunk/abdev/BasicCompiler64/Compile_Statement.cpp	(revision 254)
@@ -3,5 +3,4 @@
 #include <jenga/include/smoothie/LexicalAnalysis.h>
 
-#include <LexicalScopingImpl.h>
 #include <Compiler.h>
 
@@ -192,5 +191,5 @@
 
 	//je (endif、または else まで条件ジャンプ)
-	CodeGenerator::PertialSchedule *pIfPertialSchedule = compiler.codeGenerator.op_je( 0, sizeof(long), true );
+	const PertialSchedule *pIfPertialSchedule = compiler.codeGenerator.op_je( 0, sizeof(long), true );
 
 
@@ -200,15 +199,15 @@
 
 	//レキシカルスコープをレベルアップ
-	GetLexicalScopes().Start( obp, SCOPE_TYPE_IF );
+	compiler.codeGenerator.lexicalScopes.Start( obp, LexicalScope::SCOPE_TYPE_IF );
 
 	int i2=CompileBuffer(ESC_ENDIF,0);
 
 	//レキシカルスコープをレベルダウン
-	GetLexicalScopes().End();
+	compiler.codeGenerator.lexicalScopes.End();
 
 
 	if(i2==ESC_ELSE){
 		//jmp (endifまで)
-		CodeGenerator::PertialSchedule *pTempPertialSchedule = compiler.codeGenerator.op_jmp( 0, sizeof(long), true );
+		const PertialSchedule *pTempPertialSchedule = compiler.codeGenerator.op_jmp( 0, sizeof(long), true );
 
 		compiler.codeGenerator.opfix_JmpPertialSchedule( pIfPertialSchedule );
@@ -221,10 +220,10 @@
 
 		//レキシカルスコープをレベルアップ
-		GetLexicalScopes().Start( obp, SCOPE_TYPE_IF );
+		compiler.codeGenerator.lexicalScopes.Start( obp, LexicalScope::SCOPE_TYPE_IF );
 
 		CompileBuffer(ESC_ENDIF,0);
 
 		//レキシカルスコープをレベルダウン
-		GetLexicalScopes().End();
+		compiler.codeGenerator.lexicalScopes.End();
 
 
@@ -259,6 +258,4 @@
 void OpcodeGoto(char *Parameter){
 	extern HANDLE hHeap;
-	extern GOTOLABELSCHEDULE *pGotoLabelSchedule;
-	extern int GotoLabelScheduleNum;
 	int i,LineNum;
 
@@ -266,16 +263,16 @@
 		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)
+			extern int obp;
+			compiler.codeGenerator.op_jmp_goto_schedule( (const std::string)(Parameter + 1), 0, cp );
+		}
+		else
+		{
+			//jmp ...
+			extern int obp;
+			compiler.codeGenerator.op_jmp( i-obp, sizeof(long), false, true );
+		}
 	}
 	else{
@@ -283,16 +280,16 @@
 		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)
+			extern int obp;
+			compiler.codeGenerator.op_jmp_goto_schedule( "", LineNum, cp );
+		}
+		else
+		{
+			//jmp ...
+			extern int obp;
+			compiler.codeGenerator.op_jmp( i-obp, sizeof(long), false, true );
+		}
 	}
 }
@@ -309,13 +306,13 @@
 
 	//je (Wend まで)
-	CodeGenerator::PertialSchedule *pWhilePertialSchedule = compiler.codeGenerator.op_je( 0, sizeof(long), true );
+	const PertialSchedule *pWhilePertialSchedule = compiler.codeGenerator.op_je( 0, sizeof(long), true );
 
 	//レキシカルスコープをレベルアップ
-	GetLexicalScopes().Start( obp, SCOPE_TYPE_WHILE );
+	compiler.codeGenerator.lexicalScopes.Start( obp, LexicalScope::SCOPE_TYPE_WHILE );
 
 	//While内をコンパイル
 	CompileBuffer(0,COM_WEND);
 
-	GetLexicalScopes().CallDestructorsOfScopeEnd();
+	compiler.codeGenerator.lexicalScopes.CallDestructorsOfScopeEnd();
 
 	//jmp ...
@@ -323,5 +320,5 @@
 
 	//レキシカルスコープをレベルダウン
-	GetLexicalScopes().End();
+	compiler.codeGenerator.lexicalScopes.End();
 
 	compiler.codeGenerator.opfix_JmpPertialSchedule( pWhilePertialSchedule );
@@ -364,5 +361,5 @@
 
 	//jmp ...
-	CodeGenerator::PertialSchedule *pTempPertialSchedule = compiler.codeGenerator.op_jmp( 0, sizeof(long), true );
+	const PertialSchedule *pTempPertialSchedule = compiler.codeGenerator.op_jmp( 0, sizeof(long), true );
 
 	//Continueアドレスのバックアップとセット
@@ -407,5 +404,5 @@
 
 	//jmp [カウンタ減少の場合の判定を飛び越す]
-	CodeGenerator::PertialSchedule *pTempPertialSchedule2 = compiler.codeGenerator.op_jmp( 0, sizeof(long), true );
+	const PertialSchedule *pTempPertialSchedule2 = compiler.codeGenerator.op_jmp( 0, sizeof(long), true );
 
 	//jeジャンプ先のオフセット値
@@ -430,10 +427,10 @@
 
 	//レキシカルスコープをレベルアップ
-	GetLexicalScopes().Start( obp, SCOPE_TYPE_FOR );
+	compiler.codeGenerator.lexicalScopes.Start( obp, LexicalScope::SCOPE_TYPE_FOR );
 
 	//For内をコンパイル
 	CompileBuffer(0,COM_NEXT);
 
-	GetLexicalScopes().CallDestructorsOfScopeEnd();
+	compiler.codeGenerator.lexicalScopes.CallDestructorsOfScopeEnd();
 
 	if(szNextVariable[0]){
@@ -447,5 +444,5 @@
 
 	//レキシカルスコープをレベルダウン
-	GetLexicalScopes().End();
+	compiler.codeGenerator.lexicalScopes.End();
 
 	//jeジャンプ先のオフセット値
@@ -466,12 +463,12 @@
 
 	//レキシカルスコープをレベルアップ
-	GetLexicalScopes().Start( obp, SCOPE_TYPE_DO );
+	compiler.codeGenerator.lexicalScopes.Start( obp, LexicalScope::SCOPE_TYPE_DO );
 
 	//Do内をコンパイル
 	CompileBuffer(0,COM_LOOP);
 
-	GetLexicalScopes().CallDestructorsOfScopeEnd();
-
-	CodeGenerator::PertialSchedule *pDoPertialSchedule = NULL;
+	compiler.codeGenerator.lexicalScopes.CallDestructorsOfScopeEnd();
+
+	const PertialSchedule *pDoPertialSchedule = NULL;
 
 	extern char *basbuf;
@@ -522,8 +519,8 @@
 
 	//jmp ...
-	CodeGenerator::PertialSchedule *pTempPertialSchedule = compiler.codeGenerator.op_jmp( 0, sizeof(long), true );
+	const PertialSchedule *pTempPertialSchedule = compiler.codeGenerator.op_jmp( 0, sizeof(long), true );
 
 	//レキシカルスコープをレベルダウン
-	GetLexicalScopes().End();
+	compiler.codeGenerator.lexicalScopes.End();
 
 	//jmpジャンプ先のオフセット値
@@ -539,8 +536,4 @@
 
 void OpcodeExitSub(void){
-	extern DWORD *pExitSubSchedule;
-	extern int ExitSubScheduleNum;
-	extern HANDLE hHeap;
-
 	if( UserProc::IsGlobalAreaCompiling() ){
 		SetError(12,"Exit Sub/Function",cp);
@@ -549,45 +542,32 @@
 
 	//未解放のローカルオブジェクトのデストラクタを呼び出す
-	GetLexicalScopes().CallDestructorsOfReturn();
+	compiler.codeGenerator.lexicalScopes.CallDestructorsOfReturn();
 
 	//jmp ...(End Sub/Function)
-	OpBuffer[obp++]=(char)0xE9;
-
-	pExitSubSchedule=(DWORD *)HeapReAlloc(hHeap,0,pExitSubSchedule,(ExitSubScheduleNum+1)*sizeof(DWORD));
-	pExitSubSchedule[ExitSubScheduleNum]=obp;
-	ExitSubScheduleNum++;
-
-	obp+=sizeof(long);
-}
-
-void AddCaseSchedule(void){
-	extern DWORD *pCaseSchedule;
-	extern int CaseScheduleNum;
-	extern HANDLE hHeap;
-
-	pCaseSchedule=(DWORD *)HeapReAlloc(hHeap,0,pCaseSchedule,(CaseScheduleNum+1)*sizeof(DWORD));
-	pCaseSchedule[CaseScheduleNum]=obp;
-	CaseScheduleNum++;
-}
+	compiler.codeGenerator.op_jmp_exitsub();
+}
+
+//Caseスケジュール
+class SelectSchedule
+{
+public:
+	SelectSchedule( int typeSize )
+		: typeSize( typeSize )
+		, nowCaseSchedule( 0 )
+	{
+	}
+
+	PertialSchedules casePertialSchedules;
+	int typeSize;
+	int nowCaseSchedule;
+};
+std::vector<SelectSchedule> selectSchedules;
+
 void OpcodeSelect( const char *lpszParms ){
-	extern DWORD *pCaseSchedule;
-	extern int CaseScheduleNum;
-	extern int NowCaseSchedule;
 	extern HANDLE hHeap;
 	extern char *basbuf;
 	int i,i2,i3,NowCaseCp;
 	char temporary[VN_SIZE];
-
-	DWORD *temp_pCaseSchedule;
-	int temp_CaseScheduleNum;
-	int temp_NowCaseSchedule;
-
-	temp_pCaseSchedule=pCaseSchedule;
-	temp_CaseScheduleNum=CaseScheduleNum;
-	temp_NowCaseSchedule=NowCaseSchedule;
-	pCaseSchedule=(DWORD *)HeapAlloc(hHeap,0,1);
-	CaseScheduleNum=0;
-	NowCaseSchedule=0;
-
+	
 	int reg1=REG_RAX;
 	Type type1;
@@ -596,4 +576,10 @@
 	}
 
+	selectSchedules.push_back( SelectSchedule( type1.GetSize() ) );
+
+	if( selectSchedules.back().typeSize < sizeof(long) ){
+		selectSchedules.back().typeSize = sizeof(long);
+	}
+
 	if(type1.IsDouble()){
 		//movsd qword ptr[rsp+offset],xmm_reg		※スタックフレームを利用
@@ -613,8 +599,5 @@
 	for(i=cp;;i++){
 		if(basbuf[i]=='\0'){
-			HeapDefaultFree(pCaseSchedule);
-			pCaseSchedule=temp_pCaseSchedule;
-			CaseScheduleNum=temp_CaseScheduleNum;
-			NowCaseSchedule=temp_NowCaseSchedule;
+			selectSchedules.pop_back();
 			SetError(22,"Select",cp);
 			return;
@@ -718,6 +701,7 @@
 
 					//jne ...
-					OpBuffer[obp++]=(char)0x0F;
-					OpBuffer[obp++]=(char)0x85;
+					selectSchedules.back().casePertialSchedules.push_back(
+						compiler.codeGenerator.op_jne( 0, sizeof(long), true )
+					);
 				}
 				else{
@@ -759,9 +743,8 @@
 
 					//je ...
-					OpBuffer[obp++]=(char)0x0F;
-					OpBuffer[obp++]=(char)0x84;
+					selectSchedules.back().casePertialSchedules.push_back(
+						compiler.codeGenerator.op_je( 0, sizeof(long), true )
+					);
 				}
-				AddCaseSchedule();
-				obp+=sizeof(long);
 
 				if(basbuf[i]!=',') break;
@@ -770,7 +753,7 @@
 		if(basbuf[i]==1&&basbuf[i+1]==ESC_CASEELSE){
 			//jmp ...
-			OpBuffer[obp++]=(char)0xE9;
-			AddCaseSchedule();
-			obp+=sizeof(long);
+			selectSchedules.back().casePertialSchedules.push_back(
+				compiler.codeGenerator.op_jmp( 0, sizeof(long), true )
+			);
 		}
 	}
@@ -780,5 +763,5 @@
 
 	//レキシカルスコープをレベルアップ
-	GetLexicalScopes().Start( obp, SCOPE_TYPE_SELECT );
+	compiler.codeGenerator.lexicalScopes.Start( obp, LexicalScope::SCOPE_TYPE_SELECT );
 
 	//Select Case内をコンパイル
@@ -786,27 +769,22 @@
 
 	//jmp EndSelect
-	OpBuffer[obp++]=(char)0xE9;
-	AddCaseSchedule();
-	obp+=sizeof(long);
+	selectSchedules.back().casePertialSchedules.push_back(
+		compiler.codeGenerator.op_jmp( 0, sizeof(long), true )
+	);
 
 	//最終スケジュール
-	for(i=NowCaseSchedule;i<CaseScheduleNum;i++){
-		*(long *)(OpBuffer+pCaseSchedule[i])=obp-(pCaseSchedule[i]+sizeof(long));
-	}
-	HeapDefaultFree(pCaseSchedule);
+	for(i=selectSchedules.back().nowCaseSchedule;i<(int)selectSchedules.back().casePertialSchedules.size();i++){
+		compiler.codeGenerator.opfix_JmpPertialSchedule( selectSchedules.back().casePertialSchedules[i] );
+	}
 
 	//レキシカルスコープをレベルダウン
-	GetLexicalScopes().End();
-
-	pCaseSchedule=temp_pCaseSchedule;
-	CaseScheduleNum=temp_CaseScheduleNum;
-	NowCaseSchedule=temp_NowCaseSchedule;
+	compiler.codeGenerator.lexicalScopes.End();
+
+	selectSchedules.pop_back();
 }
 void OpcodeCase(char *Parameter){
-	extern DWORD *pCaseSchedule;
-	extern int NowCaseSchedule;
 	int i;
 
-	if(!pCaseSchedule){
+	if(selectSchedules.back().typeSize==-1){
 		SetError(30,"Case",cp);
 		return;
@@ -814,13 +792,13 @@
 
 	//jmp EndSelect
-	OpBuffer[obp++]=(char)0xE9;
-	AddCaseSchedule();
-	obp+=sizeof(long);
+	selectSchedules.back().casePertialSchedules.push_back(
+		compiler.codeGenerator.op_jmp( 0, sizeof(long), true )
+	);
 
 	i=0;
 	while(1){
 		//Caseスケジュール
-		*(long *)(OpBuffer+pCaseSchedule[NowCaseSchedule])=obp-(pCaseSchedule[NowCaseSchedule]+sizeof(long));
-		NowCaseSchedule++;
+		compiler.codeGenerator.opfix_JmpPertialSchedule( selectSchedules.back().casePertialSchedules[selectSchedules.back().nowCaseSchedule] );
+		selectSchedules.back().nowCaseSchedule++;
 
 		i=JumpOneParameter(Parameter,i);
@@ -830,62 +808,4 @@
 
 void OpcodeGosub(char *Parameter){
-	extern HANDLE hHeap;
-	extern GOTOLABELSCHEDULE *pGotoLabelSchedule;
-	extern int GotoLabelScheduleNum;
-	int i,LineNum;
-
-	//call _System_GetEip
-	extern const UserProc *pSub_System_GetEip;
-	compiler.codeGenerator.op_call(pSub_System_GetEip);
-
-	//add rax,offset（Gosubステートメントの最終ポイント）
-	int schedule=obp,schedule2;
-	compiler.codeGenerator.op_add_RV(REG_RAX,0);
-	schedule2=obp-sizeof(long);
-
-	//※戻り先用のrip
-	//mov qword ptr[rsp+offset],rax     ※スタックフレームを利用
-	pobj_sf->push(REG_RAX);
-
-
-	if(Parameter[0]=='*'){
-		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);
-	}
-	else{
-		LineNum=atoi(Parameter);
-		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);
-	}
-
-	*((long *)(OpBuffer+schedule2))=obp-schedule;
-
-	//※スタックフレームを元に戻す
-	pobj_sf->pop(REG_NON);
-
 	SetError(-1,"Gosub ～ Returnステートメントは64ビットコンパイラで利用することはできません。",cp);
 }
Index: trunk/abdev/BasicCompiler64/Compile_Var.cpp
===================================================================
--- trunk/abdev/BasicCompiler64/Compile_Var.cpp	(revision 243)
+++ trunk/abdev/BasicCompiler64/Compile_Var.cpp	(revision 254)
@@ -4,5 +4,4 @@
 #include <jenga/include/smoothie/LexicalAnalysis.h>
 
-#include <LexicalScopingImpl.h>
 #include <CodeGenerator.h>
 #include <Compiler.h>
@@ -989,8 +988,7 @@
 
 		//mov qword ptr[rsp+offset],rax
-		compiler.codeGenerator.op_mov_MR(sizeof(_int64),REG_RAX,REG_RSP,offset,MOD_BASE_DISP32);
-		obp-=sizeof(long);
-		AddLocalVarAddrSchedule();
-		obp+=sizeof(long);
+		compiler.codeGenerator.localVarPertialSchedules.push_back(
+			compiler.codeGenerator.op_mov_MR(sizeof(_int64),REG_RAX,REG_RSP,offset,MOD_BASE_DISP32, Schedule::None, true )
+		);
 	}
 	else if( type.IsSingle() ){
@@ -999,5 +997,7 @@
 
 		//mov dword ptr[rsp+offset],value
-		compiler.codeGenerator.op_mov_MV(sizeof(long),REG_RSP,offset, Schedule::LocalVar, USE_OFFSET,*(int *)&flt);
+		compiler.codeGenerator.localVarPertialSchedules.push_back(
+			compiler.codeGenerator.op_mov_MV(sizeof(long),REG_RSP,offset, Schedule::None, true, USE_OFFSET,*(int *)&flt)
+		);
 	}
 	else if( type.Is64() || type.IsPointer() ){
@@ -1014,5 +1014,7 @@
 
 			//mov qword ptr[rsp+offset],rax
-			compiler.codeGenerator.op_mov_MR(sizeof(_int64),REG_RAX,REG_RSP,offset,MOD_BASE_DISP32, Schedule::LocalVar );
+			compiler.codeGenerator.localVarPertialSchedules.push_back(
+				compiler.codeGenerator.op_mov_MR(sizeof(_int64),REG_RAX,REG_RSP,offset,MOD_BASE_DISP32, Schedule::None, true )
+			);
 		}
 		else{
@@ -1022,9 +1024,13 @@
 
 				//mov qword ptr[rsp+offset],rax
-				compiler.codeGenerator.op_mov_MR(sizeof(_int64),REG_RAX,REG_RSP,offset,MOD_BASE_DISP32, Schedule::LocalVar );
+				compiler.codeGenerator.localVarPertialSchedules.push_back(
+					compiler.codeGenerator.op_mov_MR(sizeof(_int64),REG_RAX,REG_RSP,offset,MOD_BASE_DISP32, Schedule::None, true )
+				);
 			}
 			else{
 				//mov qword ptr[rsp+offset],value
-				compiler.codeGenerator.op_mov_MV(sizeof(_int64),REG_RSP,offset, Schedule::LocalVar, USE_OFFSET,(int)i64data);
+				compiler.codeGenerator.localVarPertialSchedules.push_back(
+					compiler.codeGenerator.op_mov_MV(sizeof(_int64),REG_RSP,offset, Schedule::None, true, USE_OFFSET,(int)i64data)
+				);
 			}
 		}
@@ -1032,13 +1038,19 @@
 	else if( type.IsDWord() || type.IsLong() ){
 		//mov dword ptr[rsp+offset],value
-		compiler.codeGenerator.op_mov_MV(sizeof(long),REG_RSP,offset, Schedule::LocalVar,USE_OFFSET,(int)i64data);
+		compiler.codeGenerator.localVarPertialSchedules.push_back(
+			compiler.codeGenerator.op_mov_MV(sizeof(long),REG_RSP,offset, Schedule::None, true, USE_OFFSET,(int)i64data)
+		);
 	}
 	else if( type.IsWord() || type.IsInteger() ){
 		//mov word ptr[rsp+offset],value
-		compiler.codeGenerator.op_mov_MV(sizeof(short),REG_RSP,offset, Schedule::LocalVar,USE_OFFSET,(int)i64data);
+		compiler.codeGenerator.localVarPertialSchedules.push_back(
+			compiler.codeGenerator.op_mov_MV(sizeof(short),REG_RSP,offset, Schedule::None, true, USE_OFFSET,(int)i64data)
+		);
 	}
 	else if( type.IsSByte() || type.IsByte() || type.IsBoolean() ){
 		//mov byte ptr[rsp+offset],value
-		compiler.codeGenerator.op_mov_MV(sizeof(char),REG_RSP,offset, Schedule::LocalVar,USE_OFFSET,(int)i64data);
+		compiler.codeGenerator.localVarPertialSchedules.push_back(
+			compiler.codeGenerator.op_mov_MV(sizeof(char),REG_RSP,offset, Schedule::None, true, USE_OFFSET,(int)i64data)
+		);
 	}
 	return true;
@@ -1074,6 +1086,6 @@
 
 		//レキシカルスコープ
-		pVar->SetScopeLevel( GetLexicalScopes().GetNowLevel() );
-		pVar->SetScopeStartAddress( GetLexicalScopes().GetStartAddress() );
+		pVar->SetScopeLevel( compiler.codeGenerator.lexicalScopes.GetNowLevel() );
+		pVar->SetScopeStartAddress( compiler.codeGenerator.lexicalScopes.GetStartAddress() );
 		pVar->bLiving=TRUE;
 
@@ -1109,6 +1121,6 @@
 
 		//レキシカルスコープ
-		pVar->SetScopeLevel( GetLexicalScopes().GetNowLevel() );
-		pVar->SetScopeStartAddress( GetLexicalScopes().GetStartAddress() );
+		pVar->SetScopeLevel( compiler.codeGenerator.lexicalScopes.GetNowLevel() );
+		pVar->SetScopeStartAddress( compiler.codeGenerator.lexicalScopes.GetStartAddress() );
 		pVar->bLiving=TRUE;
 
@@ -1151,8 +1163,7 @@
 
 			//add rcx, offset
-			compiler.codeGenerator.op_add_RV( REG_RCX, -pVar->GetOffsetAddress() );
-			obp-=sizeof(long);
-			AddLocalVarAddrSchedule();
-			obp+=sizeof(long);
+			compiler.codeGenerator.localVarPertialSchedules.push_back(
+				compiler.codeGenerator.op_add_RV( REG_RCX, -pVar->GetOffsetAddress(), Schedule::None, true )
+			);
 
 			//call FillMemory
@@ -1217,5 +1228,7 @@
 		if(pRelativeVar->bOffsetOffset){
 			//add r11,offset
-			compiler.codeGenerator.op_add_RV( REG_R11, (long)pRelativeVar->offset, Schedule::LocalVar );
+			compiler.codeGenerator.localVarPertialSchedules.push_back(
+				compiler.codeGenerator.op_add_RV( REG_R11, (long)pRelativeVar->offset, Schedule::None, true )
+			);
 
 			//add r11,rsp
@@ -1230,5 +1243,7 @@
 
 			//add reg,offset
-			compiler.codeGenerator.op_add_RV(reg,(long)pRelativeVar->offset, Schedule::LocalVar );
+			compiler.codeGenerator.localVarPertialSchedules.push_back(
+				compiler.codeGenerator.op_add_RV(reg,(long)pRelativeVar->offset, Schedule::None, true )
+			);
 		}
 	}
@@ -1236,9 +1251,13 @@
 		if(pRelativeVar->bOffsetOffset){
 			//add r11,qword ptr[rsp+offset]
-			compiler.codeGenerator.op_add_RM( sizeof(_int64), REG_R11, REG_RSP, (long)pRelativeVar->offset, MOD_BASE_DISP32, Schedule::LocalVar );
+			compiler.codeGenerator.localVarPertialSchedules.push_back(
+				compiler.codeGenerator.op_add_RM( sizeof(_int64), REG_R11, REG_RSP, (long)pRelativeVar->offset, MOD_BASE_DISP32, Schedule::None, true )
+			);
 		}
 		else{
 			//mov r11,qword ptr[rsp+offset]
-			compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar );
+			compiler.codeGenerator.localVarPertialSchedules.push_back(
+				compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::None, true )
+			);
 		}
 
Index: trunk/abdev/BasicCompiler64/MakePeHdr.cpp
===================================================================
--- trunk/abdev/BasicCompiler64/MakePeHdr.cpp	(revision 243)
+++ trunk/abdev/BasicCompiler64/MakePeHdr.cpp	(revision 254)
@@ -5,5 +5,4 @@
 #include <jenga/include/smoothie/Smoothie.h>
 
-#include <LexicalScopingImpl.h>
 #include <Class.h>
 #include <Compiler.h>
@@ -334,5 +333,5 @@
 
 	//レキシカルスコープ情報を初期化
-	GetLexicalScopes().Init(obp);
+	compiler.codeGenerator.lexicalScopes.Init(obp);
 
 
@@ -369,8 +368,5 @@
 
 		//Gotoラベルスケジュール
-		extern GOTOLABELSCHEDULE *pGotoLabelSchedule;
-		extern int GotoLabelScheduleNum;
-		pGotoLabelSchedule=(GOTOLABELSCHEDULE *)HeapAlloc(hHeap,0,1);
-		GotoLabelScheduleNum=0;
+		compiler.codeGenerator.gotoLabelSchedules.clear();
 
 		//With情報のメモリを確保
@@ -424,16 +420,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 *pGotoLabelSchedule, compiler.codeGenerator.gotoLabelSchedules )
+		{
+			if(pGotoLabelSchedule->GetName().size()>0){
+				SetError(6,pGotoLabelSchedule->GetName(),pGotoLabelSchedule->GetSourceCodePos());
 			}
 			else{
-				sprintf(temporary,"%d",pGotoLabelSchedule[i].line);
-				SetError(6,temporary,pGotoLabelSchedule[i].now_cp);
+				sprintf(temporary,"%d",pGotoLabelSchedule->GetLineNum());
+				SetError(6,temporary,pGotoLabelSchedule->GetSourceCodePos());
 			}
 		}
-		HeapDefaultFree(pGotoLabelSchedule);
 
 
Index: trunk/abdev/BasicCompiler64/NumOpe.cpp
===================================================================
--- trunk/abdev/BasicCompiler64/NumOpe.cpp	(revision 243)
+++ trunk/abdev/BasicCompiler64/NumOpe.cpp	(revision 254)
@@ -533,31 +533,4 @@
 	}
 
-	if(expression[0]==1&& expression[1]==ESC_NEW ){
-		//New演算子（オブジェクト生成）
-
-		if( pobj_BlockReg->check(REG_RAX) ){
-			SetError();
-		}
-
-		//////////////////////////////////////////////////////
-		/////    レジスタ資源のバックアップ
-		{	BACKUP_REGISTER_RESOURCE
-		//////////////////////////////////////////////////////
-
-			if( !Operator_New( expression+2, baseType, resultType ) ){
-				return false;
-			}
-
-		/////////////////////////////////////////////
-		//////   レジスタ資源を復元
-			RESTORE_REGISTER_RESOURCE
-		}////////////////////////////////////////////
-
-		//mov reg,rax
-		compiler.codeGenerator.op_mov_RR( *pReg, REG_RAX );
-
-		return true;
-	}
-
 	if( !baseType.IsNull() && expression[0] == '[' ){
 		// リテラル配列の場合
@@ -608,4 +581,86 @@
 
 		resultType = baseType;
+
+		return true;
+	}
+
+	bool isLiteralCalculation;
+	if( !NumOpe_GetType( expression, baseType, resultType, &isLiteralCalculation ) )
+	{
+		return false;
+	}
+	if( isLiteralCalculation )
+	{
+		//右辺値が数値の定数式の場合
+		_int64 i64data;
+		StaticCalculation(true, expression,baseType.GetBasicType(),&i64data,resultType);
+
+		if(resultType.IsReal()){
+			if(baseType.IsReal()) resultType=baseType;
+
+			int xmmReg = REG_XMM0;
+
+			if(resultType.IsDouble()){
+				i3 = compiler.GetDataTable().Add( i64data );
+
+				//movlpd xmm_reg,qword ptr[data table offset]
+				compiler.codeGenerator.op_movlpd_RM( xmmReg, 0, i3, MOD_DISP32, Schedule::DataTable );
+			}
+			if(resultType.IsSingle()){
+				double dbl;
+				memcpy(&dbl,&i64data,sizeof(_int64));
+
+				float flt;
+				int i32data;
+				flt=(float)dbl;
+				memcpy(&i32data,&flt,sizeof(long));
+
+				i3 = compiler.GetDataTable().Add( i32data );
+
+				//movss xmm_reg,dword ptr[data table offset]
+				compiler.codeGenerator.op_movss_RM( xmmReg, 0, i3, MOD_DISP32, Schedule::DataTable );
+			}
+		}
+		else{
+			if(!resultType.Is64()){
+				//整数（符号有り/無し）
+
+				i3=(long)i64data;
+
+				if(resultType.GetBasicSize()==sizeof(char)) i3=i3&0x000000FF;
+				if(resultType.GetBasicSize()==sizeof(short)) i3=i3&0x0000FFFF;
+
+				i64data=(_int64)i3;
+			}
+
+			//mov reg,i64data
+			compiler.codeGenerator.op_mov_RV64(*pReg,i64data);
+		}
+		return true;
+	}
+
+	if(expression[0]==1&& expression[1]==ESC_NEW ){
+		//New演算子（オブジェクト生成）
+
+		if( pobj_BlockReg->check(REG_RAX) ){
+			SetError();
+		}
+
+		//////////////////////////////////////////////////////
+		/////    レジスタ資源のバックアップ
+		{	BACKUP_REGISTER_RESOURCE
+		//////////////////////////////////////////////////////
+
+			if( !Operator_New( expression+2, baseType, resultType ) ){
+				return false;
+			}
+
+		/////////////////////////////////////////////
+		//////   レジスタ資源を復元
+			RESTORE_REGISTER_RESOURCE
+		}////////////////////////////////////////////
+
+		//mov reg,rax
+		compiler.codeGenerator.op_mov_RR( *pReg, REG_RAX );
 
 		return true;
Index: trunk/abdev/BasicCompiler64/Opcode.h
===================================================================
--- trunk/abdev/BasicCompiler64/Opcode.h	(revision 243)
+++ trunk/abdev/BasicCompiler64/Opcode.h	(revision 254)
@@ -27,12 +27,4 @@
 	int line;
 	DWORD address;
-};
-
-//Goto未知ラベル
-struct GOTOLABELSCHEDULE{
-	char *pName;
-	int line;
-	DWORD pos;
-	DWORD now_cp;
 };
 
@@ -339,5 +331,4 @@
 
 //Compile_CallProc.cpp
-void AddLocalVarAddrSchedule();
 #define PROCFLAG_NEW	1
 bool Opcode_CallProcPtr(const char *variable, const char *lpszParms,ProcPointer *pProcPointer);
