source: dev/trunk/ab5.0/abdev/BasicCompiler_Common/include/NativeCode.h@ 597

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

インクルード順序を整理

File size: 5.8 KB
RevLine 
[224]1#pragma once
2
[244]3class UserProc;
4
[224]5class Schedule
6{
7public:
8 enum Type
9 {
[237]10 None = 10000,
[225]11 GlobalVar, // グローバル変数スケジュール
[237]12 DataTable, // データテーブル スケジュール
[357]13 CatchAddress, // Catchアドレス スケジュール
[225]14 Relocation, // リロケーション情報スケジュール
[244]15 UserProc, // ユーザ定義関数呼び出し側スケジュール
16 AddressOf, // ユーザ定義関数位置スケジュール
[257]17 DllProc, // DLL関数位置スケジュール
[370]18 ComVtbl, // com_vtblスケジュール
[282]19 Vtbl, // vtblスケジュール
[355]20 TypeInfo, // TypeInfoスケジュール
[224]21 };
22
23private:
24 Type type;
[244]25 long offset;
[224]26
[244]27 union{
28 LONG_PTR lpValue;
29 const ::UserProc *pUserProc;
[250]30 const ::DllProc *pDllProc;
[282]31 const ::CClass *pClass;
[244]32 };
33
[224]34 // XMLシリアライズ用
35private:
36 friend class boost::serialization::access;
37 template<class Archive> void serialize(Archive& ar, const unsigned int version)
38 {
[256]39 trace_for_serialize( "serializing - Schedule" );
40
[224]41 ar & BOOST_SERIALIZATION_NVP( type );
42 ar & BOOST_SERIALIZATION_NVP( offset );
[272]43
44 switch( type )
45 {
46 case UserProc:
47 case AddressOf:
[357]48 case CatchAddress:
[278]49 ar & boost::serialization::make_nvp("pUserProc", const_cast<::UserProc *&>(pUserProc));
[272]50 break;
51 case DllProc:
[278]52 ar & boost::serialization::make_nvp("pDllProc", const_cast<::DllProc *&>(pDllProc));
[272]53 break;
[370]54 case ComVtbl:
[282]55 case Vtbl:
[355]56 case TypeInfo:
[282]57 ar & boost::serialization::make_nvp("pClass", const_cast<::CClass *&>(pClass));
58 break;
[272]59 default:
60 ar & BOOST_SERIALIZATION_NVP( lpValue );
61 break;
62 }
[224]63 }
64
65public:
66 Schedule()
67 {
68 }
[258]69 Schedule( Type type, long offset, LONG_PTR lpValue = 0 )
[224]70 : type( type )
71 , offset( offset )
[258]72 , lpValue( lpValue )
[224]73 {
74 }
[550]75 Schedule( Schedule::Type type, const ::UserProc *pUserProc, long offset )
76 : type( type )
[244]77 , offset( offset )
78 , pUserProc( pUserProc )
79 {
80 }
[258]81 Schedule( const ::DllProc *pDllProc, long offset )
[257]82 : type( Schedule::DllProc )
[250]83 , offset( offset )
84 , pDllProc( pDllProc )
85 {
86 }
[355]87 Schedule( Type type, const ::CClass *pClass, long offset )
88 : type( type )
89 , pClass( pClass )
90 , offset( offset )
91 {
[370]92 if( !( type == Schedule::ComVtbl || type == Schedule::Vtbl || type == Schedule::TypeInfo ) )
93 {
94 DebugBreak();
95 }
[355]96 }
[224]97 ~Schedule()
98 {
99 }
[244]100
[257]101 Type GetType() const
102 {
103 return type;
104 }
105 long GetOffset() const
106 {
107 return offset;
108 }
[258]109 LONG_PTR GetLongPtrValue() const
110 {
111 return lpValue;
112 }
[465]113 const ::DllProc &GetDllProc() const;
114 const ::UserProc &GetUserProc() const;
115 const ::CClass &GetClass() const;
[224]116};
117typedef std::vector<Schedule> Schedules;
118
[263]119#define CODETYPE_SYSTEMPROC 0x0001
120#define CODETYPE_DEBUGPROC 0x0002
121class SourceLine
122{
123 int lineNum;
124 long nativeCodePos;
[280]125 int sourceIndex;
[263]126 long sourceCodePos;
127 DWORD codeType;
128
129 // XMLシリアライズ用
130private:
131 friend class boost::serialization::access;
132 template<class Archive> void serialize(Archive& ar, const unsigned int version)
133 {
134 trace_for_serialize( "serializing - SourceLine" );
135
136 ar & BOOST_SERIALIZATION_NVP( lineNum );
137 ar & BOOST_SERIALIZATION_NVP( nativeCodePos );
[280]138 ar & BOOST_SERIALIZATION_NVP( sourceIndex );
[263]139 ar & BOOST_SERIALIZATION_NVP( sourceCodePos );
140 ar & BOOST_SERIALIZATION_NVP( codeType );
141 }
142
143public:
[280]144 SourceLine( int lineNum, int nativeCodePos, int sourceIndex, int sourceCodePos, DWORD codeType )
[263]145 : lineNum( lineNum )
146 , nativeCodePos( nativeCodePos )
[280]147 , sourceIndex( sourceIndex )
[263]148 , sourceCodePos( sourceCodePos )
149 , codeType( codeType )
150 {
151 }
152 SourceLine()
153 {
154 }
155
156 int GetLineNum() const
157 {
158 return lineNum;
159 }
160 long GetNativeCodePos() const
161 {
162 return nativeCodePos;
163 }
[280]164 int GetSourceIndex() const
165 {
166 return sourceIndex;
167 }
168 void SetSourceIndex( int sourceIndex )
169 {
170 this->sourceIndex = sourceIndex;
171 }
[263]172 long GetSourceCodePos() const
173 {
174 return sourceCodePos;
175 }
176 void SetSourceCodePos( int sourceCodePos )
177 {
178 this->sourceCodePos = sourceCodePos;
179 }
180 DWORD GetCodeType() const
181 {
182 return codeType;
183 }
184 bool IsInSystemProc() const
185 {
186 return ( (codeType&CODETYPE_SYSTEMPROC) != 0 );
187 }
188 bool IsInDebugProc() const
189 {
190 return ( (codeType&CODETYPE_DEBUGPROC) != 0 );
191 }
192};
193typedef std::vector<SourceLine> SourceLines;
194
[529]195class NativeCode : public Jenga::Common::Binary
[224]196{
[263]197 // リンカで解決しなければならないスケジュール
[224]198 Schedules schedules;
199
[263]200 // ソースコード行番号とネイティブコード位置の対応情報
201 SourceLines sourceLines;
202
[224]203 // XMLシリアライズ用
204private:
205 friend class boost::serialization::access;
[287]206 template<class Archive> void serialize(Archive& ar, const unsigned int version)
[224]207 {
[256]208 trace_for_serialize( "serializing(load) - NativeCode" );
209
[529]210 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Jenga::Common::Binary );
[224]211 ar & BOOST_SERIALIZATION_NVP( schedules );
[263]212 ar & BOOST_SERIALIZATION_NVP( sourceLines );
[224]213 }
[256]214
[224]215public:
216 NativeCode()
[529]217 : Jenga::Common::Binary()
[224]218 {
219 }
[276]220 NativeCode( const NativeCode &nativeCode )
[529]221 : Jenga::Common::Binary()
[256]222 {
[287]223 PutEx( nativeCode );
[256]224 }
[276]225 NativeCode( const char *codeBuffer, int size )
[529]226 : Jenga::Common::Binary( codeBuffer, size )
[252]227 {
228 }
[224]229 ~NativeCode()
230 {
231 }
232
[256]233 void operator =( const NativeCode &nativeCode )
234 {
235 Clear();
[287]236 PutEx( nativeCode );
[256]237 }
238
[257]239 const Schedules &GetSchedules() const
240 {
241 return schedules;
242 }
[237]243
[287]244 void PutEx( const NativeCode &nativeCode );
[357]245 void PutEx( long l, Schedule::Type scheduleType );
[245]246 void PutUserProcSchedule( const UserProc *pUserProc, bool isCall );
[357]247 void PutCatchAddressSchedule( const UserProc *pUserProc, long codePos );
[250]248 void PutDllProcSchedule( const DllProc *pDllProc );
[370]249 void PutComVtblSchedule( const CClass *pClass );
[282]250 void PutVtblSchedule( const CClass *pClass );
[263]251
[265]252 const SourceLines &GetSourceLines() const
253 {
254 return sourceLines;
255 }
[597]256 void NextSourceLine( int currentSourceIndex, int nowLine );
[273]257
258 void ResetDataSectionBaseOffset( long dataSectionBaseOffset );
[280]259 void ResetSourceIndexes( long sourceIndexBase );
[224]260};
Note: See TracBrowser for help on using the repository browser.