Index: trunk/abdev/BasicCompiler_Common/src/Procedure.cpp
===================================================================
--- trunk/abdev/BasicCompiler_Common/src/ProcedureImpl.cpp	(revision 199)
+++ trunk/abdev/BasicCompiler_Common/src/Procedure.cpp	(revision 206)
@@ -1,7 +1,10 @@
+#include "stdafx.h"
+
+#include <jenga/include/smoothie/Smoothie.h>
 #include <jenga/include/smoothie/SmoothieException.h>
 #include <jenga/include/smoothie/LexicalAnalysis.h>
 
 #include <Compiler.h>
-#include <ProcedureImpl.h>
+#include <Procedure.h>
 #include <NamespaceSupporter.h>
 
@@ -13,5 +16,53 @@
 #endif
 
-bool UserProcImpl::SetParamsAndReturnType( const char *sourceOfParams, int nowLine, bool isStatic ){
+
+std::string UserProc::GetFullName() const
+{
+	if( HasParentClass() ){
+		return GetParentClass().GetName() + "." + GetName();
+	}
+
+	return GetName();
+}
+const NamespaceScopes &UserProc::GetNamespaceScopes() const
+{
+	if( HasParentClass() ){
+		return GetParentClassPtr()->GetNamespaceScopes();
+	}
+	return namespaceScopes;
+}
+const NamespaceScopesCollection &UserProc::GetImportedNamespaces() const
+{
+	return importedNamespaces;
+}
+bool UserProc::IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const
+{
+	if( GetName() != name ){
+		return false;
+	}
+
+	return compiler.GetNamespaceSupporter().IsSameAreaNamespace( GetNamespaceScopes(), namespaceScopes );
+}
+bool UserProc::IsEqualSymbol( const UserProc &globalProc ) const
+{
+	return IsEqualSymbol( globalProc.GetNamespaceScopes(), globalProc.GetName() );
+}
+bool UserProc::IsEqualSymbol( const string &fullName ) const
+{
+	char AreaName[VN_SIZE] = "";		//オブジェクト変数
+	char NestName[VN_SIZE] = "";		//入れ子メンバ
+	bool isNest = SplitMemberName( fullName.c_str(), AreaName, NestName );
+
+	return IsEqualSymbol( NamespaceScopes( AreaName ), NestName );
+}
+bool UserProc::IsVirtual() const
+{
+	if( pMethod == NULL ){
+		return false;
+	}
+	return ( pMethod->IsVirtual() != 0 );
+}
+
+bool UserProc::SetParamsAndReturnType( const char *sourceOfParams, int nowLine, bool isStatic ){
 	int i = 0;
 	int i2,i3,sw;
@@ -51,5 +102,5 @@
 		//パラメータ名
 		bool isArray = false;
-		int subScripts[MAX_ARRAYDIM];
+		Subscripts subscripts;
 		char name[VN_SIZE];
 		sw=0;
@@ -83,12 +134,12 @@
 
 			if((name[i2-2]=='('&&name[i2-1]==')')||
-				(name[i2-2]=='['&&name[i2-1]==']')){
-				subScripts[0]=LONG_MAX;
-				subScripts[1]=-1;
+				(name[i2-2]=='['&&name[i2-1]==']'))
+			{
+				subscripts.push_back( LONG_MAX );
 
 				name[i2-2]=0;
 			}
 			else{
-				GetArrange(name,temp2,subScripts);
+				GetArrange(name,temp2,subscripts);
 				lstrcpy(name,temp2);
 			}
@@ -152,5 +203,5 @@
 		Parameter *pParam = new Parameter( name, type, isRef, initValue );
 		if( isArray ){
-			pParam->SetArray( subScripts );
+			pParam->SetArray( subscripts );
 		}
 
@@ -189,5 +240,5 @@
 			//パラメータ名
 			bool isArray = false;
-			int subScripts[MAX_ARRAYDIM];
+			Subscripts subscripts;
 			char name[VN_SIZE];
 			sw=0;
@@ -221,12 +272,12 @@
 
 				if((name[i2-2]=='('&&name[i2-1]==')')||
-					(name[i2-2]=='['&&name[i2-1]==']')){
-					subScripts[0]=LONG_MAX;
-					subScripts[1]=-1;
+					(name[i2-2]=='['&&name[i2-1]==']'))
+				{
+					subscripts.push_back( LONG_MAX );
 
 					name[i2-2]=0;
 				}
 				else{
-					GetArrange(name,temp2,subScripts);
+					GetArrange(name,temp2,subscripts);
 					lstrcpy(name,temp2);
 				}
@@ -273,5 +324,5 @@
 			Parameter *pParam = new Parameter( name, type, isRef );
 			if( isArray ){
-				pParam->SetArray( subScripts );
+				pParam->SetArray( subscripts );
 			}
 
@@ -376,40 +427,216 @@
 }
 
-const NamespaceScopes &GlobalProc::GetNamespaceScopes() const
-{
-	if( HasParentClass() ){
-		return GetParentClassPtr()->GetNamespaceScopes();
-	}
-	return namespaceScopes;
-}
-bool GlobalProc::IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const
+const UserProc *UserProc::pCompilingUserProc = NULL;
+
+
+bool UserProcs::Insert( UserProc *pUserProc, int nowLine )
+{
+	/////////////////////////////////
+	// ハッシュデータに追加
+	/////////////////////////////////
+
+	if( !Put( pUserProc ) )
+	{
+		// 重複しているため、失敗
+		SetError(15,pUserProc->GetName().c_str(),nowLine);
+		return false;
+	}
+
+	return true;
+}
+UserProc *UserProcs::Add( 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);
+
+		//マクロ関数の場合は名前リストに追加
+		macroNames.push_back( temporary );
+	}
+
+	if(!pobj_c){
+		//クラスメンバ以外の場合のみ
+		//重複チェック
+
+		if(GetDeclareHash(temporary)){
+			SetError(15,temporary,nowLine);
+			return 0;
+		}
+	}
+
+	// 識別ID
+	static int id_base=0;
+
+	UserProc *pUserProc = new UserProc( namespaceScopes, importedNamespaces, temporary, kind, isMacro, isCdecl, isExport, (id_base++) );
+	pUserProc->SetParentClass( pobj_c );
+	if( Smoothie::isFullCompile ){
+		// すべての関数・メソッドをコンパイルする
+		pUserProc->Using();
+	}
+
+	if(isExport){
+		pUserProc->Using();
+	}
+
+	// パラメータを解析
+	// ※第1パラメータにに指定するデータの例："( s As String ) As String"
+	pUserProc->SetParamsAndReturnType( buffer + i, nowLine, isStatic );
+
+	pUserProc->_paramStr = buffer + i;
+
+	// ハッシュに追加
+	if( !Insert( pUserProc, nowLine ) )
+	{
+		return NULL;
+	}
+
+	return pUserProc;
+}
+void UserProcs::EnumGlobalProcs( const char *simpleName, const char *localName, std::vector<const UserProc *> &subs )
+{
+	///////////////////////////
+	// グローバル関数を検索
+	///////////////////////////
+
+	// ハッシュ値を取得
+	UserProc *pUserProc = GetHashArrayElement( simpleName );
+	while(pUserProc){
+		if(!pUserProc->GetParentClassPtr()){
+			if( pUserProc->IsEqualSymbol( localName ) ){
+				subs.push_back( pUserProc );
+			}
+		}
+
+		pUserProc=pUserProc->GetChainNext();
+	}
+}
+
+
+bool DllProc::IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const
 {
 	if( GetName() != name ){
 		return false;
 	}
-
-	return compiler.GetNamespaceSupporter().IsSameAreaNamespace( GetNamespaceScopes(), namespaceScopes );
-}
-bool GlobalProc::IsEqualSymbol( const GlobalProc &globalProc ) const
-{
-	return IsEqualSymbol( globalProc.GetNamespaceScopes(), globalProc.GetName() );
-}
-bool GlobalProc::IsEqualSymbol( const string &fullName ) const
+	return compiler.GetNamespaceSupporter().IsSameAreaNamespace( this->GetNamespaceScopes(), namespaceScopes );
+}
+bool DllProc::IsEqualSymbol( const string &fullName ) const
 {
 	char AreaName[VN_SIZE] = "";		//オブジェクト変数
 	char NestName[VN_SIZE] = "";		//入れ子メンバ
-	bool isNest = CClass::SplitName( fullName.c_str(), AreaName, NestName );
-
-	return IsEqualSymbol( NamespaceScopes( AreaName ), NestName );
-}
-
-bool DllProcImpl::IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const
-{
-	if( GetName() != name ){
-		return false;
-	}
-	return compiler.GetNamespaceSupporter().IsSameAreaNamespace( this->GetNamespaceScopes(), namespaceScopes );
-}
-bool DllProcImpl::SetParamsAndReturnType( const char *sourceOfParams, int nowLine ){
+	bool isNest = SplitMemberName( fullName.c_str(), AreaName, NestName );
+
+	if( IsEqualSymbol( NamespaceScopes( AreaName ), NestName ) ){
+		return true;
+	}
+
+	if( isNest ){
+		// 静的メンバを考慮
+
+		char AreaName2[VN_SIZE] = "";		//オブジェクト変数
+		char NestName2[VN_SIZE] = "";		//入れ子メンバ
+		bool isNest = SplitMemberName( AreaName, AreaName2, NestName2 );
+		lstrcat( NestName2, "." );
+		lstrcat( NestName2, NestName );
+
+		return IsEqualSymbol( NamespaceScopes( AreaName2 ), NestName2 );
+	}
+
+	return false;
+}
+bool DllProc::SetParamsAndReturnType( const char *sourceOfParams, int nowLine ){
 	int i = 0;
 	int i2,i3,sw;
@@ -443,5 +670,5 @@
 		//パラメータ名
 		bool isArray = false;
-		int subScripts[MAX_ARRAYDIM];
+		Subscripts subscripts;
 		char name[VN_SIZE];
 		sw=0;
@@ -475,12 +702,12 @@
 
 			if((name[i2-2]=='('&&name[i2-1]==')')||
-				(name[i2-2]=='['&&name[i2-1]==']')){
-				subScripts[0]=LONG_MAX;
-				subScripts[1]=-1;
+				(name[i2-2]=='['&&name[i2-1]==']'))
+			{
+				subscripts.push_back( LONG_MAX );
 
 				name[i2-2]=0;
 			}
 			else{
-				GetArrange(name,temp2,subScripts);
+				GetArrange(name,temp2,subscripts);
 				lstrcpy(name,temp2);
 			}
@@ -528,5 +755,5 @@
 		Parameter *pParam = new Parameter( name, type, isRef );
 		if( isArray ){
-			pParam->SetArray( subScripts );
+			pParam->SetArray( subscripts );
 		}
 
@@ -584,5 +811,5 @@
 }
 
