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

Last change on this file since 284 was 282, checked in by dai_9181, 17 years ago

vtbl構築をコード生成後(最終リンクの前)に行うようにした

File size: 2.7 KB
Line 
1#include "stdafx.h"
2
3#include <Compiler.h>
4
5#define BREAK_EIP(checkEip) (obp+0x00401000>=checkEip)
6
7void NativeCode::Put( const NativeCode &nativeCode )
8{
9 long baseOffset = size;
10
11 // コードバッファを追加
12 Put( nativeCode.codeBuffer, nativeCode.size );
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, 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::PutVtblSchedule( const CClass *pClass )
67{
68 schedules.push_back( Schedule( pClass, size ) );
69
70 *((long *)(codeBuffer+size))=0;
71 size += sizeof(long);
72}
73
74void NativeCode::NextSourceLine()
75{
76 if( sourceLines.size() )
77 {
78 if( sourceLines.back().GetNativeCodePos() == size )
79 {
80 sourceLines.back().SetSourceCodePos( cp );
81 return;
82 }
83 }
84
85 extern BOOL bDebugSupportProc;
86 extern BOOL bSystemProc;
87 DWORD sourceLineType = 0;
88 if( bDebugSupportProc )
89 {
90 sourceLineType |= CODETYPE_DEBUGPROC;
91 }
92 if( bSystemProc )
93 {
94 sourceLineType |= CODETYPE_SYSTEMPROC;
95 }
96 sourceLines.push_back(
97 SourceLine(
98 (long)sourceLines.size(),
99 size,
100 compiler.GetObjectModule().GetCurrentSourceIndex(),
101 cp,
102 sourceLineType
103 )
104 );
105}
106
107void NativeCode::ResetDataSectionBaseOffset( long dataSectionBaseOffset )
108{
109 BOOST_FOREACH( const Schedule &schedule, schedules )
110 {
111 if( schedule.GetType() == Schedule::DataTable )
112 {
113 Overwrite(
114 schedule.GetOffset(),
115 GetLong( schedule.GetOffset() ) + dataSectionBaseOffset
116 );
117 }
118 }
119}
120void NativeCode::ResetSourceIndexes( long sourceIndexBase )
121{
122 BOOST_FOREACH( SourceLine &sourceLine, sourceLines )
123 {
124 sourceLine.SetSourceIndex( sourceLine.GetSourceIndex() + sourceIndexBase );
125 }
126}
Note: See TracBrowser for help on using the repository browser.