source: dev/trunk/abdev/BasicCompiler_Common/src/NativeCode.cpp@ 411

Last change on this file since 411 was 370, checked in by dai_9181, 17 years ago

COM修飾子に対応。COMインターフェイスを呼び出せるようにした

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