merge the formfield patch from ooo-build
[ooovba.git] / basic / source / inc / codegen.hxx
blob558a4e4f480b3dc05474d8237df412fb55f5344d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: codegen.hxx,v $
10 * $Revision: 1.7 $
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 ************************************************************************/
31 #ifndef _CODEGEN_HXX
32 #define _CODEGEN_HXX
34 class SbiImage;
35 class SbiParser;
36 class SbModule;
37 #include "opcodes.hxx"
38 #include "buffer.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
47 public:
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 ); }
55 void Statement();
56 void GenStmnt(); // evtl. Statement-Opcode erzeugen
57 UINT32 GetPC();
58 UINT32 GetOffset() { return GetPC() + 1; }
59 SbModule& GetModule() { return rMod; }
60 void Save();
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
74 T m_nSize; //
75 BYTE* m_pStart;
76 BYTE* m_pCnvtdBuf;
77 S m_nCnvtdSize; //
79 // Disable usual copying symantics and bodgy default ctor
80 PCodeBuffConvertor();
81 PCodeBuffConvertor(const PCodeBuffConvertor& );
82 PCodeBuffConvertor& operator = ( const PCodeBuffConvertor& );
83 public:
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; }
86 void convert();
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
95 #endif