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

Last change on this file since 504 was 504, checked in by dai_9181, 15 years ago

Symbol::RegistNamespaceSupporterメソッドを追加。

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