[206] | 1 | #include "stdafx.h"
|
---|
| 2 |
|
---|
[7] | 3 | double CConst::GetDoubleData(){
|
---|
| 4 | double dbl;
|
---|
| 5 | memcpy(&dbl,&i64data,sizeof(_int64));
|
---|
| 6 | return dbl;
|
---|
| 7 | }
|
---|
| 8 |
|
---|
[600] | 9 | void Consts::Add( const NamespaceScopes &namespaceScopes, const std::string &name, _int64 i64data, const Type &type )
|
---|
[206] | 10 | {
|
---|
[600] | 11 | CConst *newconst = new CConst(namespaceScopes, name, type, i64data);
|
---|
[4] | 12 |
|
---|
[206] | 13 | //ハッシュリストに追加
|
---|
| 14 | Put( newconst );
|
---|
[4] | 15 | }
|
---|
[523] | 16 | void Consts::Add(const NamespaceScopes &namespaceScopes, const std::string &name, int value){
|
---|
[103] | 17 | CConst *newconst = new CConst( namespaceScopes, name, value);
|
---|
[7] | 18 |
|
---|
[206] | 19 | //ハッシュリストに追加
|
---|
| 20 | Put( newconst );
|
---|
[7] | 21 | }
|
---|
| 22 |
|
---|
[579] | 23 | CConst *Consts::GetObjectPtr( const Symbol &symbol )
|
---|
| 24 | {
|
---|
| 25 | CConst *pConst = GetHashArrayElement( symbol.GetName().c_str() );
|
---|
[206] | 26 | while( pConst )
|
---|
| 27 | {
|
---|
[579] | 28 | if( pConst->IsEqualSymbol( symbol ) )
|
---|
[206] | 29 | {
|
---|
| 30 | break;
|
---|
| 31 | }
|
---|
| 32 | pConst = pConst->GetChainNext();
|
---|
[7] | 33 | }
|
---|
| 34 |
|
---|
| 35 | return pConst;
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 |
|
---|
[579] | 39 | int Consts::GetBasicType( const Symbol &symbol ){
|
---|
| 40 | CConst *pConst = GetObjectPtr( symbol );
|
---|
[7] | 41 |
|
---|
| 42 | if(!pConst) return 0;
|
---|
| 43 |
|
---|
[103] | 44 | return pConst->GetType().GetBasicType();
|
---|
[7] | 45 | }
|
---|
[579] | 46 | _int64 Consts::GetWholeData( const Symbol &symbol ){
|
---|
| 47 | CConst *pConst = GetObjectPtr( symbol );
|
---|
[7] | 48 |
|
---|
| 49 | if(!pConst) return 0;
|
---|
| 50 |
|
---|
| 51 | return pConst->GetWholeData();
|
---|
| 52 | }
|
---|
[579] | 53 | double Consts::GetDoubleData( const Symbol &symbol ){
|
---|
| 54 | CConst *pConst = GetObjectPtr( symbol );
|
---|
[7] | 55 |
|
---|
| 56 | if(!pConst) return 0;
|
---|
| 57 |
|
---|
| 58 | return pConst->GetDoubleData();
|
---|
| 59 | }
|
---|
[600] | 60 | bool Consts::IsStringPtr( const Symbol &symbol, bool isUnicode ){
|
---|
[579] | 61 | CConst *pConst = GetObjectPtr( symbol );
|
---|
[103] | 62 |
|
---|
| 63 | if(!pConst) return false;
|
---|
| 64 |
|
---|
| 65 | const Type &type = pConst->GetType();
|
---|
| 66 |
|
---|
[600] | 67 | int charType = isUnicode
|
---|
| 68 | ? MAKE_PTR_TYPE(DEF_WORD,1)
|
---|
| 69 | : MAKE_PTR_TYPE(DEF_SBYTE,1);
|
---|
| 70 |
|
---|
| 71 | return ( type.GetBasicType() == charType && type.GetIndex() == LITERAL_STRING );
|
---|
[103] | 72 | }
|
---|
[206] | 73 |
|
---|
| 74 | // マクロ定数を追加するための関数
|
---|
[579] | 75 | bool ConstMacros::Add( const NamespaceScopes &namespaceScopes, const std::string &name, const char *parameterStr )
|
---|
[206] | 76 | {
|
---|
| 77 | std::vector<std::string> parameters;
|
---|
| 78 |
|
---|
| 79 | int i = 0;
|
---|
| 80 | if(parameterStr[i]!='(')
|
---|
| 81 | {
|
---|
[579] | 82 | return false;
|
---|
[206] | 83 | }
|
---|
| 84 |
|
---|
| 85 | char temporary[VN_SIZE];
|
---|
| 86 | int i2;
|
---|
| 87 | for(i++,i2=0;;i++,i2++){
|
---|
[579] | 88 | if(parameterStr[i]=='\0')
|
---|
| 89 | {
|
---|
| 90 | return false;
|
---|
[206] | 91 | }
|
---|
| 92 | if(parameterStr[i]==','||parameterStr[i]==')'){
|
---|
| 93 | temporary[i2]=0;
|
---|
| 94 |
|
---|
| 95 | parameters.push_back( temporary );
|
---|
| 96 |
|
---|
| 97 | if(parameterStr[i]==')'){
|
---|
| 98 | i++;
|
---|
[579] | 99 | if(parameterStr[i]!='=')
|
---|
| 100 | {
|
---|
| 101 | return false;
|
---|
[206] | 102 | }
|
---|
| 103 | break;
|
---|
| 104 | }
|
---|
| 105 |
|
---|
| 106 | i2=-1;
|
---|
| 107 | continue;
|
---|
| 108 | }
|
---|
| 109 | temporary[i2]=parameterStr[i];
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | //データ
|
---|
| 113 | lstrcpy(temporary,parameterStr+i+1);
|
---|
| 114 |
|
---|
[579] | 115 | this->Put( new ConstMacro( namespaceScopes, name, parameters, temporary ) );
|
---|
| 116 |
|
---|
| 117 | return true;
|
---|
[206] | 118 | }
|
---|
[579] | 119 | ConstMacro *ConstMacros::Find( const Symbol &symbol )
|
---|
| 120 | {
|
---|
| 121 | ConstMacro *pConstMacro = GetHashArrayElement( symbol.GetName().c_str() );
|
---|
[206] | 122 | while( pConstMacro )
|
---|
| 123 | {
|
---|
[579] | 124 | if( pConstMacro->IsEqualSymbol( symbol ) )
|
---|
[206] | 125 | {
|
---|
| 126 | break;
|
---|
| 127 | }
|
---|
| 128 | pConstMacro = pConstMacro->GetChainNext();
|
---|
| 129 | }
|
---|
| 130 |
|
---|
| 131 | return pConstMacro;
|
---|
| 132 | }
|
---|