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
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 {
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
[245]58void NativeCode::PutUserProcSchedule( const UserProc *pUserProc, bool isCall )
59{
60 pUserProc->Using();
61
[287]62 Schedule schedule( pUserProc, GetSize() );
[245]63 if( isCall == false )
64 {
65 schedule.SpecifyAddressOf();
66 }
67 schedules.push_back( schedule );
68
[287]69 Put( (long)0 );
[245]70}
[250]71
[357]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
[250]83void NativeCode::PutDllProcSchedule( const DllProc *pDllProc )
84{
85 pDllProc->Using();
86
[287]87 schedules.push_back( Schedule( pDllProc, GetSize() ) );
[250]88
[287]89 Put( (long)0 );
[250]90}
[263]91
[282]92void NativeCode::PutVtblSchedule( const CClass *pClass )
93{
[287]94 schedules.push_back( Schedule( pClass, GetSize() ) );
[282]95
[287]96 Put( (long)0 );
[282]97}
98
[263]99void NativeCode::NextSourceLine()
100{
101 if( sourceLines.size() )
102 {
[287]103 if( sourceLines.back().GetNativeCodePos() == GetSize() )
[263]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 }
[280]121 sourceLines.push_back(
122 SourceLine(
123 (long)sourceLines.size(),
[287]124 GetSize(),
[280]125 compiler.GetObjectModule().GetCurrentSourceIndex(),
126 cp,
127 sourceLineType
128 )
129 );
[263]130}
[273]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}
[280]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.