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

Last change on this file since 379 was 370, checked in by dai_9181, 17 years ago

COM修飾子に対応。COMインターフェイスを呼び出せるようにした

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