source: dev/trunk/ab5.0/abdev/BasicCompiler_Common/src/NativeCode.cpp@ 550

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

SpecifyAddressOf, SpecifyCatchAddressを廃止。

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