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

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

Throw→Catch間のパラメータ引渡しに対応。
グローバル領域でのTryスコープを可能にした。これで例外処理機構実装完了。
エディタの補間機能にTry/Catch/Finally/EndTryを追加。

File size: 3.3 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::PutVtblSchedule( const CClass *pClass )
98{
99 schedules.push_back( Schedule( pClass, GetSize() ) );
100
101 Put( (long)0 );
102}
103
104void NativeCode::NextSourceLine()
105{
106 if( sourceLines.size() )
107 {
108 if( sourceLines.back().GetNativeCodePos() == GetSize() )
109 {
110 sourceLines.back().SetSourceCodePos( cp );
111 return;
112 }
113 }
114
115 extern BOOL bDebugSupportProc;
116 extern BOOL bSystemProc;
117 DWORD sourceLineType = 0;
118 if( bDebugSupportProc )
119 {
120 sourceLineType |= CODETYPE_DEBUGPROC;
121 }
122 if( bSystemProc )
123 {
124 sourceLineType |= CODETYPE_SYSTEMPROC;
125 }
126 sourceLines.push_back(
127 SourceLine(
128 (long)sourceLines.size(),
129 GetSize(),
130 compiler.GetObjectModule().GetCurrentSourceIndex(),
131 cp,
132 sourceLineType
133 )
134 );
135}
136
137void NativeCode::ResetDataSectionBaseOffset( long dataSectionBaseOffset )
138{
139 BOOST_FOREACH( const Schedule &schedule, schedules )
140 {
141 if( schedule.GetType() == Schedule::DataTable )
142 {
143 Overwrite(
144 schedule.GetOffset(),
145 GetLong( schedule.GetOffset() ) + dataSectionBaseOffset
146 );
147 }
148 }
149}
150void NativeCode::ResetSourceIndexes( long sourceIndexBase )
151{
152 BOOST_FOREACH( SourceLine &sourceLine, sourceLines )
153 {
154 sourceLine.SetSourceIndex( sourceLine.GetSourceIndex() + sourceIndexBase );
155 }
156}
Note: See TracBrowser for help on using the repository browser.