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

Last change on this file since 270 was 263, checked in by dai_9181, 17 years ago
File size: 2.5 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 ObpPlus( int step )
9{
10 extern int obp;
11 obp += step;
12
13 // 例:epi=0x00401999
14 if( BREAK_EIP(0x00433FD7) )
15 {
16 int test=0;
17 }
18}
19
20void NativeCode::Put( const NativeCode &nativeCode, bool isOpBuffer )
21{
22 long baseOffset = size;
23
24 // コードバッファを追加
25 Put( nativeCode.codeBuffer, nativeCode.size, isOpBuffer );
26
27 // スケジュールを追加
28 BOOST_FOREACH( const Schedule &schedule, nativeCode.schedules )
29 {
30 this->schedules.push_back(
31 Schedule(
32 schedule.GetType(),
33 baseOffset + schedule.GetOffset(),
34 schedule.GetLongPtrValue()
35 )
36 );
37 }
38
39 // ソースコード行番号とネイティブコード位置の対応情報を追加
40 BOOST_FOREACH( const SourceLine &sourceLine, nativeCode.sourceLines )
41 {
42 this->sourceLines.push_back(
43 SourceLine(
44 sourceLine.GetLineNum(),
45 baseOffset + sourceLine.GetNativeCodePos(),
46 sourceLine.GetSourceCodePos(),
47 sourceLine.GetCodeType()
48 )
49 );
50 }
51}
52
53void NativeCode::PutUserProcSchedule( const UserProc *pUserProc, bool isCall )
54{
55 pUserProc->Using();
56
57 Schedule schedule( pUserProc, size );
58 if( isCall == false )
59 {
60 schedule.SpecifyAddressOf();
61 }
62 schedules.push_back( schedule );
63
64 *((long *)(codeBuffer+size))=0;
65 size += sizeof(long);
66
67
68
69 // 未完成
70 if( isCall )
71 {
72 pobj_SubAddrSchedule->add(pUserProc,1);
73 }
74 else
75 {
76 pobj_SubAddrSchedule->add(pUserProc,0);
77 }
78 extern char *OpBuffer;
79 extern int obp;
80 *((long *)(OpBuffer+obp))=0;
81 ObpPlus( sizeof(long) );
82}
83
84void NativeCode::PutDllProcSchedule( const DllProc *pDllProc )
85{
86 pDllProc->Using();
87
88 schedules.push_back( Schedule( pDllProc, size ) );
89
90 *((long *)(codeBuffer+size))=0;
91 size += sizeof(long);
92
93
94
95 // 未完成
96 pobj_ImportAddrSchedule->add(pDllProc);
97 extern char *OpBuffer;
98 extern int obp;
99 *((long *)(OpBuffer+obp))=0;
100 ObpPlus( sizeof(long) );
101}
102
103void NativeCode::NextSourceLine()
104{
105 if( sourceLines.size() )
106 {
107 if( sourceLines.back().GetNativeCodePos() == size )
108 {
109 sourceLines.back().SetSourceCodePos( cp );
110 return;
111 }
112 }
113
114 extern BOOL bDebugSupportProc;
115 extern BOOL bSystemProc;
116 DWORD sourceLineType = 0;
117 if( bDebugSupportProc )
118 {
119 sourceLineType |= CODETYPE_DEBUGPROC;
120 }
121 if( bSystemProc )
122 {
123 sourceLineType |= CODETYPE_SYSTEMPROC;
124 }
125 sourceLines.push_back( SourceLine( (long)sourceLines.size(), size, cp, sourceLineType ) );
126}
Note: See TracBrowser for help on using the repository browser.