source: dev/trunk/ab5.0/abdev/BasicCompiler_Common/src/NativeCode.cpp@ 550

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

SpecifyAddressOf, SpecifyCatchAddressを廃止。

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