Ignore:
Timestamp:
Jul 12, 2007, 2:58:26 AM (17 years ago)
Author:
dai_9181
Message:

コード全体のリファクタリングを実施

File:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/abdev/BasicCompiler_Common/include/Const.h

    r201 r206  
    11#pragma once
    22
    3 #include <jenga/include/smoothie/Type.h>
     3#include <Type.h>
     4#include <Symbol.h>
    45
    5 //定数の基底クラス
    6 class ConstBase{
    7     const string name;
    8     const NamespaceScopes namespaceScopes;
     6
     7void AddConst( const NamespaceScopes &namespaceScopes, char *buffer );
     8
     9//定数
     10class CConst : public Symbol, public Jenga::Common::ObjectInHashmap<CConst>
     11{
     12    Type type;
     13    _int64 i64data;
     14
     15    // XMLシリアライズ用
     16private:
     17    friend class boost::serialization::access;
     18    template<class Archive> void serialize(Archive& ar, const unsigned int version)
     19    {
     20        trace_for_serialize( "serializing - CConst" );
     21
     22        ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Symbol );
     23        ar & BOOST_SERIALIZATION_NVP( type );
     24        ar & BOOST_SERIALIZATION_NVP( i64data );
     25    }
    926
    1027public:
    1128
    12     ConstBase( const NamespaceScopes &namespaceScopes, const string &name )
    13         : namespaceScopes( namespaceScopes )
    14         , name( name )
     29    CConst( const NamespaceScopes &namespaceScopes, const std::string &name, const Type &newType, _int64 i64data)
     30        : Symbol( namespaceScopes, name )
     31        , type( newType )
     32        , i64data( i64data )
    1533    {
    1634    }
    17     ~ConstBase()
     35    CConst( const NamespaceScopes &namespaceScopes, const std::string &name, int value)
     36        : Symbol( namespaceScopes, name )
     37        , type( Type(DEF_LONG) )
     38        , i64data( value )
     39    {
     40    }
     41    CConst()
     42    {
     43    }
     44    ~CConst()
    1845    {
    1946    }
    2047
    21     const string &GetName() const
     48    virtual const std::string &GetKeyName() const
    2249    {
    23         return name;
     50        return GetName();
    2451    }
    2552
    26     bool IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const;
    27     bool IsEqualSymbol( const string &name ) const;
    28 };
    29 
    30 //定数
    31 class CConst:public ConstBase{
    32     Type type;
    33     _int64 i64data;
    34 
    35 public:
    36     CConst *pNext;
    37 
    38     CConst( const NamespaceScopes &namespaceScopes, const string &name, const Type &newType, _int64 i64data);
    39     CConst( const NamespaceScopes &namespaceScopes, const string &name, int value);
    40     ~CConst();
    41 
    42     Type GetType();
    43     _int64 GetWholeData();
     53    Type GetType()
     54    {
     55        return type;
     56    }
     57    _int64 GetWholeData()
     58    {
     59        return i64data;
     60    }
    4461    double GetDoubleData();
    4562};
     63class Consts : public Jenga::Common::Hashmap<CConst>
     64{
     65    // XMLシリアライズ用
     66private:
     67    friend class boost::serialization::access;
     68    template<class Archive> void serialize(Archive& ar, const unsigned int version)
     69    {
     70        trace_for_serialize( "serializing - Consts" );
    4671
    47 //定数マクロ
    48 class CConstMacro:public ConstBase{
    49     int ParmNum;
    50     char **ppParm;
    51 public:
    52 
    53     CConstMacro( const NamespaceScopes &namespaceScopes, const string &name, char *Expression);
    54     ~CConstMacro();
    55 };
    56 
    57 //定数管理クラス
    58 class CDBConst{
    59     CConst **ppHash;
    60 
    61     CConstMacro **ppobj_Macro;
    62     int NumOfMacro;
    63 
    64     //シングルトンクラスなので、プライベートに置く
    65     CDBConst();
    66     ~CDBConst();
    67     void _free();
    68     void Free();
     72        ar & boost::serialization::make_nvp("Hashmap_CConst",
     73            boost::serialization::base_object<Jenga::Common::Hashmap<CConst>>(*this));
     74    }
    6975
    7076public:
    7177
    72     void Init();
    73 
    7478    void Add( const NamespaceScopes &namespaceScopes, char *buffer);
    75 private:
    76     void AddConst( const string &name, CConst *newconst);
    77 public:
    78     void AddConst( const NamespaceScopes &namespaceScopes, const string &name, char *Expression);
    79     void AddConst( const NamespaceScopes &namespaceScopes, const string &name, int value);
     79    void Add( const NamespaceScopes &namespaceScopes, const string &name, char *Expression);
     80    void Add( const NamespaceScopes &namespaceScopes, const string &name, int value);
    8081
    8182private:
     
    8788    double GetDoubleData(char *Name);
    8889    bool IsStringPtr(char *Name);
     90};
    8991
     92//定数マクロ
     93class ConstMacro : public Symbol, public Jenga::Common::ObjectInHashmap<ConstMacro>
     94{
     95    std::vector<std::string> parameters;
     96    std::string expression;
    9097
    91     //シングルトンオブジェクト
    92     static CDBConst obj;
     98    // XMLシリアライズ用
     99private:
     100    friend class boost::serialization::access;
     101    template<class Archive> void serialize(Archive& ar, const unsigned int version)
     102    {
     103        trace_for_serialize( "serializing - ConstMacro" );
     104
     105        ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Symbol );
     106        ar & BOOST_SERIALIZATION_NVP( parameters );
     107        ar & BOOST_SERIALIZATION_NVP( expression );
     108    }
     109
     110public:
     111    ConstMacro( const NamespaceScopes &namespaceScopes, const std::string &name, const std::vector<std::string> &parameters, const string &expression )
     112        : Symbol( namespaceScopes, name )
     113        , parameters( parameters )
     114        , expression( expression )
     115    {
     116    }
     117    ConstMacro()
     118    {
     119    }
     120    ~ConstMacro()
     121    {
     122    }
     123
     124    virtual const std::string &GetKeyName() const
     125    {
     126        return GetName();
     127    }
     128
     129    const std::vector<std::string> &GetParameters() const
     130    {
     131        return parameters;
     132    }
     133    const std::string &GetExpression() const
     134    {
     135        return expression;
     136    }
     137
     138    bool GetCalcBuffer( const char *parameterStr, char *dest ) const;
    93139};
     140class ConstMacros : public Jenga::Common::Hashmap<ConstMacro>
     141{
     142    // XMLシリアライズ用
     143private:
     144    friend class boost::serialization::access;
     145    template<class Archive> void serialize(Archive& ar, const unsigned int version)
     146    {
     147        trace_for_serialize( "serializing - ConstMacros" );
     148
     149        ar & boost::serialization::make_nvp("Hashmap_ConstMacro",
     150            boost::serialization::base_object<Jenga::Common::Hashmap<ConstMacro>>(*this));
     151    }
     152
     153public:
     154    void Add( const NamespaceScopes &namespaceScopes, const std::string &name, const char *parameterStr );
     155    ConstMacro *Find( const std::string &name );
     156};
Note: See TracChangeset for help on using the changeset viewer.