source: dev/trunk/ab5.0/abdev/ab_common/src/Lexical/Const.cpp@ 700

Last change on this file since 700 was 700, checked in by イグトランス (egtra), 16 years ago

CRequireFilesの管理をhash_setベースへ。保存時にFileIndexの記録を行っていなかった問題を修正。rev.669でコミットし忘れのcompiler_x86/NumOpe.cppを追加。

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