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

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

例外処理機構実装中...

File size: 3.2 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 PutCatchAddressSchedule( &UserProc::CompilingUserProc(), l );
46 }
47 else
48 {
49 if( scheduleType != Schedule::None )
50 {
51 schedules.push_back( Schedule( scheduleType, GetSize() ) );
52 }
53
54 Put( l );
55 }
56}
57
58void NativeCode::PutUserProcSchedule( const UserProc *pUserProc, bool isCall )
59{
60 pUserProc->Using();
61
62 Schedule schedule( pUserProc, GetSize() );
63 if( isCall == false )
64 {
65 schedule.SpecifyAddressOf();
66 }
67 schedules.push_back( schedule );
68
69 Put( (long)0 );
70}
71
72void NativeCode::PutCatchAddressSchedule( const UserProc *pUserProc, long codePos )
73{
74 pUserProc->Using();
75
76 Schedule schedule( pUserProc, GetSize() );
77 schedule.SpecifyCatchAddress();
78 schedules.push_back( schedule );
79
80 Put( codePos );
81}
82
83void NativeCode::PutDllProcSchedule( const DllProc *pDllProc )
84{
85 pDllProc->Using();
86
87 schedules.push_back( Schedule( pDllProc, GetSize() ) );
88
89 Put( (long)0 );
90}
91
92void NativeCode::PutVtblSchedule( const CClass *pClass )
93{
94 schedules.push_back( Schedule( pClass, GetSize() ) );
95
96 Put( (long)0 );
97}
98
99void NativeCode::NextSourceLine()
100{
101 if( sourceLines.size() )
102 {
103 if( sourceLines.back().GetNativeCodePos() == GetSize() )
104 {
105 sourceLines.back().SetSourceCodePos( cp );
106 return;
107 }
108 }
109
110 extern BOOL bDebugSupportProc;
111 extern BOOL bSystemProc;
112 DWORD sourceLineType = 0;
113 if( bDebugSupportProc )
114 {
115 sourceLineType |= CODETYPE_DEBUGPROC;
116 }
117 if( bSystemProc )
118 {
119 sourceLineType |= CODETYPE_SYSTEMPROC;
120 }
121 sourceLines.push_back(
122 SourceLine(
123 (long)sourceLines.size(),
124 GetSize(),
125 compiler.GetObjectModule().GetCurrentSourceIndex(),
126 cp,
127 sourceLineType
128 )
129 );
130}
131
132void NativeCode::ResetDataSectionBaseOffset( long dataSectionBaseOffset )
133{
134 BOOST_FOREACH( const Schedule &schedule, schedules )
135 {
136 if( schedule.GetType() == Schedule::DataTable )
137 {
138 Overwrite(
139 schedule.GetOffset(),
140 GetLong( schedule.GetOffset() ) + dataSectionBaseOffset
141 );
142 }
143 }
144}
145void NativeCode::ResetSourceIndexes( long sourceIndexBase )
146{
147 BOOST_FOREACH( SourceLine &sourceLine, sourceLines )
148 {
149 sourceLine.SetSourceIndex( sourceLine.GetSourceIndex() + sourceIndexBase );
150 }
151}
Note: See TracBrowser for help on using the repository browser.