[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 |
|
---|
[640] | 14 | bool Procedure::Resolve( const ObjectModule &resolver, ResolveErrors &resolveErrors )
|
---|
[639] | 15 | {
|
---|
| 16 | BOOST_FOREACH( Parameter *pParameter, params )
|
---|
| 17 | {
|
---|
[640] | 18 | pParameter->Resolve( resolver, resolveErrors );
|
---|
[639] | 19 | }
|
---|
| 20 |
|
---|
[640] | 21 | returnType.Resolve( resolver, resolveErrors );
|
---|
[639] | 22 |
|
---|
| 23 | return true;
|
---|
| 24 | }
|
---|
| 25 |
|
---|
| 26 |
|
---|
[637] | 27 | void UserProc::ResetRelationalObjectModuleIndex( const std::vector<int> &relationTable )
|
---|
| 28 | {
|
---|
| 29 | Procedure::ResetRelationalObjectModuleIndex( relationTable );
|
---|
| 30 |
|
---|
| 31 | this->GetNativeCode().ResetRelationalObjectModuleIndex( relationTable );
|
---|
| 32 | }
|
---|
| 33 |
|
---|
[632] | 34 | int id_base = 0;
|
---|
| 35 |
|
---|
[637] | 36 | UserProc::UserProc( const Symbol &symbol, const NamespaceScopesCollection &importedNamespaces, Kind kind, bool isMacro, bool isCdecl, bool isExport )
|
---|
| 37 | : Procedure( symbol, kind, isCdecl )
|
---|
[632] | 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 |
|
---|
[382] | 89 | bool UserProc::IsEqualForOverride( const Types &actualTypeParametersForThisProc, const UserProc *pUserProc ) const
|
---|
| 90 | {
|
---|
| 91 | if( this->GetName() == pUserProc->GetName() // 名前空間及び名前が等しい
|
---|
[383] | 92 | && this->Params().Equals( actualTypeParametersForThisProc, pUserProc->Params() ) ) // パラメータが等しい
|
---|
[382] | 93 | {
|
---|
| 94 | if( this->returnType.Equals( pUserProc->returnType ) )
|
---|
| 95 | {
|
---|
| 96 | // 戻り値が等しい
|
---|
| 97 | return true;
|
---|
| 98 | }
|
---|
[447] | 99 | else if( this->returnType.IsCovariant( pUserProc->returnType ) )
|
---|
[382] | 100 | {
|
---|
[447] | 101 | // 戻り値が共変
|
---|
| 102 | return true;
|
---|
| 103 | }
|
---|
| 104 | else if( this->returnType.IsTypeParameter() )
|
---|
| 105 | {
|
---|
[382] | 106 | // 型パラメータだったとき
|
---|
[447] | 107 |
|
---|
[382] | 108 | if( actualTypeParametersForThisProc[this->returnType.GetFormalTypeIndex()].Equals( pUserProc->returnType ) )
|
---|
| 109 | {
|
---|
| 110 | // 戻り値が等しい
|
---|
| 111 | return true;
|
---|
| 112 | }
|
---|
[447] | 113 | else if( actualTypeParametersForThisProc[this->returnType.GetFormalTypeIndex()].IsCovariant( pUserProc->returnType ) )
|
---|
| 114 | {
|
---|
| 115 | // 戻り値が共変
|
---|
| 116 | return true;
|
---|
| 117 | }
|
---|
[382] | 118 | }
|
---|
| 119 | }
|
---|
| 120 | return false;
|
---|
| 121 | }
|
---|
| 122 |
|
---|
| 123 |
|
---|
[206] | 124 | std::string UserProc::GetFullName() const
|
---|
| 125 | {
|
---|
| 126 | if( HasParentClass() ){
|
---|
| 127 | return GetParentClass().GetName() + "." + GetName();
|
---|
| 128 | }
|
---|
| 129 |
|
---|
| 130 | return GetName();
|
---|
| 131 | }
|
---|
[350] | 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 | }
|
---|
[206] | 140 | const NamespaceScopes &UserProc::GetNamespaceScopes() const
|
---|
| 141 | {
|
---|
[632] | 142 | if( HasParentClass() )
|
---|
| 143 | {
|
---|
[206] | 144 | return GetParentClassPtr()->GetNamespaceScopes();
|
---|
| 145 | }
|
---|
[208] | 146 | return Symbol::GetNamespaceScopes();
|
---|
[206] | 147 | }
|
---|
| 148 | const NamespaceScopesCollection &UserProc::GetImportedNamespaces() const
|
---|
| 149 | {
|
---|
[306] | 150 | if( pParentClass )
|
---|
| 151 | {
|
---|
| 152 | return pParentClass->GetImportedNamespaces();
|
---|
| 153 | }
|
---|
[206] | 154 | return importedNamespaces;
|
---|
| 155 | }
|
---|
| 156 | bool UserProc::IsVirtual() const
|
---|
| 157 | {
|
---|
| 158 | if( pMethod == NULL ){
|
---|
| 159 | return false;
|
---|
| 160 | }
|
---|
| 161 | return ( pMethod->IsVirtual() != 0 );
|
---|
| 162 | }
|
---|
[336] | 163 | const CMethod &UserProc::GetMethod() const
|
---|
| 164 | {
|
---|
| 165 | if( !HasParentClass() )
|
---|
| 166 | {
|
---|
| 167 | Jenga::Throw( "グローバル関数に対してUserProc::GetMethodメソッドが呼ばれた" );
|
---|
| 168 | }
|
---|
| 169 | return *pMethod;
|
---|
| 170 | }
|
---|
[206] | 171 |
|
---|
[640] | 172 | bool UserProc::Resolve( const ObjectModule &resolver, ResolveErrors &resolveErrors )
|
---|
[637] | 173 | {
|
---|
[640] | 174 | Procedure::Resolve( resolver, resolveErrors );
|
---|
[639] | 175 |
|
---|
[640] | 176 | if( this->pParentClass )
|
---|
[639] | 177 | {
|
---|
[640] | 178 | if( this->pParentClass->IsNeedResolve() )
|
---|
[639] | 179 | {
|
---|
[640] | 180 | const CClass *pTempClass = resolver.meta.GetClasses().FindLike( this->pParentClass );
|
---|
| 181 | if( pTempClass )
|
---|
| 182 | {
|
---|
| 183 | this->pParentClass = pTempClass;
|
---|
| 184 | }
|
---|
| 185 | else
|
---|
| 186 | {
|
---|
| 187 | resolveErrors.Add( ResolveError( this->pParentClass->GetRelationalObjectModuleIndex(), this->pParentClass->GetFullName() ) );
|
---|
| 188 | }
|
---|
[639] | 189 | }
|
---|
| 190 | }
|
---|
| 191 |
|
---|
| 192 | if( pInterface )
|
---|
| 193 | {
|
---|
[640] | 194 | const_cast<Interface *>(pInterface)->Resolve( resolver, resolveErrors );
|
---|
[639] | 195 | }
|
---|
| 196 |
|
---|
| 197 | if( pMethod )
|
---|
| 198 | {
|
---|
[640] | 199 | pMethod->Resolve( resolver, resolveErrors );
|
---|
[639] | 200 | }
|
---|
| 201 |
|
---|
| 202 | BOOST_FOREACH( Parameter *pParameter, realParams )
|
---|
| 203 | {
|
---|
[640] | 204 | pParameter->Resolve( resolver, resolveErrors );
|
---|
[639] | 205 | }
|
---|
| 206 |
|
---|
| 207 | BOOST_FOREACH( Variable *pLocalVar, localVars )
|
---|
| 208 | {
|
---|
[640] | 209 | pLocalVar->Resolve( resolver, resolveErrors );
|
---|
[639] | 210 | }
|
---|
| 211 |
|
---|
[640] | 212 | nativeCode.Resolve( resolver, resolveErrors );
|
---|
[637] | 213 | return true;
|
---|
| 214 | }
|
---|
| 215 |
|
---|
[364] | 216 | const UserProc *UserProc::pGlobalProc = NULL;
|
---|
[206] | 217 |
|
---|
| 218 |
|
---|
[576] | 219 | void UserProcs::EnumGlobalProcs( const char *simpleName, const Symbol &localSymbol, std::vector<const UserProc *> &subs )
|
---|
[184] | 220 | {
|
---|
[206] | 221 | ///////////////////////////
|
---|
| 222 | // グローバル関数を検索
|
---|
| 223 | ///////////////////////////
|
---|
[184] | 224 |
|
---|
[206] | 225 | // ハッシュ値を取得
|
---|
| 226 | UserProc *pUserProc = GetHashArrayElement( simpleName );
|
---|
| 227 | while(pUserProc){
|
---|
[208] | 228 | if( pUserProc->IsGlobalProcedure() ){
|
---|
[576] | 229 | if( pUserProc->IsEqualSymbol( localSymbol ) ){
|
---|
[206] | 230 | subs.push_back( pUserProc );
|
---|
| 231 | }
|
---|
| 232 | }
|
---|
| 233 |
|
---|
| 234 | pUserProc=pUserProc->GetChainNext();
|
---|
| 235 | }
|
---|
[184] | 236 | }
|
---|
| 237 |
|
---|
[640] | 238 | bool DllProc::Resolve( const ObjectModule &resolver, ResolveErrors &resolveErrors )
|
---|
[637] | 239 | {
|
---|
[640] | 240 | Procedure::Resolve( resolver, resolveErrors );
|
---|
[637] | 241 | return true;
|
---|
| 242 | }
|
---|
| 243 |
|
---|
[640] | 244 | bool ProcPointer::Resolve( const ObjectModule &resolver, ResolveErrors &resolveErrors )
|
---|
[637] | 245 | {
|
---|
[640] | 246 | Procedure::Resolve( resolver, resolveErrors );
|
---|
[637] | 247 | return true;
|
---|
| 248 | }
|
---|
| 249 |
|
---|
[206] | 250 | void ProcPointers::Clear()
|
---|
[184] | 251 | {
|
---|
[206] | 252 | ProcPointers &procPointers = *this;
|
---|
[184] | 253 | BOOST_FOREACH( ProcPointer *pProcPointer, procPointers ){
|
---|
| 254 | delete pProcPointer;
|
---|
| 255 | }
|
---|
| 256 | this->clear();
|
---|
| 257 | }
|
---|