-bool ProcPointerImpl::SetParamsAndReturnType( const char *sourceOfParams, int nowLine ){
+bool ProcPointer::SetParamsAndReturnType( const char *sourceOfParams, int nowLine ){
 	int i = 0;
 	int i2,i3,sw;
@@ -615,5 +842,5 @@
 		//パラメータ名
 		bool isArray = false;
-		int subScripts[MAX_ARRAYDIM];
+		Subscripts subscripts;
 		char name[VN_SIZE];
 		sw=0;
@@ -647,12 +874,12 @@
 
 			if((name[i2-2]=='('&&name[i2-1]==')')||
-				(name[i2-2]=='['&&name[i2-1]==']')){
-				subScripts[0]=LONG_MAX;
-				subScripts[1]=-1;
+				(name[i2-2]=='['&&name[i2-1]==']'))
+			{
+				subscripts.push_back( LONG_MAX );
 
 				name[i2-2]=0;
 			}
 			else{
-				GetArrange(name,temp2,subScripts);
+				GetArrange(name,temp2,subscripts);
 				lstrcpy(name,temp2);
 			}
@@ -699,5 +926,5 @@
 		Parameter *pParam = new Parameter( name, type, isRef );
 		if( isArray ){
-			pParam->SetArray( subScripts );
+			pParam->SetArray( subscripts );
 		}
 
@@ -771,5 +998,5 @@
 }
 
-int ProcPointersImpl::Add( const string &typeExpression )
+int ProcPointers::Add( const string &typeExpression )
 {
 	DWORD dwProcType = (DWORD)typeExpression[2];
@@ -781,5 +1008,5 @@
 	}
 
-	ProcPointer *pProcPointer = new ProcPointerImpl( kind );
+	ProcPointer *pProcPointer = new ProcPointer( kind );
 
 	//buffer[0]は'('となっている
@@ -792,7 +1019,7 @@
 }
 
-void ProcPointersImpl::Clear()
-{
-	ProcPointersImpl &procPointers = *this;
+void ProcPointers::Clear()
+{
+	ProcPointers &procPointers = *this;
 	BOOST_FOREACH( ProcPointer *pProcPointer, procPointers ){
 		delete pProcPointer;
