LCOV - code coverage report
Current view: top level - libreoffice/codemaker/source/javamaker - classfile.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 2 2 100.0 %
Date: 2012-12-27 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_CODEMAKER_SOURCE_JAVAMAKER_CLASSFILE_HXX
      21             : #define INCLUDED_CODEMAKER_SOURCE_JAVAMAKER_CLASSFILE_HXX
      22             : 
      23             : #include "codemaker/unotype.hxx"
      24             : #include "sal/types.h"
      25             : 
      26             : #include <list>
      27             : #include <map>
      28             : #include <utility>
      29             : #include <vector>
      30             : 
      31             : class FileStream;
      32             : namespace rtl { class OString; }
      33             : 
      34             : namespace codemaker { namespace javamaker {
      35             : 
      36             : class ClassFile {
      37             : public:
      38             :     enum AccessFlags {
      39             :         ACC_PUBLIC = 0x0001,
      40             :         ACC_PRIVATE = 0x0002,
      41             :         ACC_STATIC = 0x0008,
      42             :         ACC_FINAL = 0x0010,
      43             :         ACC_SUPER = 0x0020,
      44             :         ACC_VARARGS = 0x0080,
      45             :         ACC_INTERFACE = 0x0200,
      46             :         ACC_ABSTRACT = 0x0400,
      47             :         ACC_SYNTHETIC = 0x1000
      48             :     };
      49             : 
      50             :     class Code {
      51             :     public:
      52             :         typedef std::vector< unsigned char >::size_type Branch;
      53             :         typedef std::vector< unsigned char >::size_type Position;
      54             : 
      55             :         ~Code();
      56             : 
      57             :         void instrAastore();
      58             :         void instrAconstNull();
      59             :         void instrAnewarray(rtl::OString const & type);
      60             :         void instrAreturn();
      61             :         void instrAthrow();
      62             :         void instrCheckcast(rtl::OString const & type);
      63             :         void instrDup();
      64             : 
      65             :         void instrGetstatic(
      66             :             rtl::OString const & type, rtl::OString const & name,
      67             :             rtl::OString const & descriptor);
      68             : 
      69             :         Branch instrIfAcmpne();
      70             :         Branch instrIfeq();
      71             :         Branch instrIfnull();
      72             : 
      73             :         void instrInstanceof(rtl::OString const & type);
      74             : 
      75             :         void instrInvokeinterface(
      76             :             rtl::OString const & type, rtl::OString const & name,
      77             :             rtl::OString const & descriptor, sal_uInt8 args);
      78             : 
      79             :         void instrInvokespecial(
      80             :             rtl::OString const & type, rtl::OString const & name,
      81             :             rtl::OString const & descriptor);
      82             : 
      83             :         void instrInvokestatic(
      84             :             rtl::OString const & type, rtl::OString const & name,
      85             :             rtl::OString const & descriptor);
      86             : 
      87             :         void instrInvokevirtual(
      88             :             rtl::OString const & type, rtl::OString const & name,
      89             :             rtl::OString const & descriptor);
      90             : 
      91             :         void instrLookupswitch(
      92             :             Code const * defaultBlock,
      93             :             std::list< std::pair< sal_Int32, Code * > > const & blocks);
      94             : 
      95             :         void instrNew(rtl::OString const & type);
      96             :         void instrNewarray(codemaker::UnoType::Sort sort);
      97             :         void instrPop();
      98             : 
      99             :         void instrPutfield(
     100             :             rtl::OString const & type, rtl::OString const & name,
     101             :             rtl::OString const & descriptor);
     102             : 
     103             :         void instrPutstatic(
     104             :             rtl::OString const & type, rtl::OString const & name,
     105             :             rtl::OString const & descriptor);
     106             : 
     107             :         void instrReturn();
     108             :         void instrSwap();
     109             : 
     110             :         void instrTableswitch(
     111             :             Code const * defaultBlock, sal_Int32 low,
     112             :             std::list< Code * > const & blocks);
     113             : 
     114             :         void loadIntegerConstant(sal_Int32 value);
     115             :         void loadStringConstant(rtl::OString const & value);
     116             :         void loadLocalInteger(sal_uInt16 index);
     117             :         void loadLocalLong(sal_uInt16 index);
     118             :         void loadLocalFloat(sal_uInt16 index);
     119             :         void loadLocalDouble(sal_uInt16 index);
     120             :         void loadLocalReference(sal_uInt16 index);
     121             :         void storeLocalReference(sal_uInt16 index);
     122             :         void branchHere(Branch branch);
     123             : 
     124             :         void addException(
     125             :             Position start, Position end, Position handler,
     126             :             rtl::OString const & type);
     127             : 
     128        4835 :         void setMaxStackAndLocals(sal_uInt16 maxStack, sal_uInt16 maxLocals)
     129        4835 :         { m_maxStack = maxStack; m_maxLocals = maxLocals; }
     130             : 
     131             :         Position getPosition() const;
     132             : 
     133             :     private:
     134             :         Code(Code &); // not implemented
     135             :         void operator =(Code); // not implemented
     136             : 
     137             :         Code(ClassFile & classFile);
     138             : 
     139             :         void ldc(sal_uInt16 index);
     140             : 
     141             :         void accessLocal(
     142             :             sal_uInt16 index, sal_uInt8 fastOp, sal_uInt8 normalOp);
     143             : 
     144             :         ClassFile & m_classFile;
     145             :         sal_uInt16 m_maxStack;
     146             :         sal_uInt16 m_maxLocals;
     147             :         std::vector< unsigned char > m_code;
     148             :         sal_uInt16 m_exceptionTableLength;
     149             :         std::vector< unsigned char > m_exceptionTable;
     150             : 
     151             :         friend class ClassFile;
     152             :     };
     153             : 
     154             :     ClassFile(
     155             :         AccessFlags accessFlags, rtl::OString const & thisClass,
     156             :         rtl::OString const & superClass, rtl::OString const & signature);
     157             : 
     158             :     ~ClassFile();
     159             : 
     160             :     Code * newCode();
     161             : 
     162             :     sal_uInt16 addIntegerInfo(sal_Int32 value);
     163             :     sal_uInt16 addFloatInfo(float value);
     164             :     sal_uInt16 addLongInfo(sal_Int64 value);
     165             :     sal_uInt16 addDoubleInfo(double value);
     166             : 
     167             :     void addInterface(rtl::OString const & interface);
     168             : 
     169             :     void addField(
     170             :         AccessFlags accessFlags, rtl::OString const & name,
     171             :         rtl::OString const & descriptor, sal_uInt16 constantValueIndex,
     172             :         rtl::OString const & signature);
     173             : 
     174             :     void addMethod(
     175             :         AccessFlags accessFlags, rtl::OString const & name,
     176             :         rtl::OString const & descriptor, Code const * code,
     177             :         std::vector< rtl::OString > const & exceptions,
     178             :         rtl::OString const & signature);
     179             : 
     180             :     void write(FileStream & file) const; //TODO
     181             : 
     182             : private:
     183             :     typedef std::map< rtl::OString, sal_uInt16 > Map;
     184             : 
     185             :     ClassFile(ClassFile &); // not implemented
     186             :     void operator =(ClassFile); // not implemented
     187             : 
     188             :     sal_uInt16 nextConstantPoolIndex(sal_uInt16 width);
     189             :     sal_uInt16 addUtf8Info(rtl::OString const & value);
     190             :     sal_uInt16 addClassInfo(rtl::OString const & type);
     191             :     sal_uInt16 addStringInfo(rtl::OString const & value);
     192             : 
     193             :     sal_uInt16 addFieldrefInfo(
     194             :         rtl::OString const & type, rtl::OString const & name,
     195             :         rtl::OString const & descriptor);
     196             : 
     197             :     sal_uInt16 addMethodrefInfo(
     198             :         rtl::OString const & type, rtl::OString const & name,
     199             :         rtl::OString const & descriptor);
     200             : 
     201             :     sal_uInt16 addInterfaceMethodrefInfo(
     202             :         rtl::OString const & type, rtl::OString const & name,
     203             :         rtl::OString const & descriptor);
     204             : 
     205             :     sal_uInt16 addNameAndTypeInfo(
     206             :         rtl::OString const & name, rtl::OString const & descriptor);
     207             : 
     208             :     void appendSignatureAttribute(
     209             :         std::vector< unsigned char > & stream, rtl::OString const & signature);
     210             : 
     211             :     sal_uInt16 m_constantPoolCount;
     212             :     std::vector< unsigned char > m_constantPool;
     213             :     std::map< rtl::OString, sal_uInt16 > m_utf8Infos;
     214             :     std::map< sal_Int32, sal_uInt16 > m_integerInfos;
     215             :     std::map< sal_Int64, sal_uInt16 > m_longInfos;
     216             :     std::map< float, sal_uInt16 > m_floatInfos;
     217             :     std::map< double, sal_uInt16 > m_doubleInfos;
     218             :     std::map< sal_uInt16, sal_uInt16 > m_classInfos;
     219             :     std::map< sal_uInt16, sal_uInt16 > m_stringInfos;
     220             :     std::map< sal_uInt32, sal_uInt16 > m_fieldrefInfos;
     221             :     std::map< sal_uInt32, sal_uInt16 > m_methodrefInfos;
     222             :     std::map< sal_uInt32, sal_uInt16 > m_interfaceMethodrefInfos;
     223             :     std::map< sal_uInt32, sal_uInt16 > m_nameAndTypeInfos;
     224             :     AccessFlags m_accessFlags;
     225             :     sal_uInt16 m_thisClass;
     226             :     sal_uInt16 m_superClass;
     227             :     sal_uInt16 m_interfacesCount;
     228             :     std::vector< unsigned char > m_interfaces;
     229             :     sal_uInt16 m_fieldsCount;
     230             :     std::vector< unsigned char > m_fields;
     231             :     sal_uInt16 m_methodsCount;
     232             :     std::vector< unsigned char > m_methods;
     233             :     sal_uInt16 m_attributesCount;
     234             :     std::vector< unsigned char > m_attributes;
     235             : 
     236             :     friend class Code;
     237             : };
     238             : 
     239             : } }
     240             : 
     241             : #endif // INCLUDED_CODEMAKER_SOURCE_JAVAMAKER_CLASSFILE_HXX
     242             : 
     243             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10