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

Last change on this file since 666 was 640, checked in by dai_9181, 16 years ago

静的リンクリンカの依存関係解決モジュールを製作中

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