1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: codegen.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
37 #include "opcodes.hxx"
40 class SbiCodeGen
{ // Code-Erzeugung:
41 SbiParser
* pParser
; // fuer Fehlermeldungen, Line, Column etc.
42 SbModule
& rMod
; // aktuelles Modul
43 SbiBuffer aCode
; // Code-Puffer
44 short nLine
, nCol
; // Zeile, Spalte fuer Stmnt-Befehl
45 short nForLevel
; // #29955 for-Schleifen-Ebene
46 BOOL bStmnt
; // TRUE: Statement-Opcode liegt an
48 SbiCodeGen( SbModule
&, SbiParser
*, short );
49 SbiParser
* GetParser() { return pParser
; }
50 UINT32
Gen( SbiOpcode
);
51 UINT32
Gen( SbiOpcode
, UINT32
);
52 UINT32
Gen( SbiOpcode
, UINT32
, UINT32
);
53 void Patch( UINT32 o
, UINT32 v
){ aCode
.Patch( o
, v
); }
54 void BackChain( UINT32 off
) { aCode
.Chain( off
); }
56 void GenStmnt(); // evtl. Statement-Opcode erzeugen
58 UINT32
GetOffset() { return GetPC() + 1; }
59 SbModule
& GetModule() { return rMod
; }
62 // #29955 for-Schleifen-Ebene pflegen
63 void IncForLevel( void ) { nForLevel
++; }
64 void DecForLevel( void ) { nForLevel
--; }
66 static UINT32
calcNewOffSet( BYTE
* pCode
, UINT16 nOffset
);
67 static UINT16
calcLegacyOffSet( BYTE
* pCode
, UINT32 nOffset
);
71 template < class T
, class S
>
72 class PCodeBuffConvertor
79 // Disable usual copying symantics and bodgy default ctor
81 PCodeBuffConvertor(const PCodeBuffConvertor
& );
82 PCodeBuffConvertor
& operator = ( const PCodeBuffConvertor
& );
84 PCodeBuffConvertor( BYTE
* pCode
, T nSize
): m_nSize( nSize
), m_pStart( pCode
), m_pCnvtdBuf( NULL
), m_nCnvtdSize( 0 ){ convert(); }
85 S
GetSize(){ return m_nCnvtdSize
; }
87 // Caller owns the buffer returned
88 BYTE
* GetBuffer() { return m_pCnvtdBuf
; }
91 // #111897 PARAM_INFO flags start at 0x00010000 to not
92 // conflict with DefaultId in SbxParamInfo::nUserData
93 #define PARAM_INFO_PARAMARRAY 0x0010000