source: dev/trunk/ab5.0/abdev/BasicCompiler_Common/include/Symbol.h@ 508

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

Symbolコンストラクタを少なくし、LexicalAnalyzer::FullNameToSymbolメソッドを実装。

File size: 2.0 KB
Line 
1#pragma once
2
3#include <vector>
4#include <string>
5
6#include <BoostSerializationSupport.h>
7
8using namespace std;
9
10class Symbol
11{
12 static const NamespaceSupporter *namespaceSupporter;
13
14 NamespaceScopes namespaceScopes;
15 string name;
16
17 // XMLシリアライズ用
18private:
19 friend class boost::serialization::access;
20 BOOST_SERIALIZATION_SPLIT_MEMBER();
21 template<class Archive> void load(Archive& ar, const unsigned int version)
22 {
23 //trace_for_serialize( "serializing(load) - Symbol" );
24
25 ar & BOOST_SERIALIZATION_NVP( namespaceScopes );
26
27 std::string _name;
28 ar & BOOST_SERIALIZATION_NVP( _name );
29 this->name = Operator_NaturalStringToCalcMarkString( _name );
30 }
31 template<class Archive> void save(Archive& ar, const unsigned int version) const
32 {
33 //trace_for_serialize( "serializing(save) - Symbol" );
34
35 ar & BOOST_SERIALIZATION_NVP( namespaceScopes );
36
37 std::string _name = Operator_CalcMarkStringToNaturalString( name );
38 ar & BOOST_SERIALIZATION_NVP( _name );
39 }
40
41public:
42 bool isTargetObjectModule;
43 Symbol( const NamespaceScopes &namespaceScopes, const string &name )
44 : namespaceScopes( namespaceScopes )
45 , name( name )
46 , isTargetObjectModule( true )
47 {
48 }
49 Symbol( const Symbol &symbol )
50 : namespaceScopes( symbol.namespaceScopes )
51 , name( symbol.name )
52 , isTargetObjectModule( true )
53 {
54 }
55 Symbol()
56 : isTargetObjectModule( true )
57 {
58 }
59
60 static void RegistNamespaceSupporter( const NamespaceSupporter *namespaceSupporter )
61 {
62 Symbol::namespaceSupporter = namespaceSupporter;
63 }
64
65 virtual const NamespaceScopes &GetNamespaceScopes() const
66 {
67 return namespaceScopes;
68 }
69 const string &GetName() const
70 {
71 return name;
72 }
73 std::string GetFullName() const;
74
75 // シンボル比較
76 bool IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const;
77 bool IsEqualSymbol( const Symbol &symbol ) const;
78 bool IsEqualSymbol( const char *fullName ) const;
79 bool IsEqualSymbol( const string &fullName ) const
80 {
81 return IsEqualSymbol( fullName.c_str() );
82 }
83};
Note: See TracBrowser for help on using the repository browser.