Index: trunk/abdev/BasicCompiler_Common/Intermediate_Step2.cpp
===================================================================
--- trunk/abdev/BasicCompiler_Common/Intermediate_Step2.cpp	(revision 199)
+++ trunk/abdev/BasicCompiler_Common/Intermediate_Step2.cpp	(revision 206)
@@ -1,2 +1,4 @@
+#include "stdafx.h"
+
 #include <jenga/include/smoothie/Smoothie.h>
 #include <jenga/include/smoothie/LexicalAnalysis.h>
@@ -6,168 +8,5 @@
 #include "../BasicCompiler_Common/common.h"
 
-CONSTINFO *GetNewConstHash(char *name){
-	extern int cp;
-	CONSTINFO *pci;
-
-	int key;
-	key=hash_default(name);
-
-	extern CONSTINFO **ppConstHash;
-	if(ppConstHash[key]){
-		pci=ppConstHash[key];
-		while(1){
-			if(lstrcmp(pci->name,name)==0){
-				//重複エラー
-				SetError(15,name,cp);
-				return 0;
-			}
-
-			if(pci->pNextData==0){
-				pci->pNextData=(CONSTINFO *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,sizeof(CONSTINFO));
-				break;
-			}
-			pci=pci->pNextData;
-		}
-		pci=pci->pNextData;
-	}
-	else{
-		ppConstHash[key]=(CONSTINFO *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,sizeof(CONSTINFO));
-		pci=ppConstHash[key];
-	}
-
-	return pci;
-}
-
-// マクロ定数を追加するための関数
-void AddConstData(char *Command){
-	extern HANDLE hHeap;
-	extern int cp;
-	int i,i2;
-	char temporary[VN_SIZE];
-
-	for(i=0;;i++){
-		if(Command[i]=='\0'){
-			SetError(10,"Const",cp);
-			return;
-		}
-		if(Command[i]=='=' ||  Command[i] == 1 && Command[i+1] == ESC_AS ){
-			//定数定義は新しいクラスモジュール（CDBConst）へ移行
-			// ※この関数はマクロ定数のみを扱う
-			return;
-		}
-		if(Command[i]=='('){
-			temporary[i]=0;
-			break;
-		}
-		temporary[i]=Command[i];
-	}
-
-
-	/////////////////////////////////
-	// 格納位置を計算してpciにセット
-	/////////////////////////////////
-
-	CONSTINFO *pci;
-	pci=GetNewConstHash(temporary);
-	if(!pci) return;
-
-
-
-	////////////////////
-	// 定数情報を取得
-	////////////////////
-
-	//定数名
-	pci->name=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
-	lstrcpy(pci->name,temporary);
-
-	if(Command[i]=='('){
-		pci->ppParm=(char **)HeapAlloc(hHeap,0,1);
-		pci->ParmNum=0;
-		for(i++,i2=0;;i++,i2++){
-			if(Command[i]=='\0'){
-				SetError(1,NULL,cp);
-				return;
-			}
-			if(Command[i]==','||Command[i]==')'){
-				temporary[i2]=0;
-				pci->ppParm=(char **)HeapReAlloc(hHeap,0,pci->ppParm,(pci->ParmNum+1)*sizeof(char *));
-				pci->ppParm[pci->ParmNum]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
-				lstrcpy(pci->ppParm[pci->ParmNum],temporary);
-				pci->ParmNum++;
-				if(Command[i]==')'){
-					i++;
-					if(Command[i]!='='){
-						SetError(1,NULL,cp);
-						return;
-					}
-					break;
-				}
-
-				i2=-1;
-				continue;
-			}
-			temporary[i2]=Command[i];
-		}
-	}
-	else pci->ParmNum=0;
-
-	//データ
-	lstrcpy(temporary,Command+i+1);
-	if(pci->ParmNum){
-		pci->StrValue=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
-		lstrcpy(pci->StrValue,temporary);
-	}
-	else if(temporary[0]=='\"'){
-		//文字列定数
-		RemoveStringQuotes(temporary);
-		i2=lstrlen(temporary);
-
-		pci->StrValue=(char *)HeapAlloc(hHeap,0,i2+1);
-		memcpy(pci->StrValue,temporary,i2);
-		pci->StrValue[i2]=0;
-
-		pci->DblValue=(double)i2;
-
-		pci->type=DEF_STRING;
-		pci->lpIndex=-1;
-	}
-	else if((temporary[0]=='e'||temporary[0]=='E')&&
-		(temporary[1]=='x'||temporary[1]=='X')&&
-		temporary[2]=='\"'){
-		//文字列定数
-		RemoveStringQuotes(temporary+2);
-		i2=FormatString_EscapeSequence(temporary+2);
-		pci->StrValue=(char *)HeapAlloc(hHeap,0,i2+1);
-		memcpy(pci->StrValue,temporary+2,i2);
-		pci->StrValue[i2]=0;
-
-		pci->DblValue=(double)i2;
-
-		pci->type=DEF_STRING;
-		pci->lpIndex=-1;
-	}
-	else{
-		//数値定数
-		_int64 i64data;
-		Type resultType;
-		StaticCalculation(true, temporary,0,&i64data,resultType);
-		pci->type=resultType.GetBasicType();
-		if(IsRealNumberType(pci->type)){
-			//実数型
-			memcpy(&pci->DblValue,&i64data,sizeof(double));
-		}
-		else if(Is64Type(pci->type)){
-			//64ビット型
-			pci->i64Value=i64data;
-		}
-		else if(IsWholeNumberType(pci->type)){
-			//その他整数型
-			pci->DblValue=(double)i64data;
-		}
-
-		pci->StrValue=0;
-	}
-}
+
 void AddConstEnum( const NamespaceScopes &namespaceScopes, char *buffer){
 	extern int cp;
@@ -240,5 +79,5 @@
 
 		//定数を追加
-		CDBConst::obj.AddConst( namespaceScopes, temporary, NextValue);
+		compiler.GetMeta().GetGlobalConsts().Add( namespaceScopes, temporary, NextValue);
 	}
 }
@@ -255,7 +94,7 @@
 	namespaceScopes.clear();
 
-	//定数に関する情報
-	extern CONSTINFO **ppConstHash;
-	ppConstHash=(CONSTINFO **)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,MAX_HASH*sizeof(CONSTINFO *));
+	//定数に関する情報を初期化
+	compiler.GetMeta().GetGlobalConsts().Clear();
+	compiler.GetMeta().GetGlobalConstMacros().Clear();
 
 	extern char *basbuf;
@@ -315,5 +154,5 @@
 					temporary[i2]=basbuf[i];
 				}
-				CDBConst::obj.Add( namespaceScopes, temporary);
+				AddConst( namespaceScopes, temporary);
 				if(basbuf[i]=='\0') break;
 			}
@@ -331,4 +170,9 @@
 		}
 	}
+
+	// イテレータを初期化
+	compiler.GetMeta().GetGlobalConsts().Iterator_Init();
+	compiler.GetMeta().GetGlobalConstMacros().Iterator_Init();
+
 	return true;
 }
