source: dev/trunk/ab5.0/abdev/BasicCompiler_Common/src/Procedure.cpp@ 575

Last change on this file since 575 was 575, checked in by dai_9181, 16 years ago

ProcPointers::Addメソッドを排除。

File size: 3.0 KB
RevLine 
[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]13using namespace ActiveBasic::Compiler;
[206]14
[509]15
[382]16bool 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]51std::string UserProc::GetFullName() const
52{
53 if( HasParentClass() ){
54 return GetParentClass().GetName() + "." + GetName();
55 }
56
57 return GetName();
58}
[350]59bool 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]67const NamespaceScopes &UserProc::GetNamespaceScopes() const
68{
69 if( HasParentClass() ){
70 return GetParentClassPtr()->GetNamespaceScopes();
71 }
[208]72 return Symbol::GetNamespaceScopes();
[206]73}
74const NamespaceScopesCollection &UserProc::GetImportedNamespaces() const
75{
[306]76 if( pParentClass )
77 {
78 return pParentClass->GetImportedNamespaces();
79 }
[206]80 return importedNamespaces;
81}
82bool UserProc::IsVirtual() const
83{
84 if( pMethod == NULL ){
85 return false;
86 }
87 return ( pMethod->IsVirtual() != 0 );
88}
[336]89const CMethod &UserProc::GetMethod() const
90{
91 if( !HasParentClass() )
92 {
93 Jenga::Throw( "グローバル関数に対してUserProc::GetMethodメソッドが呼ばれた" );
94 }
95 return *pMethod;
96}
[206]97
[364]98const UserProc *UserProc::pGlobalProc = NULL;
[206]99
100
101void UserProcs::EnumGlobalProcs( const char *simpleName, const char *localName, std::vector<const UserProc *> &subs )
[184]102{
[206]103 ///////////////////////////
104 // グローバル関数を検索
105 ///////////////////////////
[184]106
[206]107 // ハッシュ値を取得
108 UserProc *pUserProc = GetHashArrayElement( simpleName );
109 while(pUserProc){
[208]110 if( pUserProc->IsGlobalProcedure() ){
[509]111 if( pUserProc->IsEqualSymbol( LexicalAnalyzer::FullNameToSymbol( localName ) ) ){
[206]112 subs.push_back( pUserProc );
113 }
114 }
115
116 pUserProc=pUserProc->GetChainNext();
117 }
[184]118}
119
[206]120void ProcPointers::Clear()
[184]121{
[206]122 ProcPointers &procPointers = *this;
[184]123 BOOST_FOREACH( ProcPointer *pProcPointer, procPointers ){
124 delete pProcPointer;
125 }
126 this->clear();
127}
Note: See TracBrowser for help on using the repository browser.