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