source: dev/trunk/ab5.0/abdev/ab_common/src/Lexical/NativeCode.cpp@ 636

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

libファイルを跨ったテンプレート展開に対応。

File size: 3.8 KB
Line 
1#include "stdafx.h"
2
3#define BREAK_EIP(checkEip) (obp+0x00401000>=checkEip)
4
5const ::DllProc &Schedule::GetDllProc() const
6{
7 _ASSERT( type == Schedule::DllProc );
8 return *pDllProc;
9}
10const ::UserProc &Schedule::GetUserProc() const
11{
12 _ASSERT( type == Schedule::UserProc || type == Schedule::AddressOf || type == Schedule::CatchAddress );
13 return *pUserProc;
14}
15const ::CClass &Schedule::GetClass() const
16{
17 _ASSERT( type == Schedule::ComVtbl || type == Schedule::Vtbl || type == Schedule::TypeInfo );
18 return *pClass;
19}
20
21void NativeCode::PutEx( const NativeCode &nativeCode )
22{
23 long baseOffset = GetSize();
24
25 // コードバッファを追加
26 Put( nativeCode.GetBuffer(), nativeCode.GetSize() );
27
28 // スケジュールを追加
29 BOOST_FOREACH( const Schedule &schedule, nativeCode.schedules )
30 {
31 this->schedules.push_back(
32 Schedule(
33 schedule.GetType(),
34 baseOffset + schedule.GetOffset(),
35 schedule.GetLongPtrValue()
36 )
37 );
38 }
39
40 // ソースコード行番号とネイティブコード位置の対応情報を追加
41 BOOST_FOREACH( const SourceLine &sourceLine, nativeCode.sourceLines )
42 {
43 this->sourceLines.push_back(
44 SourceLine(
45 sourceLine.GetLineNum(),
46 baseOffset + sourceLine.GetNativeCodePos(),
47 sourceLine.GetRelationalObjectModuleIndex(), // TODO: 複数libの取り込みを想定できていない(ソースコード行番号とネイティブコード位置の対応情報の追加は静的リンクが完了した後に行うべき)
48 sourceLine.GetSourceCodePos(),
49 sourceLine.GetCodeType()
50 )
51 );
52 }
53}
54
55void NativeCode::PutEx( long l, Schedule::Type scheduleType )
56{
57 if( scheduleType != Schedule::None )
58 {
59 schedules.push_back( Schedule( scheduleType, GetSize() ) );
60 }
61
62 Put( l );
63}
64
65void NativeCode::PutUserProcSchedule( const UserProc *pUserProc, bool isCall )
66{
67 pUserProc->Using();
68
69 Schedule::Type type = isCall ? Schedule::UserProc : Schedule::AddressOf;
70
71 schedules.push_back( Schedule( type, pUserProc, GetSize() ) );
72
73 Put( (long)0 );
74}
75
76void NativeCode::PutCatchAddressSchedule( const UserProc *pUserProc, long codePos )
77{
78 pUserProc->Using();
79
80 schedules.push_back( Schedule( Schedule::CatchAddress, pUserProc, GetSize() ) );
81
82 Put( codePos );
83}
84
85void NativeCode::PutDllProcSchedule( const DllProc *pDllProc )
86{
87 pDllProc->Using();
88
89 schedules.push_back( Schedule( pDllProc, GetSize() ) );
90
91 Put( (long)0 );
92}
93
94void NativeCode::PutComVtblSchedule( const CClass *pClass )
95{
96 schedules.push_back( Schedule( Schedule::ComVtbl, pClass, GetSize() ) );
97
98 Put( (long)0 );
99}
100
101void NativeCode::PutVtblSchedule( const CClass *pClass )
102{
103 schedules.push_back( Schedule( Schedule::Vtbl, pClass, GetSize() ) );
104
105 Put( (long)0 );
106}
107
108void NativeCode::NextSourceLine( int currentSourceIndex, int nowLine )
109{
110 if( sourceLines.size() )
111 {
112 if( sourceLines.back().GetNativeCodePos() == GetSize() )
113 {
114 sourceLines.back().SetSourceCodePos( nowLine );
115 return;
116 }
117 }
118
119 extern BOOL bDebugSupportProc;
120 extern BOOL bSystemProc;
121 DWORD sourceLineType = 0;
122 if( bDebugSupportProc )
123 {
124 sourceLineType |= CODETYPE_DEBUGPROC;
125 }
126 if( bSystemProc )
127 {
128 sourceLineType |= CODETYPE_SYSTEMPROC;
129 }
130 sourceLines.push_back(
131 SourceLine(
132 (long)sourceLines.size(),
133 GetSize(),
134 currentSourceIndex,
135 nowLine,
136 sourceLineType
137 )
138 );
139}
140
141void NativeCode::ResetDataSectionBaseOffset( long dataSectionBaseOffset )
142{
143 BOOST_FOREACH( const Schedule &schedule, schedules )
144 {
145 if( schedule.GetType() == Schedule::DataTable )
146 {
147 Overwrite(
148 schedule.GetOffset(),
149 GetLong( schedule.GetOffset() ) + dataSectionBaseOffset
150 );
151 }
152 }
153}
154void NativeCode::ResetSourceIndexes( const std::vector<int> &relationTable )
155{
156 BOOST_FOREACH( SourceLine &sourceLine, sourceLines )
157 {
158 sourceLine.SetRelationalObjectModuleIndex( relationTable[sourceLine.GetRelationalObjectModuleIndex()] );
159 }
160}
Note: See TracBrowser for help on using the repository browser.