#include "../BasicCompiler_Common/common.h" #ifdef _AMD64_ #include "../BasicCompiler64/opcode.h" #else #include "../BasicCompiler32/opcode.h" #endif int hash_default(const char *name){ int key; for(key=0;*name!='\0';name++){ key=((key<<8)+ *name )%MAX_HASH; } return key; } CONSTINFO *GetConstHash(const char *name){ //ハッシュ値を取得 int key; key=hash_default(name); //格納位置を取得 extern CONSTINFO **ppConstHash; CONSTINFO *pci; pci=ppConstHash[key]; while(pci){ if(lstrcmp(pci->name,name)==0) break; pci=pci->pNextData; } return pci; } DllProc *GetDeclareHash(char *fullName){ char ObjName[VN_SIZE]; //オブジェクト変数 char NestMember[VN_SIZE]; //入れ子メンバ bool isObjectMember = SplitMemberName( fullName, ObjName, NestMember ); //ハッシュ値を取得 int key; key=hash_default(NestMember); //格納位置を取得 extern DllProc **ppDeclareHash; DllProc *pDllProc; pDllProc=ppDeclareHash[key]; while(pDllProc){ // TODO: Declare名前空間対応 if( pDllProc->IsEqualSymbol( fullName ) ){ break; } pDllProc=pDllProc->pNextData; } return pDllProc; } void GetOverloadSubHash( const char *lpszName, std::vector &subs ){ char name[VN_SIZE]; if(lpszName[0]=='.'){ GetWithName(name); lstrcat(name,lpszName); } else lstrcpy(name,lpszName); char ObjName[VN_SIZE]; //オブジェクト変数 char NestMember[VN_SIZE]; //入れ子メンバ bool isObjectMember = SplitMemberName( name, ObjName, NestMember ); if(isObjectMember){ //オブジェクトのメンバ関数の場合 bool isStatic = false; const CClass *pobj_c = NULL; if(lstrcmpi(ObjName,"Super")==0){ //クラスメンバ関数内から基底クラスの呼び出し pobj_c=pobj_CompilingClass; } else{ //"->"によってオブジェクトを指定する通常のメンバ関数呼び出し Type type; if( GetVarType(ObjName,type,0) ){ pobj_c = &type.GetClass(); } else{ pobj_c=pobj_DBClass->Find(ObjName); if( pobj_c ){ isStatic = true; } } } if( pobj_c && pobj_c != (CClass *)-1 ){ if( isStatic ){ // 静的メソッドから列挙 pobj_c->EnumStaticMethod( NestMember, subs ); } else{ //動的メソッドから列挙 pobj_c->EnumMethod( NestMember, subs ); } return; } } if(pobj_CompilingClass){ //自身のオブジェクトのメンバ関数を検索 // 静的メソッド pobj_CompilingClass->EnumStaticMethod( name, subs ); // 動的メソッド pobj_CompilingClass->EnumMethod( name, subs ); } /////////////////////////// // グローバル関数を検索 /////////////////////////// //ハッシュ値を取得 int key; key=hash_default(NestMember); //格納位置を取得 extern GlobalProc **ppSubHash; GlobalProc *pUserProc; pUserProc=ppSubHash[key]; while(pUserProc){ if(!pUserProc->GetParentClassPtr()){ if( pUserProc->IsEqualSymbol( name ) ){ subs.push_back( pUserProc ); } } pUserProc=pUserProc->pNextData; } } //オーバーロードされていない関数を取得(昔のコンパイラソースコードとの互換性保持) UserProc *GetSubHash(const char *lpszName,BOOL bError){ std::vector subs; GetOverloadSubHash(lpszName,subs); //関数が存在しないとき if(subs.size() == 0){ if(bError){ SetError(3,lpszName,cp); } return 0; } //一つ以上の関数が存在するときは内部エラー(デバッグ用) if(subs.size() > 1){ if(bError) SetError(300,NULL,cp); } UserProc *pUserProc; pUserProc = subs[0]; return pUserProc; } UserProc *GetMethodHash(const char *ObjectName,const char *MethodName,const char *Parameter,BOOL bError){ char temporary[VN_SIZE]; sprintf(temporary,"%s.%s",ObjectName,MethodName); std::vector subs; UserProc *pUserProc; GetOverloadSubHash(temporary,subs); //関数が存在しないとき if(subs.size() == 0){ return 0; } //オーバーロードを解決 pUserProc=OverloadSolutionWithStrParam(temporary,subs,Parameter,ObjectName); return pUserProc; } UserProc *GetClassMethod( const char *className, const char *methodName ){ const CClass *pClass = pobj_DBClass->Find( className ); if( pClass ){ vector userProcs; pClass->EnumMethod( methodName, userProcs ); if( userProcs.size() == 1 ){ return userProcs[0]; } } char temporary[VN_SIZE]; sprintf( temporary, "%s.%s", className, methodName ); SetError(3, temporary, -1 ); return NULL; }