Index: trunk/abdev/BasicCompiler_Common/VariableOpe.cpp
===================================================================
--- trunk/abdev/BasicCompiler_Common/VariableOpe.cpp	(revision 199)
+++ trunk/abdev/BasicCompiler_Common/VariableOpe.cpp	(revision 206)
@@ -1,2 +1,4 @@
+#include "stdafx.h"
+
 #include <jenga/include/smoothie/Smoothie.h>
 #include <jenga/include/smoothie/LexicalAnalysis.h>
@@ -4,5 +6,5 @@
 #include <Compiler.h>
 #include <LexicalScopingImpl.h>
-#include <VariableImpl.h>
+#include <Variable.h>
 #include <NamespaceSupporter.h>
 
@@ -247,7 +249,7 @@
 
 
-void GetArrange(char *variable,char *variAnswer,int *SubScripts){
+void GetArrange(char *variable,char *variAnswer, Subscripts &subscripts ){
 	extern int cp;
-	int i,i2,i3,i4;
+	int i,i2,i4;
 	double dbl;
 	_int64 i64data;
@@ -261,5 +263,5 @@
 
 			variAnswer[i]=0;
-			for(i++,i2=0,i3=0;;i++,i2++){
+			for(i++,i2=0;;i++,i2++){
 				if(variable[i]==','){
 					temporary[i2]=0;
@@ -274,10 +276,13 @@
 					}
 
-					if(i64data<0){
+					if(i64data<0)
+					{
 						//error
-						SubScripts[i3]=0;
+						subscripts.push_back( 0 );
 					}
-					else SubScripts[i3]=(int)i64data;
-					i3++;
+					else
+					{
+						subscripts.push_back( (int)i64data );
+					}
 					i2=-1;
 					continue;
@@ -299,5 +304,5 @@
 					temporary[i2]=0;
 					if(i2==0){
-						SubScripts[i3]=-2;
+						subscripts.push_back( -2 );
 						break;
 					}
@@ -314,8 +319,10 @@
 					if(i64data<0){
 						//error
-						SubScripts[i3]=0;
+						subscripts.push_back( 0 );
 					}
-					else SubScripts[i3]=(int)i64data;
-					SubScripts[i3+1]=-1;
+					else
+					{
+						subscripts.push_back( (int)i64data );
+					}
 					break;
 				}
@@ -330,5 +337,4 @@
 		variAnswer[i]=variable[i];
 		if(variable[i]=='\0'){
-			SubScripts[0]=-1;
 			break;
 		}
@@ -337,5 +343,5 @@
 
 
-BOOL GetVarFormatString(char *buffer,char *array,char *array2,char *NestMember,CClass::RefType &refType){
+BOOL GetVarFormatString(char *buffer,char *array,char *array2,char *NestMember,ReferenceKind &refType){
 	extern int cp;
 	int i,i2,i3;
@@ -403,5 +409,5 @@
 		if(buffer[i]=='.'){
 			lstrcpy(NestMember,buffer+i+1);
-			refType = CClass::Dot;
+			refType = RefDot;
 			buffer[i]=0;
 			break;
@@ -409,5 +415,5 @@
 		if(buffer[i]==1&&buffer[i+1]==ESC_PSMEM){
 			lstrcpy(NestMember,buffer+i+2);
-			refType = CClass::Pointer;
+			refType = RefPointer;
 			buffer[i]=0;
 			break;
@@ -459,10 +465,9 @@
 }
 
-int JumpSubScripts(const int *ss){
+int JumpSubScripts( const Subscripts &subscripts ){
 	//DIMで定義された並んだ配列の数だけアドレスを進める
-	int i,i2;
-	for(i=0,i2=1;i<255;i++){
-		if(ss[i]==-1) break;
-		i2*=ss[i]+1;
+	int i, i2;
+	for( i=0,i2=1; i<(int)subscripts.size(); i++ ){
+		i2 *= subscripts[i] + 1;
 	}
 	return i2;
@@ -478,5 +483,5 @@
 	char lpPtrOffset[VN_SIZE];		//第2次配列
 	char NestMember[VN_SIZE];	//入れ子メンバ
-	CClass::RefType refType = CClass::Non;
+	ReferenceKind refType = RefNon;
 	lstrcpy(VarName,lpszMember);
 	if(!GetVarFormatString(VarName,array,lpPtrOffset,NestMember,refType)) return false;
@@ -496,5 +501,5 @@
 
 	//アクセシビリティをチェック
-	if( &objClass == Smoothie::Temp::pCompilingClass ){
+	if( &objClass == compiler.pCompilingClass ){
 		//同一クラスオブジェクトの場合はプライベートアクセスを容認する
 		if( pMember->IsNoneAccess() ){
@@ -519,5 +524,5 @@
 	//ポインタ変数の場合
 	if( resultType.IsPointer() ){
-		if(pMember->SubScripts[0]==-1){
+		if( pMember->GetSubscripts().size() == 0 ){
 			lstrcpy(lpPtrOffset,array);
 			array[0]=0;
@@ -531,5 +536,5 @@
 	}
 
-	if( refType != CClass::Non ){
+	if( refType != RefNon ){
 		//入れ子構造の場合
 
@@ -541,5 +546,5 @@
 	}
 
-	if(array[0]==0&&pMember->SubScripts[0]!=-1){
+	if( array[0] == 0 && pMember->GetSubscripts().size() > 0 ){
 		resultType.SetBasicType( resultType.GetBasicType() | FLAG_PTR );
 		return true;
@@ -573,5 +578,5 @@
 
 	// 先頭オブジェクトまたはクラス名と入れ子メンバに分割
-	CClass::RefType refType;
+	ReferenceKind refType;
 	char member[VN_SIZE],array[VN_SIZE],lpPtrOffset[VN_SIZE];
 	GetVarFormatString(simpleName,array,lpPtrOffset,member,refType);
@@ -587,5 +592,4 @@
 
 	const Variable *pVar = NULL;
-	const int *pSubScripts;
 
 	if( UserProc::IsLocalAreaCompiling() ){
@@ -594,5 +598,5 @@
 		/////////////////
 
-		pVar = UserProc::CompilingUserProc().localVars.BackSearch( Symbol( VarName ) );
+		pVar = UserProc::CompilingUserProc().GetLocalVars().BackSearch( Symbol( VarName ) );
 		if( pVar ){
 			goto ok;
@@ -600,5 +604,5 @@
 	}
 
-	if(Smoothie::Temp::pCompilingClass){
+	if(compiler.pCompilingClass){
 		///////////////////////
 		// クラスメンバの参照
@@ -607,5 +611,5 @@
 		if(lstrcmpi(variable,"This")==0){
 			//Thisオブジェクト
-			resultType.SetType( DEF_OBJECT, Smoothie::Temp::pCompilingClass );
+			resultType.SetType( DEF_OBJECT, compiler.pCompilingClass );
 			return true;
 		}
@@ -620,5 +624,5 @@
 
 			bool isFound = false;
-			BOOST_FOREACH( CMember *pMember, Smoothie::Temp::pCompilingClass->GetDynamicMembers() ){
+			BOOST_FOREACH( CMember *pMember, compiler.pCompilingClass->GetDynamicMembers() ){
 				if( pMember->GetName() == VarName ){
 					isFound = true;
@@ -629,5 +633,5 @@
 		}
 
-		return GetMemberType(*Smoothie::Temp::pCompilingClass,variable,resultType,1,isErrorEnabled);
+		return GetMemberType(*compiler.pCompilingClass,variable,resultType,1,isErrorEnabled);
 	}
 
@@ -643,5 +647,5 @@
 		GetNowStaticVarFullName(VarName,temporary);
 
-		pVar = globalVars.Find( Symbol( temporary ) );
+		pVar = compiler.GetMeta().GetGlobalVars().Find( Symbol( temporary ) );
 		if( pVar ){
 			goto ok;
@@ -659,5 +663,5 @@
 		char tempArray[VN_SIZE];
 		{
-			CClass::RefType refType;
+			ReferenceKind refType;
 			GetVarFormatString(temporary,tempArray,lpPtrOffset,tempMember,refType);
 		}
@@ -672,5 +676,5 @@
 		sprintf(temp2,"%s.%s",VarName,temporary);
 
-		pVar = globalVars.Find( Symbol( temp2 ) );
+		pVar = compiler.GetMeta().GetGlobalVars().Find( Symbol( temp2 ) );
 		if( pVar ){
 			lstrcpy(member,tempMember);
@@ -680,10 +684,10 @@
 	}
 
-	if(Smoothie::Temp::pCompilingClass){
+	if(compiler.pCompilingClass){
 		//自身のクラスから静的メンバを参照する場合
 		char temp2[VN_SIZE];
-		sprintf(temp2,"%s.%s",Smoothie::Temp::pCompilingClass->GetName().c_str(),VarName);
-
-		pVar = globalVars.Find( Symbol( temp2 ) );
+		sprintf(temp2,"%s.%s",compiler.pCompilingClass->GetName().c_str(),VarName);
+
+		pVar = compiler.GetMeta().GetGlobalVars().Find( Symbol( temp2 ) );
 		if( pVar ){
 			goto ok;
@@ -696,5 +700,5 @@
 	////////////////////
 
-	pVar = globalVars.BackSearch( Symbol( VarName ) );
+	pVar = compiler.GetMeta().GetGlobalVars().BackSearch( Symbol( VarName ) );
 	if( pVar ){
 		goto ok;
@@ -708,5 +712,5 @@
 
 	//ポインタ変数の場合
-	if( pVar->IsPointer() ){
+	if( pVar->GetType().IsPointer() ){
 		if( !pVar->IsArray() ){
 			lstrcpy(lpPtrOffset,array);
@@ -721,7 +725,5 @@
 	}
 
-	resultType = (*pVar);
-	pSubScripts=pVar->GetSubScriptsPtr();
-
+	resultType = pVar->GetType();
 
 	if(member[0]){
@@ -732,5 +734,5 @@
 	}
 
-	if(array[0]==0&&pSubScripts[0]!=-1){
+	if( array[0] == 0 && pVar->GetSubscripts().size() > 0 ){
 		//配列の先頭ポインタを示す場合
 		resultType.SetBasicType( resultType.GetBasicType() | FLAG_PTR );
@@ -751,5 +753,5 @@
 }
 
-bool GetVarOffsetReadOnly(const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType,int *pss ){
+bool GetVarOffsetReadOnly(const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType, Subscripts *pResultSubscripts ){
 	//読み取り専用で変数へアクセス
 	return GetVarOffset(
@@ -759,7 +761,8 @@
 		pRelativeVar,
 		resultType,
-		pss);
-}
-bool GetVarOffsetReadWrite(const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType,int *pss ){
+		pResultSubscripts
+	);
+}
+bool GetVarOffsetReadWrite(const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType, Subscripts *pResultSubscripts ){
 	//読み書き両用で変数へアクセス
 	return GetVarOffset(
@@ -769,5 +772,6 @@
 		pRelativeVar,
 		resultType,
-		pss);
+		pResultSubscripts
+	);
 }
 
@@ -776,5 +780,5 @@
 bool GetDimentionFormat( const char *buffer,
 						char *VarName,
-						int *SubScripts,
+						Subscripts &subscripts,
 						Type &type,
 						char *InitBuf,
@@ -924,5 +928,5 @@
 	}
 
-	GetArrange(variable,VarName,SubScripts);
+	GetArrange(variable,VarName,subscripts);
 	return true;
 }
@@ -934,5 +938,5 @@
 	}
 
-	UserProc &proc = UserProc::CompilingUserProc();
+	const UserProc &proc = UserProc::CompilingUserProc();
 
 	//Static識別
@@ -940,6 +944,6 @@
 
 	//クラス名
-	if(Smoothie::Temp::pCompilingClass){
-		lstrcat(FullName,Smoothie::Temp::pCompilingClass->GetName().c_str());
+	if(compiler.pCompilingClass){
+		lstrcat(FullName,compiler.pCompilingClass->GetName().c_str());
 		lstrcat(FullName,"%");
 	}
@@ -951,5 +955,5 @@
 	//ID
 	char temp[255];
-	sprintf(temp,"%x",proc.id);
+	sprintf(temp,"%x",proc.GetId());
 	lstrcat(FullName,temp);
 	lstrcat(FullName,"%");
@@ -962,5 +966,5 @@
 
 
-void AddGlobalVariable( const char *name,int *SubScripts, const Type &type,const char *InitBuf,const char *ConstractParameter,DWORD dwFlag){
+void AddGlobalVariable( const char *name, const Subscripts &subscripts, const Type &type,const char *InitBuf,const char *ConstractParameter,DWORD dwFlag){
 	/////////////////////////
 	// グローバル変数を追加
@@ -969,5 +973,5 @@
 	extern int AllGlobalVarSize;
 
-	if( globalVars.DuplicateCheck( Symbol( name ) ) ){
+	if( compiler.GetMeta().GetGlobalVars().DuplicateCheck( Symbol( name ) ) ){
 		//２重定義のエラー
 		SetError(15,name,cp);
@@ -977,17 +981,14 @@
 	bool isConst = ( dwFlag & DIMFLAG_CONST ) ? true:false;
 
-	Variable *pVar = new VariableImpl( compiler.GetNamespaceSupporter().GetLivingNamespaceScopes(), name, type, isConst );
-
-	if( SubScripts[0] != -1 ){
+	Variable *pVar = new Variable( compiler.GetNamespaceSupporter().GetLivingNamespaceScopes(), name, type, isConst, false, ConstractParameter );
+
+	if( subscripts.size() > 0 ){
 		//配列あり
-		pVar->SetArray( SubScripts );
-	}
-
-	//コンストラクタ用パラメータ
-	pVar->paramStrForConstructor = ConstractParameter;
+		pVar->SetArray( subscripts );
+	}
 
 	//レキシカルスコープ
-	pVar->ScopeLevel=GetLexicalScopes().GetNowLevel();
-	pVar->ScopeStartAddress=GetLexicalScopes().GetStartAddress();
+	pVar->SetScopeLevel( GetLexicalScopes().GetNowLevel() );
+	pVar->SetScopeStartAddress( GetLexicalScopes().GetStartAddress() );
 	pVar->bLiving=TRUE;
 
@@ -996,10 +997,10 @@
 
 	// 変数を追加
-	globalVars.push_back( pVar );
+	compiler.GetMeta().GetGlobalVars().push_back( pVar );
 
 	//アラインメントを考慮
 	int alignment = 0;
-	if( pVar->IsStruct() ){
-		alignment = pVar->GetClass().iAlign;
+	if( pVar->GetType().IsStruct() ){
+		alignment = pVar->GetType().GetClass().iAlign;
 	}
 
@@ -1013,5 +1014,5 @@
 		}
 
-		pVar->offset=AllInitGlobalVarSize;
+		pVar->SetOffsetAddress( AllInitGlobalVarSize );
 		AllInitGlobalVarSize += pVar->GetMemorySize();
 	}
@@ -1025,5 +1026,5 @@
 		}
 
-		pVar->offset=AllGlobalVarSize | 0x80000000;
+		pVar->SetOffsetAddress( AllGlobalVarSize | 0x80000000 );
 		AllGlobalVarSize += pVar->GetMemorySize();
 	}
@@ -1031,5 +1032,5 @@
 	if(InitBuf[0]){
 		int result = 0;
-		if( !pVar->IsObject() ){
+		if( !pVar->GetType().IsObject() ){
 			//初期バッファにデータをセット
 			extern BYTE *initGlobalBuf;
@@ -1039,7 +1040,7 @@
 				AllInitGlobalVarSize);
 
-			result = SetInitGlobalData(pVar->offset,
-				*pVar,
-				pVar->GetSubScriptsPtr(),
+			result = SetInitGlobalData(pVar->GetOffsetAddress(),
+				pVar->GetType(),
+				pVar->GetSubscripts(),
 				InitBuf);
 		}
@@ -1070,5 +1071,5 @@
 		const CMethod *method = type.GetClass().GetDestructorMethod();
 		if( method ){
-			method->pUserProc->Using();
+			method->GetUserProc().Using();
 		}
 	}
@@ -1104,10 +1105,11 @@
 
 		//定数と２重定義されていないる場合は抜け出す
-		if(CDBConst::obj.GetBasicType(VarName)){
+		if(compiler.GetMeta().GetGlobalConsts().GetBasicType(VarName)){
 			return;
 		}
 
 		//定数マクロとして定義されている場合は抜け出す
-		if(GetConstHash(VarName)){
+		if( compiler.GetMeta().GetGlobalConstMacros().IsExist( VarName ) )
+		{
 			return;
 		}
@@ -1115,14 +1117,14 @@
 
 	//構文を解析
-	int SubScripts[MAX_ARRAYDIM];
 	Type type;
 	char InitBuf[8192];
 	char ConstractParameter[VN_SIZE];
-	if(!GetDimentionFormat(Parameter, VarName,SubScripts,type,InitBuf,ConstractParameter))
+	Subscripts subscripts;
+	if(!GetDimentionFormat(Parameter, VarName,subscripts,type,InitBuf,ConstractParameter))
 		return;
 
 
 	//定数と２重定義されていないかを調べる
-	if(CDBConst::obj.GetBasicType(VarName)){
+	if(compiler.GetMeta().GetGlobalConsts().GetBasicType(VarName)){
 		SetError(15,VarName,cp);
 		return;
@@ -1130,5 +1132,5 @@
 
 	//定数マクロとして定義されている場合
-	if(GetConstHash(VarName)){
+	if( compiler.GetMeta().GetGlobalConstMacros().IsExist( VarName ) ){
 		SetError(15,VarName,cp);
 		return;
@@ -1165,5 +1167,5 @@
 		GetNowStaticVarFullName(VarName,temporary);
 
-		dim( temporary,SubScripts,type,InitBuf,ConstractParameter,dwFlags );
+		dim( temporary,subscripts,type,InitBuf,ConstractParameter,dwFlags );
 
 		/*
@@ -1173,5 +1175,5 @@
 	}
 	else{
-		dim( VarName,SubScripts,type,InitBuf,ConstractParameter,dwFlags );
+		dim( VarName,subscripts,type,InitBuf,ConstractParameter,dwFlags );
 	}
 }
