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

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

Binaryクラスを追加

File size: 2.6 KB
Line 
1#include "stdafx.h"
2
3#include <Compiler.h>
4
5#define BREAK_EIP(checkEip) (obp+0x00401000>=checkEip)
6
7void NativeCode::PutEx( const NativeCode &nativeCode )
8{
9 long baseOffset = GetSize();
10
11 // コードバッファを追加
12 Put( nativeCode.GetBuffer(), nativeCode.GetSize() );
13
14 // スケジュールを追加
15 BOOST_FOREACH( const Schedule &schedule, nativeCode.schedules )
16 {
17 this->schedules.push_back(
18 Schedule(
19 schedule.GetType(),
20 baseOffset + schedule.GetOffset(),
21 schedule.GetLongPtrValue()
22 )
23 );
24 }
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(),
33 sourceLine.GetSourceIndex(),
34 sourceLine.GetSourceCodePos(),
35 sourceLine.GetCodeType()
36 )
37 );
38 }
39}
40
41void NativeCode::PutUserProcSchedule( const UserProc *pUserProc, bool isCall )
42{
43 pUserProc->Using();
44
45 Schedule schedule( pUserProc, GetSize() );
46 if( isCall == false )
47 {
48 schedule.SpecifyAddressOf();
49 }
50 schedules.push_back( schedule );
51
52 Put( (long)0 );
53}
54
55void NativeCode::PutDllProcSchedule( const DllProc *pDllProc )
56{
57 pDllProc->Using();
58
59 schedules.push_back( Schedule( pDllProc, GetSize() ) );
60
61 Put( (long)0 );
62}
63
64void NativeCode::PutVtblSchedule( const CClass *pClass )
65{
66 schedules.push_back( Schedule( pClass, GetSize() ) );
67
68 Put( (long)0 );
69}
70
71void NativeCode::NextSourceLine()
72{
73 if( sourceLines.size() )
74 {
75 if( sourceLines.back().GetNativeCodePos() == GetSize() )
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 }
93 sourceLines.push_back(
94 SourceLine(
95 (long)sourceLines.size(),
96 GetSize(),
97 compiler.GetObjectModule().GetCurrentSourceIndex(),
98 cp,
99 sourceLineType
100 )
101 );
102}
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}
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.