source: dev/branches/egtra/ab5.0/abdev/BasicCompiler_Common/hash.cpp@ 806

Last change on this file since 806 was 806, checked in by イグトランス (egtra), 13 years ago

コンパイラのstdafx.h, .cppを32/64ビットで共通化。Windows SDKに含まれるライブラリ・ヘッダの除去。VC++ 2010 Express with WDKのATL環境で_SECURE_ATLがエラーを起こす問題の修正。4996警告の抑制pragmaを削除。ほか。

File size: 4.2 KB
RevLine 
[206]1#include "stdafx.h"
2
[193]3#include <Compiler.h>
4
[4]5#include "../BasicCompiler_Common/common.h"
6
7#ifdef _AMD64_
[485]8#include "../compiler_x64/opcode.h"
[4]9#else
[484]10#include "../compiler_x86/opcode.h"
[4]11#endif
12
[509]13using namespace ActiveBasic::Compiler;
14
[209]15DllProc *GetDeclareHash(const char *fullName){
16 char namespaceStr[VN_SIZE]; //オブジェクト変数
17 char simpleName[VN_SIZE]; //入れ子メンバ
18 bool isObjectMember = SplitMemberName( fullName, namespaceStr, simpleName );
[113]19
[209]20 ///////////////////////////
21 // グローバル関数を検索
22 ///////////////////////////
[4]23
[209]24 // ハッシュ値を取得
[803]25 foreach (auto pDllProc, compiler.GetObjectModule().meta.GetDllProcs().GetHashArrayElement(simpleName))
26 {
[509]27 if( pDllProc->IsEqualSymbol( LexicalAnalyzer::FullNameToSymbol( fullName ) ) ){
[209]28 return pDllProc;
[75]29 }
[4]30 }
31
[209]32 return NULL;
[4]33}
34
[206]35void GetOverloadSubHash( const char *lpszName, std::vector<const UserProc *> &subs ){
[4]36 char name[VN_SIZE];
37
38 if(lpszName[0]=='.'){
39 GetWithName(name);
40 lstrcat(name,lpszName);
41 }
42 else lstrcpy(name,lpszName);
43
44 char ObjName[VN_SIZE]; //オブジェクト変数
45 char NestMember[VN_SIZE]; //入れ子メンバ
[206]46 bool isObjectMember = SplitMemberName( name, ObjName, NestMember );
[4]47
[28]48 if(isObjectMember){
[4]49 //オブジェクトのメンバ関数の場合
50
[27]51 bool isStatic = false;
[75]52 const CClass *pobj_c = NULL;
[304]53 if(lstrcmpi(ObjName,"Super")==0)
54 {
[27]55 //クラスメンバ関数内から基底クラスの呼び出し
[536]56 pobj_c=&compiler.GetCompilingClass().GetSuperClass();
[27]57 }
[304]58 else
59 {
[47]60 //"->"によってオブジェクトを指定する通常のメンバ関数呼び出し
[75]61 Type type;
[415]62 if( GetTermType(ObjName,type) )
63 {
64 if( type.IsObject() )
65 {
66 pobj_c = &type.GetClass();
67 }
[100]68 }
[415]69
70 if( !pobj_c )
71 {
[598]72 pobj_c = compiler.GetObjectModule().meta.FindClassSupportedTypeDef(
73 LexicalAnalyzer::FullNameToSymbol( ObjName )
74 );
[47]75 if( pobj_c ){
76 isStatic = true;
77 }
[28]78 }
[4]79 }
80
[101]81 if( pobj_c && pobj_c != (CClass *)-1 ){
[100]82 if( isStatic ){
83 // 静的メソッドから列挙
[136]84 pobj_c->GetStaticMethods().Enum( NestMember, subs );
[100]85 }
86 else{
87 //動的メソッドから列挙
[350]88 pobj_c->EnumDynamicMethodsOrInterfaceMethods( NestMember, subs );
[100]89 }
[304]90
[100]91 return;
[4]92 }
93 }
94
95
[536]96 if( compiler.IsCompilingClass() ){
[100]97 //自身のオブジェクトのメンバ関数を検索
[4]98
[100]99 // 静的メソッド
[536]100 compiler.GetCompilingClass().GetStaticMethods().Enum( name, subs );
[4]101
[100]102 // 動的メソッド
[536]103 compiler.GetCompilingClass().EnumDynamicMethodsOrInterfaceMethods( name, subs );
[100]104 }
[27]105
106
[100]107 // グローバル関数を検索
[576]108 compiler.GetObjectModule().meta.GetUserProcs().EnumGlobalProcs( NestMember, LexicalAnalyzer::FullNameToSymbol( name ), subs );
[4]109}
110
111//オーバーロードされていない関数を取得(昔のコンパイラソースコードとの互換性保持)
[206]112const UserProc *GetSubHash(const char *lpszName,BOOL bError){
113 std::vector<const UserProc *> subs;
[50]114 GetOverloadSubHash(lpszName,subs);
[4]115
116 //関数が存在しないとき
[50]117 if(subs.size() == 0){
[75]118 if(bError){
[465]119 compiler.errorMessenger.Output(3,lpszName,cp);
[75]120 }
[4]121 return 0;
122 }
123
124 //一つ以上の関数が存在するときは内部エラー(デバッグ用)
[50]125 if(subs.size() > 1){
[465]126 if(bError) compiler.errorMessenger.Output(300,NULL,cp);
[4]127 }
128
[206]129 const UserProc *pUserProc = subs[0];
[4]130
[75]131 return pUserProc;
[5]132}
[206]133const UserProc *GetMethodHash(const char *ObjectName,const char *MethodName,const char *Parameter,BOOL bError){
[5]134 char temporary[VN_SIZE];
135 sprintf(temporary,"%s.%s",ObjectName,MethodName);
136
[206]137 std::vector<const UserProc *> subs;
[50]138 GetOverloadSubHash(temporary,subs);
[5]139
140 //関数が存在しないとき
[50]141 if(subs.size() == 0){
[5]142 return 0;
143 }
144
145 //オーバーロードを解決
[206]146 const UserProc *pUserProc = OverloadSolutionWithStrParam(temporary,subs,Parameter,ObjectName);
[5]147
[75]148 return pUserProc;
[5]149}
[95]150
[206]151const UserProc *GetClassMethod( const char *className, const char *methodName ){
[598]152 const CClass *pClass = compiler.GetObjectModule().meta.FindClassSupportedTypeDef(
153 LexicalAnalyzer::FullNameToSymbol( className )
154 );
[95]155 if( pClass ){
[523]156 std::vector<const UserProc *> userProcs;
[350]157 pClass->EnumDynamicMethodsOrInterfaceMethods( methodName, userProcs );
[95]158 if( userProcs.size() == 1 ){
159 return userProcs[0];
160 }
161 }
162
163 char temporary[VN_SIZE];
164 sprintf( temporary, "%s.%s", className, methodName );
[465]165 compiler.errorMessenger.Output(3, temporary, -1 );
[95]166
167 return NULL;
168}
Note: See TracBrowser for help on using the repository browser.