Index: trunk/abdev/BasicCompiler_Common/DebugMiddleFile.cpp
===================================================================
--- trunk/abdev/BasicCompiler_Common/DebugMiddleFile.cpp	(revision 201)
+++ trunk/abdev/BasicCompiler_Common/DebugMiddleFile.cpp	(revision 206)
@@ -1,9 +1,12 @@
+#include "stdafx.h"
+
 #include <jenga/include/smoothie/Smoothie.h>
 
 #include <Compiler.h>
-#include <ClassImpl.h>
-#include <VariableImpl.h>
+#include <Class.h>
+#include <Variable.h>
 
 #include "../BasicCompiler_Common/common.h"
+#include "../BasicCompiler_Common/DebugSection.h"
 
 #ifdef _AMD64_
@@ -44,7 +47,4 @@
 
 
-CDebugSection::CDebugSection(){
-	memset(this,0,sizeof(CDebugSection));
-}
 CDebugSection::~CDebugSection(){
 	if(pobj_DBClass) DeleteDebugInfo();
@@ -56,5 +56,5 @@
 void CDebugSection::make(void){
 	extern INCLUDEFILEINFO IncludeFileInfo;
-	int i2,i3,i5,BufferSize;
+	int i2,i3,BufferSize;
 
 	if(buffer){
@@ -159,7 +159,7 @@
 
 	//グローバル変数情報
-	*(long *)(buffer+i2)=(int)::globalVars.size();
-	i2+=sizeof(long);
-	BOOST_FOREACH( Variable *pVar, ::globalVars ){
+	*(long *)(buffer+i2)=(int)compiler.GetMeta().GetGlobalVars().size();
+	i2+=sizeof(long);
+	BOOST_FOREACH( Variable *pVar, compiler.GetMeta().GetGlobalVars() ){
 		//変数名
 		lstrcpy(buffer+i2,pVar->GetName().c_str());
@@ -167,9 +167,9 @@
 
 		//型
-		*(long *)(buffer+i2)=pVar->GetBasicType();
+		*(long *)(buffer+i2)=pVar->GetType().GetBasicType();
 		i2+=sizeof(long);
 
 		//型の拡張情報
-		SetLpIndex_DebugFile(buffer,&i2,*pVar);
+		SetLpIndex_DebugFile(buffer,&i2,pVar->GetType());
 
 		buffer[i2++] = pVar->IsRef() ? 1 : 0;
@@ -178,21 +178,23 @@
 
 		if(pVar->IsArray()){
-			for(i5=0;;i5++){
-				*(long *)(buffer+i2)=pVar->GetSubScriptsPtr()[i5];
+			*(long *)(buffer+i2)=(int)pVar->GetSubscripts().size();
+			i2+=sizeof(long);
+			BOOST_FOREACH( int indexMax, pVar->GetSubscripts() )
+			{
+				*(long *)(buffer+i2)=indexMax;
 				i2+=sizeof(long);
-				if(pVar->GetSubScriptsPtr()[i5]==-1) break;
 			}
 		}
 
 		//レキシカルスコープ情報
-		*(long *)(buffer+i2)=pVar->ScopeStartAddress;
-		i2+=sizeof(long);
-		*(long *)(buffer+i2)=pVar->ScopeEndAddress;
-		i2+=sizeof(long);
-		*(long *)(buffer+i2)=pVar->ScopeLevel;
+		*(long *)(buffer+i2)=pVar->GetScopeStartAddress();
+		i2+=sizeof(long);
+		*(long *)(buffer+i2)=pVar->GetScopeEndAddress();
+		i2+=sizeof(long);
+		*(long *)(buffer+i2)=pVar->GetScopeLevel();
 		i2+=sizeof(long);
 
 		//メモリ位置
-		*(long *)(buffer+i2)=pVar->offset;
+		*(long *)(buffer+i2)=pVar->GetOffsetAddress();
 		i2+=sizeof(long);
 
@@ -210,37 +212,85 @@
 
 	//プロシージャ情報
-	extern GlobalProc **ppSubHash;
-	extern int SubNum;
-	GlobalProc *pUserProc;
-	*(long *)(buffer+i2)=SubNum;
-	i2+=sizeof(long);
-	for(i3=0;i3<MAX_HASH;i3++){
-		pUserProc=ppSubHash[i3];
-		while(pUserProc){
-			if(pUserProc->GetParentClassPtr()){
-				lstrcpy(buffer+i2,pUserProc->GetParentClassPtr()->GetName().c_str());
-				i2+=lstrlen(buffer+i2)+1;
-			}
-			else{
-				lstrcpy(buffer+i2,"");
-				i2+=lstrlen(buffer+i2)+1;
-			}
-
-			//ID
-			*(long *)(buffer+i2)=pUserProc->id;
-			i2+=sizeof(long);
-
-			//関数名
-			lstrcpy(buffer+i2,pUserProc->GetName().c_str());
+	*(long *)(buffer+i2) = compiler.GetMeta().GetUserProcs().Iterator_GetMaxCount();
+	i2+=sizeof(long);
+	compiler.GetMeta().GetUserProcs().Iterator_Reset();
+	while( compiler.GetMeta().GetUserProcs().Iterator_HasNext() )
+	{
+		UserProc *pUserProc = compiler.GetMeta().GetUserProcs().Iterator_GetNext();
+
+		if(pUserProc->GetParentClassPtr()){
+			lstrcpy(buffer+i2,pUserProc->GetParentClassPtr()->GetName().c_str());
 			i2+=lstrlen(buffer+i2)+1;
-
-			*(long *)(buffer+i2)=pUserProc->beginOpAddress;
-			i2+=sizeof(long);
-			*(long *)(buffer+i2)=pUserProc->endOpAddress;
-			i2+=sizeof(long);
-
-			//ローカル変数情報
-			*(long *)(buffer+i2)=(int)pUserProc->localVars.size();
-			i2+=sizeof(long);
+		}
+		else{
+			lstrcpy(buffer+i2,"");
+			i2+=lstrlen(buffer+i2)+1;
+		}
+
+		//ID
+		*(long *)(buffer+i2)=pUserProc->GetId();
+		i2+=sizeof(long);
+
+		//関数名
+		lstrcpy(buffer+i2,pUserProc->GetName().c_str());
+		i2+=lstrlen(buffer+i2)+1;
+
+		*(long *)(buffer+i2)=pUserProc->GetBeginOpAddress();
+		i2+=sizeof(long);
+		*(long *)(buffer+i2)=pUserProc->GetEndOpAddress();
+		i2+=sizeof(long);
+
+		//ローカル変数情報
+		*(long *)(buffer+i2)=(int)pUserProc->GetLocalVars().size();
+		i2+=sizeof(long);
+
+		//バッファが足りない場合は再確保
+		if(BufferSize<i2+32768){
+			BufferSize+=32768;
+			buffer=(char *)HeapReAlloc(hHeap,0,buffer,BufferSize);
+		}
+
+		BOOST_FOREACH( Variable *pVar, pUserProc->GetLocalVars() ){
+			lstrcpy(buffer+i2,pVar->GetName().c_str());
+			i2+=lstrlen(buffer+i2)+1;
+
+			//型
+			*(long *)(buffer+i2)=pVar->GetType().GetBasicType();
+			i2+=sizeof(long);
+
+			//型の拡張情報
+			SetLpIndex_DebugFile(buffer,&i2,pVar->GetType());
+
+			//参照型パラメータかどうか
+			buffer[i2++] = pVar->IsRef() ? 1 : 0;
+
+			//配列かどうか
+			buffer[i2++] = pVar->IsArray() ? 1 : 0;
+
+			//配列要素
+			if(pVar->IsArray()){
+				*(long *)(buffer+i2)=(int)pVar->GetSubscripts().size();
+				i2+=sizeof(long);
+				BOOST_FOREACH( int indexMax, pVar->GetSubscripts() )
+				{
+					*(long *)(buffer+i2)=indexMax;
+					i2+=sizeof(long);
+				}
+			}
+
+			//レキシカルスコープ情報
+			*(long *)(buffer+i2)=pVar->GetScopeStartAddress();
+			i2+=sizeof(long);
+			*(long *)(buffer+i2)=pVar->GetScopeEndAddress();
+			i2+=sizeof(long);
+			*(long *)(buffer+i2)=pVar->GetScopeLevel();
+			i2+=sizeof(long);
+
+			//メモリ位置
+			*(long *)(buffer+i2)=pVar->GetOffsetAddress();
+			i2+=sizeof(long);
+
+
+
 
 			//バッファが足りない場合は再確保
@@ -249,54 +299,4 @@
 				buffer=(char *)HeapReAlloc(hHeap,0,buffer,BufferSize);
 			}
-
-			BOOST_FOREACH( Variable *pVar, pUserProc->localVars ){
-				lstrcpy(buffer+i2,pVar->GetName().c_str());
-				i2+=lstrlen(buffer+i2)+1;
-
-				//型
-				*(long *)(buffer+i2)=pVar->GetBasicType();
-				i2+=sizeof(long);
-
-				//型の拡張情報
-				SetLpIndex_DebugFile(buffer,&i2,*pVar);
-
-				//参照型パラメータかどうか
-				buffer[i2++] = pVar->IsRef() ? 1 : 0;
-
-				//配列かどうか
-				buffer[i2++] = pVar->IsArray() ? 1 : 0;
-
-				//配列要素
-				if(pVar->IsArray()){
-					for(i5=0;;i5++){
-						*(long *)(buffer+i2)=pVar->GetSubScriptsPtr()[i5];
-						i2+=sizeof(long);
-						if(pVar->GetSubScriptsPtr()[i5]==-1) break;
-					}
-				}
-
-				//レキシカルスコープ情報
-				*(long *)(buffer+i2)=pVar->ScopeStartAddress;
-				i2+=sizeof(long);
-				*(long *)(buffer+i2)=pVar->ScopeEndAddress;
-				i2+=sizeof(long);
-				*(long *)(buffer+i2)=pVar->ScopeLevel;
-				i2+=sizeof(long);
-
-				//メモリ位置
-				*(long *)(buffer+i2)=pVar->offset;
-				i2+=sizeof(long);
-
-
-
-
-				//バッファが足りない場合は再確保
-				if(BufferSize<i2+32768){
-					BufferSize+=32768;
-					buffer=(char *)HeapReAlloc(hHeap,0,buffer,BufferSize);
-				}
-			}
-
-			pUserProc=pUserProc->pNextData;
 		}
 	}
@@ -328,5 +328,5 @@
 		i2+=sizeof(long);
 
-		//メンバ
+		// 動的メンバ
 		*(long *)(buffer+i2)=(int)pobj_c->GetDynamicMembers().size();
 		i2+=sizeof(long);
@@ -347,6 +347,11 @@
 			i2+=sizeof(Prototype::Accessibility);
 
-			memcpy(buffer+i2,member->SubScripts,sizeof(int)*MAX_ARRAYDIM);
-			i2+=sizeof(int)*MAX_ARRAYDIM;
+			*(long *)(buffer+i2)=(int)member->GetSubscripts().size();
+			i2+=sizeof(long);
+			BOOST_FOREACH( int indexMax, member->GetSubscripts() )
+			{
+				*(long *)(buffer+i2)=indexMax;
+				i2+=sizeof(long);
+			}
 
 			//バッファが足りない場合は再確保
@@ -357,5 +362,5 @@
 		}
 
-		//メソッド
+		// 動的メソッド
 		*(long *)(buffer+i2)=(long)pobj_c->GetMethods().size();
 		i2+=sizeof(long);
@@ -371,5 +376,5 @@
 				i2+=lstrlen(buffer+i2)+1;
 			}
-			lstrcpy(buffer+i2,pMethod->pUserProc->GetName().c_str());
+			lstrcpy(buffer+i2,pMethod->GetUserProc().GetName().c_str());
 			i2+=lstrlen(buffer+i2)+1;
 		}
@@ -394,6 +399,12 @@
 			i2+=sizeof(Prototype::Accessibility);
 
-			memcpy(buffer+i2,member->SubScripts,sizeof(int)*MAX_ARRAYDIM);
-			i2+=sizeof(int)*MAX_ARRAYDIM;
+			// 配列
+			*(long *)(buffer+i2)=(int)member->GetSubscripts().size();
+			i2+=sizeof(long);
+			BOOST_FOREACH( int indexMax, member->GetSubscripts() )
+			{
+				*(long *)(buffer+i2)=indexMax;
+				i2+=sizeof(long);
+			}
 
 			//バッファが足りない場合は再確保
@@ -434,8 +445,8 @@
 }
 BOOL CDebugSection::__load(void){
-	int i2,i3,i4,i5,num;
+	int i2,i3,i4,num;
 	char temp2[MAX_PATH],*temp5;
 
-	Smoothie::Temp::pCompilingClass = NULL;
+	compiler.pCompilingClass = NULL;
 
 	i2=0;
@@ -487,5 +498,5 @@
 	///////////////////////////////////////////
 
-	this->pobj_DBClass=new ClassesImpl();
+	this->pobj_DBClass=new Classes();
 
 	int iMaxClassCount;
@@ -524,10 +535,9 @@
 	//定数を取得
 	GetConstInfo();
-	extern CONSTINFO **ppConstHash;
-	this->ppConstHash=ppConstHash;
-
+	this->globalConsts = compiler.GetMeta().GetGlobalConsts();
+	this->globalConstMacros = compiler.GetMeta().GetGlobalConstMacros();
 
 	//グローバル変数情報
-	globalVars.clear();
+	compiler.GetMeta().GetGlobalVars().clear();
 	int maxGlobalVars=*(long *)(buffer+i2);
 	i2+=sizeof(long);
@@ -548,32 +558,33 @@
 		bool isArray = (buffer[i2++]) ? true:false;
 
-		Variable *pVar = new VariableImpl( name, type, false, isRef );
+		Variable *pVar = new Variable( name, type, false, isRef, "" );
 
 		if(isArray){
-			int SubScripts[MAX_ARRAYDIM];
-			for(i4=0;;i4++){
-				SubScripts[i4]=*(long *)(buffer+i2);
+			Subscripts subscripts;
+			int nSubScriptsNum = *(long *)(buffer+i2);
+			i2+=sizeof(long);
+			for( int i=0; i<nSubScriptsNum; i++ )
+			{
+				subscripts.push_back( *(long *)(buffer+i2) );
 				i2+=sizeof(long);
-
-				if(SubScripts[i4]==-1) break;
-			}
-
-			pVar->SetArray( SubScripts );
+			}
+
+			pVar->SetArray( subscripts );
 		}
 
 		//レキシカルスコープ情報
-		pVar->ScopeStartAddress=*(long *)(buffer+i2);
-		i2+=sizeof(long);
-		pVar->ScopeEndAddress=*(long *)(buffer+i2);
-		i2+=sizeof(long);
-		pVar->ScopeLevel=*(long *)(buffer+i2);
+		pVar->SetScopeStartAddress( *(long *)(buffer+i2) );
+		i2+=sizeof(long);
+		pVar->SetScopeEndAddress( *(long *)(buffer+i2) );
+		i2+=sizeof(long);
+		pVar->SetScopeLevel( *(long *)(buffer+i2) );
 		i2+=sizeof(long);
 
 		//メモリ位置
-		pVar->offset=*(long *)(buffer+i2);
+		pVar->SetOffsetAddress( *(long *)(buffer+i2) );
 		i2+=sizeof(long);
 
 		//変数を追加
-		globalVars.push_back( pVar );
+		compiler.GetMeta().GetGlobalVars().push_back( pVar );
 	}
 
@@ -583,9 +594,8 @@
 
 	//プロシージャ情報
-	GlobalProc *pUserProc;
-	SubNum=*(long *)(buffer+i2);
-	i2+=sizeof(long);
-	ppSubHash=(GlobalProc **)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,MAX_HASH*sizeof(GlobalProc *));
-	for(int i6=0;i6<SubNum;i6++){
+	userProcs.Clear();
+	int subNum = *(long *)(buffer+i2);
+	i2+=sizeof(long);
+	for(int i6=0;i6<subNum;i6++){
 		char szParentClassName[VN_SIZE];
 		lstrcpy(szParentClassName,buffer+i2);
@@ -607,12 +617,10 @@
 		// オブジェクトを生成
 		// TODO: 名前空間が未完成
-		pUserProc = new GlobalProc( NamespaceScopes(), NamespaceScopesCollection(), name, Procedure::Function, false, false, false );
-		pUserProc->pNextData=0;
-		pUserProc->id=id;
+		UserProc *pUserProc = new UserProc( NamespaceScopes(), NamespaceScopesCollection(), name, Procedure::Function, false, false, false, id );
 		pUserProc->SetParentClass( pClass );
 
-		pUserProc->beginOpAddress=*(long *)(buffer+i2);
-		i2+=sizeof(long);
-		pUserProc->endOpAddress=*(long *)(buffer+i2);
+		pUserProc->SetBeginOpAddress( *(long *)(buffer+i2) );
+		i2+=sizeof(long);
+		pUserProc->SetEndOpAddress( *(long *)(buffer+i2) );
 		i2+=sizeof(long);
 
@@ -620,5 +628,5 @@
 
 		//ローカル変数情報
-		pUserProc->localVars.clear();
+		pUserProc->GetLocalVars().clear();
 		int maxLocalVar=*(long *)(buffer+i2);
 		i2+=sizeof(long);
@@ -638,32 +646,33 @@
 			bool isArray = (buffer[i2++]) ? true:false;
 
-			Variable *pVar = new VariableImpl( name, type, false, isRef );
+			Variable *pVar = new Variable( name, type, false, isRef, "" );
 
 			if(isArray){
-				int SubScripts[MAX_ARRAYDIM];
-				for(i4=0;;i4++){
-					SubScripts[i4]=*(long *)(buffer+i2);
+				Subscripts subscripts;
+				int nSubScriptsNum = *(long *)(buffer+i2);
+				i2+=sizeof(long);
+				for( int i=0; i<nSubScriptsNum; i++ )
+				{
+					subscripts.push_back( *(long *)(buffer+i2) );
 					i2+=sizeof(long);
-
-					if(SubScripts[i4]==-1) break;
 				}
 
-				pVar->SetArray( SubScripts );
+				pVar->SetArray( subscripts );
 			}
 
 			//レキシカルスコープ情報
-			pVar->ScopeStartAddress=*(long *)(buffer+i2);
-			i2+=sizeof(long);
-			pVar->ScopeEndAddress=*(long *)(buffer+i2);
-			i2+=sizeof(long);
-			pVar->ScopeLevel=*(long *)(buffer+i2);
+			pVar->SetScopeStartAddress( *(long *)(buffer+i2) );
+			i2+=sizeof(long);
+			pVar->SetScopeEndAddress( *(long *)(buffer+i2) );
+			i2+=sizeof(long);
+			pVar->SetScopeLevel( *(long *)(buffer+i2) );
 			i2+=sizeof(long);
 
 			//メモリ位置
-			pVar->offset=*(long *)(buffer+i2);
+			pVar->SetOffsetAddress( *(long *)(buffer+i2) );
 			i2+=sizeof(long);
 
 			//変数を追加
-			pUserProc->localVars.push_back( pVar );
+			pUserProc->GetLocalVars().push_back( pVar );
 		}
 
@@ -673,21 +682,11 @@
 		/////////////////////////////////
 
-		i4=hash_default(pUserProc->GetName().c_str());
-
-		GlobalProc *psi2;
-		if(ppSubHash[i4]){
-			psi2=ppSubHash[i4];
-			while(1){
-				if(psi2->pNextData==0){
-					psi2->pNextData=pUserProc;
-					break;
-				}
-				psi2=psi2->pNextData;
-			}
-		}
-		else{
-			ppSubHash[i4]=pUserProc;
-		}
-	}
+		// ハッシュに追加
+		if( !userProcs.Insert( pUserProc, -1 ) )
+		{
+			//return NULL;
+		}
+	}
+	userProcs.Iterator_Init();
 
 	//クラス情報
@@ -709,5 +708,5 @@
 		i2+=sizeof(long);
 
-		//静的メンバ
+		// 動的メンバ
 		int nDynamicMember = *(long *)(buffer+i2);
 		i2+=sizeof(long);
@@ -728,13 +727,19 @@
 			i2+=sizeof(Prototype::Accessibility);
 
-			CMember *member=new CMember( accessibility, name, type, false, "", "" );
-
-			memcpy(member->SubScripts,buffer+i2,sizeof(int)*MAX_ARRAYDIM);
-			i2+=sizeof(int)*MAX_ARRAYDIM;
+			Subscripts subscripts;
+			int nSubScriptsNum = *(long *)(buffer+i2);
+			i2+=sizeof(long);
+			for( int i=0; i<nSubScriptsNum; i++ )
+			{
+				subscripts.push_back( *(long *)(buffer+i2) );
+				i2+=sizeof(long);
+			}
+
+			CMember *member=new CMember( accessibility, name, type, false, subscripts, "", "" );
 
 			pobj_c->GetDynamicMembers().push_back( member );
 		}
 
-		//メソッド
+		// 動的メソッド
 		int nMethod = *(long *)(buffer+i2);
 		i2+=sizeof(long);
@@ -759,9 +764,13 @@
 			pobj_temp_c=pobj_InheritsClass;
 			if(pobj_temp_c==0) pobj_temp_c=pobj_c;
-			i5=hash_default(temp2);
-			pUserProc=ppSubHash[i5];
-			while(1){
-				if( pUserProc->GetName() == temp2 &&pUserProc->GetParentClassPtr()==pobj_temp_c) break;
-				pUserProc=pUserProc->pNextData;
+
+			UserProc *pUserProc = compiler.GetMeta().GetUserProcs().GetHashArrayElement( temp2 );
+			while(pUserProc){
+				if( pUserProc->GetName() == temp2 &&pUserProc->GetParentClassPtr()==pobj_temp_c)
+				{
+					break;
+				}
+
+				pUserProc=pUserProc->GetChainNext();
 			}
 
@@ -790,8 +799,15 @@
 			i2+=sizeof(Prototype::Accessibility);
 
-			CMember *member=new CMember( accessibility, name, type, false, "", "" );
-
-			memcpy(member->SubScripts,buffer+i2,sizeof(int)*MAX_ARRAYDIM);
-			i2+=sizeof(int)*MAX_ARRAYDIM;
+			// 配列
+			Subscripts subscripts;
+			int nSubScriptsNum = *(long *)(buffer+i2);
+			i2+=sizeof(long);
+			for( int i=0; i<nSubScriptsNum; i++ )
+			{
+				subscripts.push_back( *(long *)(buffer+i2) );
+				i2+=sizeof(long);
+			}
+
+			CMember *member=new CMember( accessibility, name, type, false, subscripts, "", "" );
 
 			pobj_c->GetStaticMembers().push_back( member );
@@ -805,6 +821,5 @@
 
 
-	extern GlobalProc **ppSubHash;
-	ppSubHash=this->ppSubHash;
+	compiler.GetMeta().GetUserProcs() = userProcs;
 	pSub_DebugSys_EndProc=GetSubHash("_DebugSys_EndProc");
 
@@ -950,6 +965,6 @@
 
 	//定数を取得
-	extern CONSTINFO **ppConstHash;
-	ppConstHash=this->ppConstHash;
+	compiler.GetMeta().GetGlobalConsts() = this->globalConsts;
+	compiler.GetMeta().GetGlobalConstMacros() = this->globalConstMacros;
 
 	//グローバル実行領域のサイズ
@@ -958,12 +973,7 @@
 
 	//プロシージャ
-	extern char **ppMacroNames;
-	ppMacroNames=0;
-	extern GlobalProc **ppSubHash;
-	extern int SubNum;
-	ppSubHash=this->ppSubHash;
-	SubNum=this->SubNum;
-
-	extern UserProc *pSub_DebugSys_EndProc;
+	compiler.GetMeta().GetUserProcs() = userProcs;
+
+	extern const UserProc *pSub_DebugSys_EndProc;
 	pSub_DebugSys_EndProc=this->pSub_DebugSys_EndProc;
 
@@ -986,10 +996,4 @@
 	delete this->pobj_DBClass;
 	this->pobj_DBClass=0;
-
-	//サブルーチン情報のメモリ解放
-	DeleteSubInfo(ppSubHash,0,0);
-
-	//定数に関する情報を解放
-	DeleteConstInfo(ppConstHash);
 
 	//コードと行番号の関係を解放
