source: dev/trunk/abdev/BasicCompiler_Common/src/Symbol.cpp@ 353

Last change on this file since 353 was 348, checked in by dai_9181, 17 years ago
File size: 2.0 KB
Line 
1#include "stdafx.h"
2
3#include <jenga/include/smoothie/BasicFixed.h>
4#include <jenga/include/smoothie/LexicalAnalysis.h>
5
6#include <Compiler.h>
7#include <Symbol.h>
8
9Symbol::Symbol( const char *fullName )
10 : isTargetObjectModule( true )
11{
12 char areaName[VN_SIZE] = ""; //オブジェクト変数
13 char nestName[VN_SIZE] = ""; //入れ子メンバ
14 bool isNest = SplitMemberName( fullName, areaName, nestName );
15
16 namespaceScopes = NamespaceScopes( areaName );
17 name = nestName;
18}
19Symbol::Symbol( const string &fullName )
20 : isTargetObjectModule( true )
21{
22 char areaName[VN_SIZE] = ""; //オブジェクト変数
23 char nestName[VN_SIZE] = ""; //入れ子メンバ
24 bool isNest = SplitMemberName( fullName.c_str(), areaName, nestName );
25
26 namespaceScopes = NamespaceScopes( areaName );
27 name = nestName;
28}
29
30std::string Symbol::GetFullName() const
31{
32 if( namespaceScopes.size() )
33 {
34 return namespaceScopes.ToString() + "." + name;
35 }
36
37 return name;
38}
39
40bool Symbol::IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const
41{
42 if( GetName() != name ){
43 return false;
44 }
45
46 return compiler.GetNamespaceSupporter().IsSameAreaNamespace( GetNamespaceScopes(), namespaceScopes );
47}
48bool Symbol::IsEqualSymbol( const Symbol &symbol ) const
49{
50 if( IsEqualSymbol( symbol.GetNamespaceScopes(), symbol.GetName() ) )
51 {
52 return true;
53 }
54
55 if( symbol.GetNamespaceScopes().size() >= 1 )
56 {
57 // 静的メンバを考慮
58 NamespaceScopes namespaceScopes( symbol.GetNamespaceScopes() );
59 string name = namespaceScopes[namespaceScopes.size()-1] + "." + symbol.GetName();
60 namespaceScopes.pop_back();
61
62 return IsEqualSymbol( namespaceScopes, name );
63 }
64 return false;
65}
66bool Symbol::IsEqualSymbol( const char *fullName ) const
67{
68 char AreaName[VN_SIZE] = ""; //オブジェクト変数
69 char NestName[VN_SIZE] = ""; //入れ子メンバ
70 bool isNest = SplitMemberName( fullName, AreaName, NestName );
71
72 if( IsEqualSymbol( NamespaceScopes( AreaName ), NestName ) ){
73 return true;
74 }
75
76 return false;
77}
Note: See TracBrowser for help on using the repository browser.