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