| 1 | #include "stdafx.h"
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 | void Procedure::ResetRelationalObjectModuleIndex( const std::vector<int> &relationTable )
|
|---|
| 5 | {
|
|---|
| 6 | RelationalObjectModuleItem::ResetRelationalObjectModuleIndex( relationTable );
|
|---|
| 7 |
|
|---|
| 8 | if( !this->sourceCodePosition.IsNothing() )
|
|---|
| 9 | {
|
|---|
| 10 | this->sourceCodePosition.SetRelationalObjectModuleIndex( relationTable[this->sourceCodePosition.GetRelationalObjectModuleIndex()] );
|
|---|
| 11 | }
|
|---|
| 12 | }
|
|---|
| 13 |
|
|---|
| 14 | bool Procedure::Resolve( const ObjectModule &resolver )
|
|---|
| 15 | {
|
|---|
| 16 | BOOST_FOREACH( Parameter *pParameter, params )
|
|---|
| 17 | {
|
|---|
| 18 | pParameter->Resolve( resolver );
|
|---|
| 19 | }
|
|---|
| 20 |
|
|---|
| 21 | returnType.Resolve( resolver );
|
|---|
| 22 |
|
|---|
| 23 | return true;
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 | void UserProc::ResetRelationalObjectModuleIndex( const std::vector<int> &relationTable )
|
|---|
| 28 | {
|
|---|
| 29 | Procedure::ResetRelationalObjectModuleIndex( relationTable );
|
|---|
| 30 |
|
|---|
| 31 | this->GetNativeCode().ResetRelationalObjectModuleIndex( relationTable );
|
|---|
| 32 | }
|
|---|
| 33 |
|
|---|
| 34 | int id_base = 0;
|
|---|
| 35 |
|
|---|
| 36 | UserProc::UserProc( const Symbol &symbol, const NamespaceScopesCollection &importedNamespaces, Kind kind, bool isMacro, bool isCdecl, bool isExport )
|
|---|
| 37 | : Procedure( symbol, kind, isCdecl )
|
|---|
| 38 | , importedNamespaces( importedNamespaces )
|
|---|
| 39 | , pParentClass( NULL )
|
|---|
| 40 | , pInterface( NULL )
|
|---|
| 41 | , pMethod( NULL )
|
|---|
| 42 | , isMacro( isMacro )
|
|---|
| 43 | , secondParmNum( 0 )
|
|---|
| 44 | , realSecondParmNum( 1 )
|
|---|
| 45 | , isExport( isExport )
|
|---|
| 46 | , isSystem( false )
|
|---|
| 47 | , isAutoGeneration( false )
|
|---|
| 48 | , isCompiled( false )
|
|---|
| 49 | , beginOpAddress( 0 )
|
|---|
| 50 | , endOpAddress( 0 )
|
|---|
| 51 | , id( id_base ++ )
|
|---|
| 52 | {
|
|---|
| 53 | }
|
|---|
| 54 |
|
|---|
| 55 | UserProc::UserProc( const UserProc &userProc, const CClass *pParentClass )
|
|---|
| 56 | : Procedure( userProc )
|
|---|
| 57 | , _paramStr( userProc._paramStr )
|
|---|
| 58 | , importedNamespaces( userProc.importedNamespaces )
|
|---|
| 59 | , pParentClass( pParentClass )
|
|---|
| 60 | , pInterface( NULL )
|
|---|
| 61 | , pMethod( NULL )
|
|---|
| 62 | , isMacro( userProc.isMacro )
|
|---|
| 63 | , secondParmNum( userProc.secondParmNum )
|
|---|
| 64 | , realParams( userProc.realParams )
|
|---|
| 65 | , realSecondParmNum( userProc.realSecondParmNum )
|
|---|
| 66 | , isExport( userProc.isExport )
|
|---|
| 67 | , isSystem( userProc.isSystem )
|
|---|
| 68 | , isAutoGeneration( userProc.isAutoGeneration )
|
|---|
| 69 | , isCompiled( false )
|
|---|
| 70 | , beginOpAddress( 0 )
|
|---|
| 71 | , endOpAddress( 0 )
|
|---|
| 72 | , localVars( Variables() )
|
|---|
| 73 | , id( id_base ++ )
|
|---|
| 74 | , nativeCode( NativeCode() )
|
|---|
| 75 | {
|
|---|
| 76 | }
|
|---|
| 77 |
|
|---|
| 78 | UserProc::UserProc()
|
|---|
| 79 | {
|
|---|
| 80 | }
|
|---|
| 81 |
|
|---|
| 82 | UserProc::~UserProc()
|
|---|
| 83 | {
|
|---|
| 84 | BOOST_FOREACH( Parameter *pParam, realParams ){
|
|---|
| 85 | delete pParam;
|
|---|
| 86 | }
|
|---|
| 87 | }
|
|---|
| 88 |
|
|---|
| 89 | bool UserProc::IsEqualForOverride( const Types &actualTypeParametersForThisProc, const UserProc *pUserProc ) const
|
|---|
| 90 | {
|
|---|
| 91 | if( this->GetName() == pUserProc->GetName() // 名前空間及び名前が等しい
|
|---|
| 92 | && this->Params().Equals( actualTypeParametersForThisProc, pUserProc->Params() ) ) // パラメータが等しい
|
|---|
| 93 | {
|
|---|
| 94 | if( this->returnType.Equals( pUserProc->returnType ) )
|
|---|
| 95 | {
|
|---|
| 96 | // 戻り値が等しい
|
|---|
| 97 | return true;
|
|---|
| 98 | }
|
|---|
| 99 | else if( this->returnType.IsCovariant( pUserProc->returnType ) )
|
|---|
| 100 | {
|
|---|
| 101 | // 戻り値が共変
|
|---|
| 102 | return true;
|
|---|
| 103 | }
|
|---|
| 104 | else if( this->returnType.IsTypeParameter() )
|
|---|
| 105 | {
|
|---|
| 106 | // 型パラメータだったとき
|
|---|
| 107 |
|
|---|
| 108 | if( actualTypeParametersForThisProc[this->returnType.GetFormalTypeIndex()].Equals( pUserProc->returnType ) )
|
|---|
| 109 | {
|
|---|
| 110 | // 戻り値が等しい
|
|---|
| 111 | return true;
|
|---|
| 112 | }
|
|---|
| 113 | else if( actualTypeParametersForThisProc[this->returnType.GetFormalTypeIndex()].IsCovariant( pUserProc->returnType ) )
|
|---|
| 114 | {
|
|---|
| 115 | // 戻り値が共変
|
|---|
| 116 | return true;
|
|---|
| 117 | }
|
|---|
| 118 | }
|
|---|
| 119 | }
|
|---|
| 120 | return false;
|
|---|
| 121 | }
|
|---|
| 122 |
|
|---|
| 123 |
|
|---|
| 124 | std::string UserProc::GetFullName() const
|
|---|
| 125 | {
|
|---|
| 126 | if( HasParentClass() ){
|
|---|
| 127 | return GetParentClass().GetName() + "." + GetName();
|
|---|
| 128 | }
|
|---|
| 129 |
|
|---|
| 130 | return GetName();
|
|---|
| 131 | }
|
|---|
| 132 | bool UserProc::IsCastOperator() const
|
|---|
| 133 | {
|
|---|
| 134 | if( GetName()[0] == 1 && GetName()[1] == ESC_OPERATOR && GetName()[2] == CALC_AS )
|
|---|
| 135 | {
|
|---|
| 136 | return true;
|
|---|
| 137 | }
|
|---|
| 138 | return false;
|
|---|
| 139 | }
|
|---|
| 140 | const NamespaceScopes &UserProc::GetNamespaceScopes() const
|
|---|
| 141 | {
|
|---|
| 142 | if( HasParentClass() )
|
|---|
| 143 | {
|
|---|
| 144 | return GetParentClassPtr()->GetNamespaceScopes();
|
|---|
| 145 | }
|
|---|
| 146 | return Symbol::GetNamespaceScopes();
|
|---|
| 147 | }
|
|---|
| 148 | const NamespaceScopesCollection &UserProc::GetImportedNamespaces() const
|
|---|
| 149 | {
|
|---|
| 150 | if( pParentClass )
|
|---|
| 151 | {
|
|---|
| 152 | return pParentClass->GetImportedNamespaces();
|
|---|
| 153 | }
|
|---|
| 154 | return importedNamespaces;
|
|---|
| 155 | }
|
|---|
| 156 | bool UserProc::IsVirtual() const
|
|---|
| 157 | {
|
|---|
| 158 | if( pMethod == NULL ){
|
|---|
| 159 | return false;
|
|---|
| 160 | }
|
|---|
| 161 | return ( pMethod->IsVirtual() != 0 );
|
|---|
| 162 | }
|
|---|
| 163 | const CMethod &UserProc::GetMethod() const
|
|---|
| 164 | {
|
|---|
| 165 | if( !HasParentClass() )
|
|---|
| 166 | {
|
|---|
| 167 | Jenga::Throw( "グローバル関数に対してUserProc::GetMethodメソッドが呼ばれた" );
|
|---|
| 168 | }
|
|---|
| 169 | return *pMethod;
|
|---|
| 170 | }
|
|---|
| 171 |
|
|---|
| 172 | bool UserProc::Resolve( const ObjectModule &resolver )
|
|---|
| 173 | {
|
|---|
| 174 | Procedure::Resolve( resolver );
|
|---|
| 175 |
|
|---|
| 176 | if( pParentClass )
|
|---|
| 177 | {
|
|---|
| 178 | if( pParentClass->IsNeedResolve() )
|
|---|
| 179 | {
|
|---|
| 180 | pParentClass = resolver.meta.GetClasses().FindLike( pParentClass );
|
|---|
| 181 | }
|
|---|
| 182 | }
|
|---|
| 183 |
|
|---|
| 184 | if( pInterface )
|
|---|
| 185 | {
|
|---|
| 186 | const_cast<Interface *>(pInterface)->Resolve( resolver );
|
|---|
| 187 | }
|
|---|
| 188 |
|
|---|
| 189 | if( pMethod )
|
|---|
| 190 | {
|
|---|
| 191 | pMethod->Resolve( resolver );
|
|---|
| 192 | }
|
|---|
| 193 |
|
|---|
| 194 | BOOST_FOREACH( Parameter *pParameter, realParams )
|
|---|
| 195 | {
|
|---|
| 196 | pParameter->Resolve( resolver );
|
|---|
| 197 | }
|
|---|
| 198 |
|
|---|
| 199 | BOOST_FOREACH( Variable *pLocalVar, localVars )
|
|---|
| 200 | {
|
|---|
| 201 | pLocalVar->Resolve( resolver );
|
|---|
| 202 | }
|
|---|
| 203 |
|
|---|
| 204 | nativeCode.Resolve( resolver );
|
|---|
| 205 | return true;
|
|---|
| 206 | }
|
|---|
| 207 |
|
|---|
| 208 | const UserProc *UserProc::pGlobalProc = NULL;
|
|---|
| 209 |
|
|---|
| 210 |
|
|---|
| 211 | void UserProcs::EnumGlobalProcs( const char *simpleName, const Symbol &localSymbol, std::vector<const UserProc *> &subs )
|
|---|
| 212 | {
|
|---|
| 213 | ///////////////////////////
|
|---|
| 214 | // グローバル関数を検索
|
|---|
| 215 | ///////////////////////////
|
|---|
| 216 |
|
|---|
| 217 | // ハッシュ値を取得
|
|---|
| 218 | UserProc *pUserProc = GetHashArrayElement( simpleName );
|
|---|
| 219 | while(pUserProc){
|
|---|
| 220 | if( pUserProc->IsGlobalProcedure() ){
|
|---|
| 221 | if( pUserProc->IsEqualSymbol( localSymbol ) ){
|
|---|
| 222 | subs.push_back( pUserProc );
|
|---|
| 223 | }
|
|---|
| 224 | }
|
|---|
| 225 |
|
|---|
| 226 | pUserProc=pUserProc->GetChainNext();
|
|---|
| 227 | }
|
|---|
| 228 | }
|
|---|
| 229 |
|
|---|
| 230 | bool DllProc::Resolve( const ObjectModule &resolver )
|
|---|
| 231 | {
|
|---|
| 232 | Procedure::Resolve( resolver );
|
|---|
| 233 | return true;
|
|---|
| 234 | }
|
|---|
| 235 |
|
|---|
| 236 | bool ProcPointer::Resolve( const ObjectModule &resolver )
|
|---|
| 237 | {
|
|---|
| 238 | Procedure::Resolve( resolver );
|
|---|
| 239 | return true;
|
|---|
| 240 | }
|
|---|
| 241 |
|
|---|
| 242 | void ProcPointers::Clear()
|
|---|
| 243 | {
|
|---|
| 244 | ProcPointers &procPointers = *this;
|
|---|
| 245 | BOOST_FOREACH( ProcPointer *pProcPointer, procPointers ){
|
|---|
| 246 | delete pProcPointer;
|
|---|
| 247 | }
|
|---|
| 248 | this->clear();
|
|---|
| 249 | }
|
|---|