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