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

Last change on this file since 276 was 276, checked in by dai_9181, 17 years ago
File size: 2.2 KB
Line 
1#include "stdafx.h"
2
3#include <NativeCode.h>
4#include <Procedure.h>
5
6#define BREAK_EIP(checkEip) (obp+0x00401000>=checkEip)
7
8void NativeCode::Put( const NativeCode &nativeCode )
9{
10 long baseOffset = size;
11
12 // コードバッファを追加
13 Put( nativeCode.codeBuffer, nativeCode.size );
14
15 // スケジュールを追加
16 BOOST_FOREACH( const Schedule &schedule, nativeCode.schedules )
17 {
18 this->schedules.push_back(
19 Schedule(
20 schedule.GetType(),
21 baseOffset + schedule.GetOffset(),
22 schedule.GetLongPtrValue()
23 )
24 );
25 }
26
27 // ソースコード行番号とネイティブコード位置の対応情報を追加
28 BOOST_FOREACH( const SourceLine &sourceLine, nativeCode.sourceLines )
29 {
30 this->sourceLines.push_back(
31 SourceLine(
32 sourceLine.GetLineNum(),
33 baseOffset + sourceLine.GetNativeCodePos(),
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, size );
46 if( isCall == false )
47 {
48 schedule.SpecifyAddressOf();
49 }
50 schedules.push_back( schedule );
51
52 *((long *)(codeBuffer+size))=0;
53 size += sizeof(long);
54}
55
56void NativeCode::PutDllProcSchedule( const DllProc *pDllProc )
57{
58 pDllProc->Using();
59
60 schedules.push_back( Schedule( pDllProc, size ) );
61
62 *((long *)(codeBuffer+size))=0;
63 size += sizeof(long);
64}
65
66void NativeCode::NextSourceLine()
67{
68 if( sourceLines.size() )
69 {
70 if( sourceLines.back().GetNativeCodePos() == size )
71 {
72 sourceLines.back().SetSourceCodePos( cp );
73 return;
74 }
75 }
76
77 extern BOOL bDebugSupportProc;
78 extern BOOL bSystemProc;
79 DWORD sourceLineType = 0;
80 if( bDebugSupportProc )
81 {
82 sourceLineType |= CODETYPE_DEBUGPROC;
83 }
84 if( bSystemProc )
85 {
86 sourceLineType |= CODETYPE_SYSTEMPROC;
87 }
88 sourceLines.push_back( SourceLine( (long)sourceLines.size(), size, cp, sourceLineType ) );
89}
90
91void NativeCode::ResetDataSectionBaseOffset( long dataSectionBaseOffset )
92{
93 BOOST_FOREACH( const Schedule &schedule, schedules )
94 {
95 if( schedule.GetType() == Schedule::DataTable )
96 {
97 Overwrite(
98 schedule.GetOffset(),
99 GetLong( schedule.GetOffset() ) + dataSectionBaseOffset
100 );
101 }
102 }
103}
Note: See TracBrowser for help on using the repository browser.