Index: trunk/abdev/BasicCompiler_Common/Subroutine.cpp
===================================================================
--- trunk/abdev/BasicCompiler_Common/Subroutine.cpp	(revision 199)
+++ trunk/abdev/BasicCompiler_Common/Subroutine.cpp	(revision 206)
@@ -1,7 +1,9 @@
+#include "stdafx.h"
+
 #include <jenga/include/smoothie/Smoothie.h>
 #include <jenga/include/smoothie/LexicalAnalysis.h>
 
 #include <Compiler.h>
-#include <ProcedureImpl.h>
+#include <Procedure.h>
 #include <NamespaceSupporter.h>
 
@@ -103,5 +105,5 @@
 		/////////////////////
 
-		UserProc *pUserProc = (UserProc *)pProc;
+		const UserProc *pUserProc = (const UserProc *)pProc;
 
 		//オブジェクト名を取得
@@ -115,5 +117,5 @@
 		////////////////////////
 
-		std::vector<UserProc *> subs;
+		std::vector<const UserProc *> subs;
 		GetOverloadSubHash(fullCallName,subs);
 		if(subs.size()){
@@ -194,5 +196,5 @@
 
 	//オーバーロード用の関数リストを作成
-	std::vector<UserProc *> subs;
+	std::vector<const UserProc *> subs;
 	GetOverloadSubHash(VarName,subs);
 	if(subs.size()==0){
@@ -210,6 +212,5 @@
 
 	//オーバーロードを解決
-	UserProc *pUserProc;
-	pUserProc=OverloadSolutionWithStrParam(VarName,subs,Parameter,ObjectName);
+	const UserProc *pUserProc = OverloadSolutionWithStrParam(VarName,subs,Parameter,ObjectName);
 
 	if(pUserProc){
@@ -238,5 +239,5 @@
 
 	//オーバーロード用の関数リストを作成
-	std::vector<UserProc *> subs;
+	std::vector<const UserProc *> subs;
 	GetOverloadSubHash(VarName,subs);
 	if(subs.size()==0){
@@ -254,6 +255,5 @@
 
 	//オーバーロードを解決
-	UserProc *pUserProc;
-	pUserProc=OverloadSolutionWithStrParam(VarName,subs,Parameter,ObjectName);
+	const UserProc *pUserProc = OverloadSolutionWithStrParam(VarName,subs,Parameter,ObjectName);
 
 	if(pUserProc){
@@ -266,5 +266,5 @@
 //インデクサ（getter）の戻り値を取得
 bool GetReturnTypeOfIndexerGetterProc( const CClass &objClass, Type &resultType ){
-	vector<UserProc *> subs;
+	vector<const UserProc *> subs;
 	objClass.GetMethods().Enum( CALC_ARRAY_GET, subs );
 	if( subs.size() == 0 ){
@@ -369,5 +369,5 @@
 
 	// オブジェクトを生成
-	DllProc *pDllProc = new DllProcImpl( namespaceScopes, procName, kind, isCdecl, dllFileName, alias );
+	DllProc *pDllProc = new DllProc( namespaceScopes, procName, kind, isCdecl, dllFileName, alias );
 
 	// パラメータを解析
@@ -429,184 +429,7 @@
 }
 
-GlobalProc *AddSubData( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, char *buffer,int nowLine,bool isVirtual,CClass *pobj_c, bool isStatic){
-	int i2,i3;
-	char temporary[8192];
-
-	int i=1;
-
-	Procedure::Kind kind = Procedure::Sub;
-	bool isMacro = false;
-	if(buffer[i]==ESC_FUNCTION) kind = Procedure::Function;
-	if(buffer[i]==ESC_MACRO){
-		isMacro = true;
-	}
-
-	i++;
-
-	bool isCdecl = false;
-	bool isExport = false;
-	while(1){
-		if(buffer[i]==1&&buffer[i+1]==ESC_CDECL&& isCdecl == false ){
-			isCdecl = true;
-
-			i+=2;
-		}
-		else if(buffer[i]==1&&buffer[i+1]==ESC_EXPORT&& isExport == false ){
-			isExport = true;
-
-			i+=2;
-		}
-		else break;
-	}
-
-	i2=0;
-	if(buffer[i]==1&&buffer[i+1]==ESC_OPERATOR){
-		if(!pobj_c){
-			SetError(126,NULL,nowLine);
-			return 0;
-		}
-
-		//オペレータの場合
-		temporary[i2++]=buffer[i++];
-		temporary[i2++]=buffer[i++];
-
-		int iCalcId;
-		if(buffer[i]=='='&&buffer[i+1]=='='){
-			iCalcId=CALC_EQUAL;
-			i3=2;
-		}
-		else if(buffer[i]=='='){
-			iCalcId=CALC_SUBSITUATION;
-			i3=1;
-		}
-		else if(buffer[i]=='('){
-			iCalcId=CALC_AS;
-			i3=0;
-		}
-		else if(buffer[i]=='['&&buffer[i+1]==']'&&buffer[i+2]=='='){
-			iCalcId=CALC_ARRAY_SET;
-			i3=3;
-		}
-		else if(buffer[i]=='['&&buffer[i+1]==']'){
-			iCalcId=CALC_ARRAY_GET;
-			i3=2;
-		}
-		else{
-			iCalcId=GetCalcId(buffer+i,&i3);
-			i3++;
-		}
-		if(!iCalcId){
-			SetError(1,NULL,nowLine);
-			return 0;
-		}
-		temporary[i2++]=iCalcId;
-		temporary[i2]=0;
-
-		i+=i3;
-	}
-	else{
-		if(pobj_c){
-			//クラスメンバの場合、デストラクタには~が付くことを考慮
-			if(buffer[i]=='~'){
-				temporary[i2]='~';
-				i++;
-				i2++;
-			}
-		}
-
-		for(;;i++,i2++){
-			if(!IsVariableChar(buffer[i])){
-				temporary[i2]=0;
-				break;
-			}
-			temporary[i2]=buffer[i];
-		}
-	}
-
-	if( isMacro ){
-		//大文字に変換
-		CharUpper(temporary);
-
-		//マクロ関数の場合は名前リストに追加
-		extern char **ppMacroNames;
-		extern int MacroNum;
-		ppMacroNames=(char **)HeapReAlloc(hHeap,0,ppMacroNames,(MacroNum+1)*sizeof(char *));
-		ppMacroNames[MacroNum]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
-		lstrcpy(ppMacroNames[MacroNum],temporary);
-		MacroNum++;
-	}
-
-	if(!pobj_c){
-		//クラスメンバ以外の場合のみ
-		//重複チェック
-
-		if(GetDeclareHash(temporary)){
-			SetError(15,temporary,nowLine);
-			return 0;
-		}
-	}
-
-	extern int SubNum;
-	SubNum++;
-
-	GlobalProc *pUserProc = new GlobalProc( namespaceScopes, importedNamespaces, temporary, kind, isMacro, isCdecl, isExport );
-	pUserProc->SetParentClass( pobj_c );
-	if( Smoothie::isFullCompile ){
-		// すべての関数・メソッドをコンパイルする
-		pUserProc->Using();
-	}
-
-	//ID
-	static int id_base=0;
-	pUserProc->id = (id_base++);
-
-	if(isExport){
-		pUserProc->Using();
-	}
-
-	// パラメータを解析
-	// ※第1パラメータにに指定するデータの例："( s As String ) As String"
-	pUserProc->SetParamsAndReturnType( buffer + i, nowLine, isStatic );
-
-	pUserProc->_paramStr = buffer + i;
-
-
-	/////////////////////////////////
-	// ハッシュデータに追加
-	/////////////////////////////////
-
-	int key;
-	key=hash_default(pUserProc->GetName().c_str());
-
-	extern GlobalProc **ppSubHash;
-	if(ppSubHash[key]){
-		GlobalProc *psi2;
-		psi2=ppSubHash[key];
-		while(1){
-			if(pobj_c==psi2->GetParentClassPtr()){
-				//重複エラーチェックを行う
-				if( pUserProc->IsEqualSymbol( *psi2 ) ){
-					if( psi2->Params().Equals( pUserProc->Params() ) ){
-						SetError(15,pUserProc->GetName().c_str(),nowLine);
-						return 0;
-					}
-				}
-			}
-
-			if(psi2->pNextData==0) break;
-			psi2=psi2->pNextData;
-		}
-		psi2->pNextData=pUserProc;
-	}
-	else{
-		ppSubHash[key]=pUserProc;
-	}
-
-	return pUserProc;
-}
-
-void GetSubInfo(void){	//サブルーチン情報を取得
+void UserProcs::CollectUserProcs( const BasicSource &source, UserProcs &userProcs )
+{
 	extern HANDLE hHeap;
-	extern char *basbuf;
 	int i,i2,i3;
 	char temporary[8192];
@@ -617,14 +440,5 @@
 
 	//サブルーチン（ユーザー定義）情報を初期化
-	extern GlobalProc **ppSubHash;
-	extern int SubNum;
-	ppSubHash=(GlobalProc **)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,MAX_HASH*sizeof(GlobalProc *));
-	SubNum=0;
-
-	//マクロ関数の名前リストを初期化
-	extern char **ppMacroNames;
-	extern int MacroNum;
-	ppMacroNames=(char **)HeapAlloc(hHeap,0,1);
-	MacroNum=0;
+	userProcs.Clear();
 
 	// 名前空間管理
@@ -640,27 +454,27 @@
 		i++;
 
-		if(basbuf[i]==1&&(basbuf[i+1]==ESC_CLASS||basbuf[i+1]==ESC_INTERFACE)){
+		if(source[i]==1&&(source[i+1]==ESC_CLASS||source[i+1]==ESC_INTERFACE)){
 			/*	Class ～ End Class
 				Interface ～ End Interface
 				を飛び越す			*/
-			i3=GetEndXXXCommand(basbuf[i+1]);
+			i3=GetEndXXXCommand(source[i+1]);
 			for(i+=2,i2=0;;i++,i2++){
-				if(basbuf[i]=='\0') break;
-				if(basbuf[i]==1&&basbuf[i+1]==(char)i3){
+				if(source[i]=='\0') break;
+				if(source[i]==1&&source[i+1]==(char)i3){
 					i++;
 					break;
 				}
 			}
-			if(basbuf[i]=='\0') break;
-			continue;
-		}
-
-		if( basbuf[i] == 1 && basbuf[i+1] == ESC_NAMESPACE ){
+			if(source[i]=='\0') break;
+			continue;
+		}
+
+		if( source[i] == 1 && source[i+1] == ESC_NAMESPACE ){
 			for(i+=2,i2=0;;i2++,i++){
-				if( IsCommandDelimitation( basbuf[i] ) ){
+				if( IsCommandDelimitation( source[i] ) ){
 					temporary[i2]=0;
 					break;
 				}
-				temporary[i2]=basbuf[i];
+				temporary[i2]=source[i];
 			}
 			namespaceScopes.push_back( temporary );
@@ -668,5 +482,5 @@
 			continue;
 		}
-		else if( basbuf[i] == 1 && basbuf[i+1] == ESC_ENDNAMESPACE ){
+		else if( source[i] == 1 && source[i+1] == ESC_ENDNAMESPACE ){
 			if( namespaceScopes.size() <= 0 ){
 				SetError(12, "End Namespace", i );
@@ -679,11 +493,11 @@
 			continue;
 		}
-		else if( basbuf[i] == 1 && basbuf[i+1] == ESC_IMPORTS ){
+		else if( source[i] == 1 && source[i+1] == ESC_IMPORTS ){
 			for(i+=2,i2=0;;i2++,i++){
-				if( IsCommandDelimitation( basbuf[i] ) ){
+				if( IsCommandDelimitation( source[i] ) ){
 					temporary[i2]=0;
 					break;
 				}
-				temporary[i2]=basbuf[i];
+				temporary[i2]=source[i];
 			}
 			if( !compiler.GetNamespaceSupporter().ImportsNamespace( temporary ) )
@@ -694,17 +508,17 @@
 			continue;
 		}
-		else if( basbuf[i] == 1 && basbuf[i+1] == ESC_CLEARNAMESPACEIMPORTED ){
+		else if( source[i] == 1 && source[i+1] == ESC_CLEARNAMESPACEIMPORTED ){
 			importedNamespaces.clear();
 			continue;
 		}
 
-		if(basbuf[i]==1&&basbuf[i+1]==ESC_DECLARE){
+		if(source[i]==1&&source[i+1]==ESC_DECLARE){
 			for(i+=2,i2=0;;i2++,i++){
-				if(basbuf[i]=='\n'){
+				if(source[i]=='\n'){
 					temporary[i2]=0;
 					break;
 				}
-				temporary[i2]=basbuf[i];
-				if(basbuf[i]=='\0') break;
+				temporary[i2]=source[i];
+				if(source[i]=='\0') break;
 			}
 			AddDeclareData(namespaceScopes,temporary,i);
@@ -712,16 +526,16 @@
 			continue;
 		}
-		if(basbuf[i]==1&&(basbuf[i+1]==ESC_SUB||basbuf[i+1]==ESC_FUNCTION||basbuf[i+1]==ESC_MACRO)){
-			char statementChar = basbuf[i+1];
+		if(source[i]==1&&(source[i+1]==ESC_SUB||source[i+1]==ESC_FUNCTION||source[i+1]==ESC_MACRO)){
+			char statementChar = source[i+1];
 
 			for(i2=0;;i2++,i++){
-				if(IsCommandDelimitation(basbuf[i])){
+				if(IsCommandDelimitation(source[i])){
 					temporary[i2]=0;
 					break;
 				}
-				temporary[i2]=basbuf[i];
-				if(basbuf[i]=='\0') break;
-			}
-			AddSubData(namespaceScopes, importedNamespaces, temporary,i,0,0);
+				temporary[i2]=source[i];
+				if(source[i]=='\0') break;
+			}
+			userProcs.Add(namespaceScopes, importedNamespaces, temporary,i,false,NULL,false);
 
 			/*	Sub ～ End Sub
@@ -731,11 +545,11 @@
 			char endStatementChar = GetEndXXXCommand( statementChar );
 			for(i2=0;;i++,i2++){
-				if( basbuf[i] == '\0' ) break;
-				if( basbuf[i] == 1 && basbuf[i+1] == endStatementChar ){
+				if( source[i] == '\0' ) break;
+				if( source[i] == 1 && source[i+1] == endStatementChar ){
 					i++;
 					break;
 				}
 			}
-			if(basbuf[i]=='\0') break;
+			if(source[i]=='\0') break;
 			continue;
 		}
@@ -743,7 +557,7 @@
 		//次の行
 		for(;;i++){
-			if(IsCommandDelimitation(basbuf[i])) break;
-		}
-		if(basbuf[i]=='\0') break;
+			if(IsCommandDelimitation(source[i])) break;
+		}
+		if(source[i]=='\0') break;
 	}
 
@@ -755,50 +569,29 @@
 
 	sprintf(temporary,"%c%c_allrem()",1,ESC_SUB);
-	AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);
+	userProcs.Add( namespaceScopes, importedNamespaces, temporary,0,false,NULL,false);
 
 	sprintf(temporary,"%c%c_aullrem()",1,ESC_SUB);
-	AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);
+	userProcs.Add( namespaceScopes, importedNamespaces, temporary,0,false,NULL,false);
 
 	sprintf(temporary,"%c%c_allmul()",1,ESC_SUB);
-	AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);
+	userProcs.Add( namespaceScopes, importedNamespaces, temporary,0,false,NULL,false);
 
 	sprintf(temporary,"%c%c_alldiv()",1,ESC_SUB);
-	AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);
+	userProcs.Add( namespaceScopes, importedNamespaces, temporary,0,false,NULL,false);
 
 	sprintf(temporary,"%c%c_aulldiv()",1,ESC_SUB);
-	AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);
+	userProcs.Add( namespaceScopes, importedNamespaces, temporary,0,false,NULL,false);
 
 	sprintf(temporary,"%c%c_allshl()",1,ESC_SUB);
-	AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);
+	userProcs.Add( namespaceScopes, importedNamespaces, temporary,0,false,NULL,false);
 
 	sprintf(temporary,"%c%c_allshr()",1,ESC_SUB);
-	AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);
+	userProcs.Add( namespaceScopes, importedNamespaces, temporary,0,false,NULL,false);
 
 	sprintf(temporary,"%c%c_aullshr()",1,ESC_SUB);
-	AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);
+	userProcs.Add( namespaceScopes, importedNamespaces, temporary,0,false,NULL,false);
 
 	sprintf(temporary,"%c%c_System_InitStaticLocalVariables()",1,ESC_SUB);
-	AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);
-}
-void Delete_si(GlobalProc *pUserProc){
-	if(pUserProc->pNextData) Delete_si(pUserProc->pNextData);
-	delete pUserProc;
-}
-void DeleteSubInfo(GlobalProc **ppSubHash,char **ppMacroNames,int MacroNum){	//サブルーチン情報のメモリ解放
-	int i;
-	for(i=0;i<MAX_HASH;i++){
-		if(!ppSubHash[i]) continue;
-
-		Delete_si(ppSubHash[i]);
-	}
-	HeapDefaultFree(ppSubHash);
-
-	//マクロの名前リスト
-	if(ppMacroNames){
-		for(i=0;i<MacroNum;i++){
-			HeapDefaultFree(ppMacroNames[i]);
-		}
-		HeapDefaultFree(ppMacroNames);
-	}
+	userProcs.Add( namespaceScopes, importedNamespaces, temporary,0,false,NULL,false);
 }
 void Delete_di(DllProc *pDllProc){
@@ -820,13 +613,10 @@
 
 bool IsNeedProcCompile(){
-	for(int i2=0;i2<MAX_HASH;i2++){
-		extern GlobalProc **ppSubHash;
-		GlobalProc *pUserProc=ppSubHash[i2];
-		while(pUserProc){
-			if( pUserProc->IsUsing() && pUserProc->IsCompiled() == false ){
-				return true;
-			}
-
-			pUserProc=pUserProc->pNextData;
+	compiler.GetMeta().GetUserProcs().Iterator_Reset();
+	while( compiler.GetMeta().GetUserProcs().Iterator_HasNext() )
+	{
+		UserProc *pUserProc = compiler.GetMeta().GetUserProcs().Iterator_GetNext();
+		if( pUserProc->IsUsing() && pUserProc->IsCompiled() == false ){
+			return true;
 		}
 	}
