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

Last change on this file since 296 was 287, checked in by dai_9181, 17 years ago

Binaryクラスを追加

File size: 2.6 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
[245]41void NativeCode::PutUserProcSchedule( const UserProc *pUserProc, bool isCall )
42{
43 pUserProc->Using();
44
[287]45 Schedule schedule( pUserProc, GetSize() );
[245]46 if( isCall == false )
47 {
48 schedule.SpecifyAddressOf();
49 }
50 schedules.push_back( schedule );
51
[287]52 Put( (long)0 );
[245]53}
[250]54
55void NativeCode::PutDllProcSchedule( const DllProc *pDllProc )
56{
57 pDllProc->Using();
58
[287]59 schedules.push_back( Schedule( pDllProc, GetSize() ) );
[250]60
[287]61 Put( (long)0 );
[250]62}
[263]63
[282]64void NativeCode::PutVtblSchedule( const CClass *pClass )
65{
[287]66 schedules.push_back( Schedule( pClass, GetSize() ) );
[282]67
[287]68 Put( (long)0 );
[282]69}
70
[263]71void NativeCode::NextSourceLine()
72{
73 if( sourceLines.size() )
74 {
[287]75 if( sourceLines.back().GetNativeCodePos() == GetSize() )
[263]76 {
77 sourceLines.back().SetSourceCodePos( cp );
78 return;
79 }
80 }
81
82 extern BOOL bDebugSupportProc;
83 extern BOOL bSystemProc;
84 DWORD sourceLineType = 0;
85 if( bDebugSupportProc )
86 {
87 sourceLineType |= CODETYPE_DEBUGPROC;
88 }
89 if( bSystemProc )
90 {
91 sourceLineType |= CODETYPE_SYSTEMPROC;
92 }
[280]93 sourceLines.push_back(
94 SourceLine(
95 (long)sourceLines.size(),
[287]96 GetSize(),
[280]97 compiler.GetObjectModule().GetCurrentSourceIndex(),
98 cp,
99 sourceLineType
100 )
101 );
[263]102}
[273]103
104void NativeCode::ResetDataSectionBaseOffset( long dataSectionBaseOffset )
105{
106 BOOST_FOREACH( const Schedule &schedule, schedules )
107 {
108 if( schedule.GetType() == Schedule::DataTable )
109 {
110 Overwrite(
111 schedule.GetOffset(),
112 GetLong( schedule.GetOffset() ) + dataSectionBaseOffset
113 );
114 }
115 }
116}
[280]117void NativeCode::ResetSourceIndexes( long sourceIndexBase )
118{
119 BOOST_FOREACH( SourceLine &sourceLine, sourceLines )
120 {
121 sourceLine.SetSourceIndex( sourceLine.GetSourceIndex() + sourceIndexBase );
122 }
123}
Note: See TracBrowser for help on using the repository browser.