[206] | 1 | #include "stdafx.h"
|
---|
| 2 |
|
---|
[193] | 3 | #include <Compiler.h>
|
---|
[206] | 4 | #include <Procedure.h>
|
---|
[184] | 5 |
|
---|
| 6 | #include "../common.h"
|
---|
| 7 | #ifdef _AMD64_
|
---|
[485] | 8 | #include "../../compiler_x64/opcode.h"
|
---|
[184] | 9 | #else
|
---|
[484] | 10 | #include "../../compiler_x86/opcode.h"
|
---|
[184] | 11 | #endif
|
---|
| 12 |
|
---|
[509] | 13 | using namespace ActiveBasic::Compiler;
|
---|
[206] | 14 |
|
---|
[509] | 15 |
|
---|
[382] | 16 | bool UserProc::IsEqualForOverride( const Types &actualTypeParametersForThisProc, const UserProc *pUserProc ) const
|
---|
| 17 | {
|
---|
| 18 | if( this->GetName() == pUserProc->GetName() // 名前空間及び名前が等しい
|
---|
[383] | 19 | && this->Params().Equals( actualTypeParametersForThisProc, pUserProc->Params() ) ) // パラメータが等しい
|
---|
[382] | 20 | {
|
---|
| 21 | if( this->returnType.Equals( pUserProc->returnType ) )
|
---|
| 22 | {
|
---|
| 23 | // 戻り値が等しい
|
---|
| 24 | return true;
|
---|
| 25 | }
|
---|
[447] | 26 | else if( this->returnType.IsCovariant( pUserProc->returnType ) )
|
---|
[382] | 27 | {
|
---|
[447] | 28 | // 戻り値が共変
|
---|
| 29 | return true;
|
---|
| 30 | }
|
---|
| 31 | else if( this->returnType.IsTypeParameter() )
|
---|
| 32 | {
|
---|
[382] | 33 | // 型パラメータだったとき
|
---|
[447] | 34 |
|
---|
[382] | 35 | if( actualTypeParametersForThisProc[this->returnType.GetFormalTypeIndex()].Equals( pUserProc->returnType ) )
|
---|
| 36 | {
|
---|
| 37 | // 戻り値が等しい
|
---|
| 38 | return true;
|
---|
| 39 | }
|
---|
[447] | 40 | else if( actualTypeParametersForThisProc[this->returnType.GetFormalTypeIndex()].IsCovariant( pUserProc->returnType ) )
|
---|
| 41 | {
|
---|
| 42 | // 戻り値が共変
|
---|
| 43 | return true;
|
---|
| 44 | }
|
---|
[382] | 45 | }
|
---|
| 46 | }
|
---|
| 47 | return false;
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 |
|
---|
[206] | 51 | std::string UserProc::GetFullName() const
|
---|
| 52 | {
|
---|
| 53 | if( HasParentClass() ){
|
---|
| 54 | return GetParentClass().GetName() + "." + GetName();
|
---|
| 55 | }
|
---|
| 56 |
|
---|
| 57 | return GetName();
|
---|
| 58 | }
|
---|
[350] | 59 | bool UserProc::IsCastOperator() const
|
---|
| 60 | {
|
---|
| 61 | if( GetName()[0] == 1 && GetName()[1] == ESC_OPERATOR && GetName()[2] == CALC_AS )
|
---|
| 62 | {
|
---|
| 63 | return true;
|
---|
| 64 | }
|
---|
| 65 | return false;
|
---|
| 66 | }
|
---|
[206] | 67 | const NamespaceScopes &UserProc::GetNamespaceScopes() const
|
---|
| 68 | {
|
---|
| 69 | if( HasParentClass() ){
|
---|
| 70 | return GetParentClassPtr()->GetNamespaceScopes();
|
---|
| 71 | }
|
---|
[208] | 72 | return Symbol::GetNamespaceScopes();
|
---|
[206] | 73 | }
|
---|
| 74 | const NamespaceScopesCollection &UserProc::GetImportedNamespaces() const
|
---|
| 75 | {
|
---|
[306] | 76 | if( pParentClass )
|
---|
| 77 | {
|
---|
| 78 | return pParentClass->GetImportedNamespaces();
|
---|
| 79 | }
|
---|
[206] | 80 | return importedNamespaces;
|
---|
| 81 | }
|
---|
| 82 | bool UserProc::IsVirtual() const
|
---|
| 83 | {
|
---|
| 84 | if( pMethod == NULL ){
|
---|
| 85 | return false;
|
---|
| 86 | }
|
---|
| 87 | return ( pMethod->IsVirtual() != 0 );
|
---|
| 88 | }
|
---|
[336] | 89 | const CMethod &UserProc::GetMethod() const
|
---|
| 90 | {
|
---|
| 91 | if( !HasParentClass() )
|
---|
| 92 | {
|
---|
| 93 | Jenga::Throw( "グローバル関数に対してUserProc::GetMethodメソッドが呼ばれた" );
|
---|
| 94 | }
|
---|
| 95 | return *pMethod;
|
---|
| 96 | }
|
---|
[206] | 97 |
|
---|
[364] | 98 | const UserProc *UserProc::pGlobalProc = NULL;
|
---|
[206] | 99 |
|
---|
| 100 |
|
---|
| 101 | bool UserProcs::Insert( UserProc *pUserProc, int nowLine )
|
---|
[184] | 102 | {
|
---|
[206] | 103 | /////////////////////////////////
|
---|
| 104 | // ハッシュデータに追加
|
---|
| 105 | /////////////////////////////////
|
---|
| 106 |
|
---|
| 107 | if( !Put( pUserProc ) )
|
---|
| 108 | {
|
---|
| 109 | // 重複しているため、失敗
|
---|
[465] | 110 | compiler.errorMessenger.Output(15,pUserProc->GetName().c_str(),nowLine);
|
---|
[206] | 111 | return false;
|
---|
[184] | 112 | }
|
---|
[206] | 113 |
|
---|
| 114 | return true;
|
---|
[184] | 115 | }
|
---|
[206] | 116 |
|
---|
| 117 | void UserProcs::EnumGlobalProcs( const char *simpleName, const char *localName, std::vector<const UserProc *> &subs )
|
---|
[184] | 118 | {
|
---|
[206] | 119 | ///////////////////////////
|
---|
| 120 | // グローバル関数を検索
|
---|
| 121 | ///////////////////////////
|
---|
[184] | 122 |
|
---|
[206] | 123 | // ハッシュ値を取得
|
---|
| 124 | UserProc *pUserProc = GetHashArrayElement( simpleName );
|
---|
| 125 | while(pUserProc){
|
---|
[208] | 126 | if( pUserProc->IsGlobalProcedure() ){
|
---|
[509] | 127 | if( pUserProc->IsEqualSymbol( LexicalAnalyzer::FullNameToSymbol( localName ) ) ){
|
---|
[206] | 128 | subs.push_back( pUserProc );
|
---|
| 129 | }
|
---|
| 130 | }
|
---|
| 131 |
|
---|
| 132 | pUserProc=pUserProc->GetChainNext();
|
---|
| 133 | }
|
---|
[184] | 134 | }
|
---|
| 135 |
|
---|
[523] | 136 | int ProcPointers::Add( const std::string &typeExpression )
|
---|
[184] | 137 | {
|
---|
| 138 | DWORD dwProcType = (DWORD)typeExpression[2];
|
---|
[523] | 139 | const std::string ¶mStr = typeExpression.substr( 3 );
|
---|
[184] | 140 |
|
---|
| 141 | Procedure::Kind kind = Procedure::Sub;
|
---|
| 142 | if( dwProcType == ESC_FUNCTION ){
|
---|
| 143 | kind = Procedure::Function;
|
---|
| 144 | }
|
---|
| 145 |
|
---|
[206] | 146 | ProcPointer *pProcPointer = new ProcPointer( kind );
|
---|
[184] | 147 |
|
---|
| 148 | //buffer[0]は'('となっている
|
---|
| 149 | extern int cp;
|
---|
[573] | 150 | LexicalAnalyzer::SetParamsAndReturnType( pProcPointer, paramStr.c_str(), false, cp );
|
---|
[184] | 151 |
|
---|
| 152 | this->push_back( pProcPointer );
|
---|
| 153 |
|
---|
| 154 | return (int)this->size()-1;
|
---|
| 155 | }
|
---|
| 156 |
|
---|
[206] | 157 | void ProcPointers::Clear()
|
---|
[184] | 158 | {
|
---|
[206] | 159 | ProcPointers &procPointers = *this;
|
---|
[184] | 160 | BOOST_FOREACH( ProcPointer *pProcPointer, procPointers ){
|
---|
| 161 | delete pProcPointer;
|
---|
| 162 | }
|
---|
| 163 | this->clear();
|
---|
| 164 | }
|
---|