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
RevLine 
[232]1#include "stdafx.h"
2
[280]3#include <Compiler.h>
[245]4
[237]5#define BREAK_EIP(checkEip) (obp+0x00401000>=checkEip)
[232]6
[287]7void NativeCode::PutEx( const NativeCode &nativeCode )
[232]8{
[287]9 long baseOffset = GetSize();
[257]10
[263]11 // コードバッファを追加
[287]12 Put( nativeCode.GetBuffer(), nativeCode.GetSize() );
[257]13
[263]14 // スケジュールを追加
[257]15 BOOST_FOREACH( const Schedule &schedule, nativeCode.schedules )
16 {
17 this->schedules.push_back(
18 Schedule(
19 schedule.GetType(),
[258]20 baseOffset + schedule.GetOffset(),
21 schedule.GetLongPtrValue()
[257]22 )
23 );
24 }
[263]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(),
[280]33 sourceLine.GetSourceIndex(),
[263]34 sourceLine.GetSourceCodePos(),
35 sourceLine.GetCodeType()
36 )
37 );
38 }
[257]39}
40
[357]41void NativeCode::PutEx( long l, Schedule::Type scheduleType )
42{
43 if( scheduleType == Schedule::CatchAddress )
44 {
[364]45 const UserProc *pUserProc = &UserProc::CompilingUserProc();
46 if( UserProc::IsGlobalAreaCompiling() )
47 {
48 pUserProc = UserProc::pGlobalProc;
49 }
50 PutCatchAddressSchedule( pUserProc, l );
[357]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
[245]63void NativeCode::PutUserProcSchedule( const UserProc *pUserProc, bool isCall )
64{
65 pUserProc->Using();
66
[287]67 Schedule schedule( pUserProc, GetSize() );
[245]68 if( isCall == false )
69 {
70 schedule.SpecifyAddressOf();
71 }
72 schedules.push_back( schedule );
73
[287]74 Put( (long)0 );
[245]75}
[250]76
[357]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
[250]88void NativeCode::PutDllProcSchedule( const DllProc *pDllProc )
89{
90 pDllProc->Using();
91
[287]92 schedules.push_back( Schedule( pDllProc, GetSize() ) );
[250]93
[287]94 Put( (long)0 );
[250]95}
[263]96
[282]97void NativeCode::PutVtblSchedule( const CClass *pClass )
98{
[287]99 schedules.push_back( Schedule( pClass, GetSize() ) );
[282]100
[287]101 Put( (long)0 );
[282]102}
103
[263]104void NativeCode::NextSourceLine()
105{
106 if( sourceLines.size() )
107 {
[287]108 if( sourceLines.back().GetNativeCodePos() == GetSize() )
[263]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 }
[280]126 sourceLines.push_back(
127 SourceLine(
128 (long)sourceLines.size(),
[287]129 GetSize(),
[280]130 compiler.GetObjectModule().GetCurrentSourceIndex(),
131 cp,
132 sourceLineType
133 )
134 );
[263]135}
[273]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}
[280]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.