LCOV - code coverage report
Current view: top level - idlc/source - astconstant.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 43 54 79.6 %
Date: 2012-08-25 Functions: 3 5 60.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 16 35 45.7 %

           Branch data     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                 :            : #include <idlc/astconstant.hxx>
      21                 :            : #include <idlc/astscope.hxx>
      22                 :            : 
      23                 :            : #include "registry/writer.hxx"
      24                 :            : 
      25                 :            : using namespace ::rtl;
      26                 :            : 
      27                 :      78602 : AstConstant::AstConstant(const ExprType type,
      28                 :            :                          const NodeType nodeType,
      29                 :            :                          AstExpression* pExpr,
      30                 :            :                          const ::rtl::OString& name,
      31                 :            :                          AstScope* pScope)
      32                 :            :     : AstDeclaration(nodeType, name, pScope)
      33                 :            :     , m_pConstValue(pExpr)
      34                 :      78602 :     , m_constValueType(type)
      35                 :            : {
      36                 :      78602 : }
      37                 :            : 
      38                 :      14719 : AstConstant::AstConstant(const ExprType type,
      39                 :            :                          AstExpression* pExpr,
      40                 :            :                          const ::rtl::OString& name,
      41                 :            :                          AstScope* pScope)
      42                 :            :     : AstDeclaration(NT_const, name, pScope)
      43                 :            :     , m_pConstValue(pExpr)
      44                 :      14719 :     , m_constValueType(type)
      45                 :            : {
      46                 :      14719 : }
      47                 :            : 
      48                 :          0 : AstConstant::~AstConstant()
      49                 :            : {
      50                 :            : 
      51         [ #  # ]:          0 : }
      52                 :            : 
      53                 :      14123 : sal_Bool AstConstant::dumpBlob(
      54                 :            :     typereg::Writer & rBlob, sal_uInt16 index, bool published)
      55                 :            : {
      56                 :      14123 :     RTConstValue    aConst;
      57                 :      14123 :     sal_Unicode*    str = NULL;
      58                 :            : 
      59                 :      14123 :     AstExprValue *exprVal = getConstValue()->getExprValue();
      60   [ +  +  +  +  :      14123 :     switch (getConstValueType())
          +  +  +  -  +  
                   -  - ]
      61                 :            :     {
      62                 :            :         case ET_short:
      63                 :       2450 :             aConst.m_type = RT_TYPE_INT16;
      64                 :       2450 :             aConst.m_value.aShort = exprVal->u.sval;
      65                 :       2450 :             break;
      66                 :            :         case ET_ushort:
      67                 :          2 :             aConst.m_type = RT_TYPE_UINT16;
      68                 :          2 :             aConst.m_value.aUShort = exprVal->u.usval;
      69                 :          2 :             break;
      70                 :            :         case ET_long:
      71                 :      11327 :             aConst.m_type = RT_TYPE_INT32;
      72                 :      11327 :             aConst.m_value.aLong = exprVal->u.lval;
      73                 :      11327 :             break;
      74                 :            :         case ET_ulong:
      75                 :         41 :             aConst.m_type = RT_TYPE_UINT32;
      76                 :         41 :             aConst.m_value.aULong = exprVal->u.ulval;
      77                 :         41 :             break;
      78                 :            :         case ET_hyper:
      79                 :         31 :             aConst.m_type = RT_TYPE_INT64;
      80                 :         31 :             aConst.m_value.aHyper = exprVal->u.hval;
      81                 :         31 :             break;
      82                 :            :         case ET_uhyper:
      83                 :          2 :             aConst.m_type = RT_TYPE_UINT64;
      84                 :          2 :             aConst.m_value.aUHyper = exprVal->u.uhval;
      85                 :          2 :             break;
      86                 :            :         case ET_float:
      87                 :         20 :             aConst.m_type = RT_TYPE_FLOAT;
      88                 :         20 :             aConst.m_value.aFloat = exprVal->u.fval;
      89                 :         20 :             break;
      90                 :            :         case ET_double:
      91                 :          0 :             aConst.m_type = RT_TYPE_DOUBLE;
      92                 :          0 :             aConst.m_value.aDouble = exprVal->u.dval;
      93                 :          0 :             break;
      94                 :            :         case ET_byte:
      95                 :        250 :             aConst.m_type = RT_TYPE_BYTE;
      96                 :        250 :             aConst.m_value.aByte = exprVal->u.byval;
      97                 :        250 :             break;
      98                 :            :         case ET_boolean:
      99                 :          0 :             aConst.m_type = RT_TYPE_BOOL;
     100                 :          0 :             aConst.m_value.aBool = exprVal->u.bval;
     101                 :          0 :             break;
     102                 :            :         default:
     103                 :            :             {
     104                 :            :                 fprintf(stderr, "%s: exprtype to const type: cannot convert ExprType\n",
     105 [ #  # ][ #  # ]:          0 :                         idlc()->getOptions()->getProgramName().getStr());
                 [ #  # ]
     106                 :          0 :                 return sal_False;
     107                 :            :             }
     108                 :            :     }
     109                 :            : 
     110                 :      14123 :     OString name = getLocalName();
     111                 :            : 
     112                 :      14123 :     OUString type;
     113         [ +  + ]:      14123 :     if ( getNodeType() != NT_enum_val )
     114                 :            :     {
     115 [ +  - ][ +  - ]:      12202 :         type = OStringToOUString(exprTypeToString(getConstValueType()), RTL_TEXTENCODING_UTF8);
     116                 :            :     }
     117                 :            : 
     118                 :            :     rBlob.setFieldData(
     119                 :      14123 :         index, getDocumentation(), OUString(),
     120                 :            :         RT_ACCESS_CONST | (published ? RT_ACCESS_PUBLISHED : 0),
     121 [ +  - ][ -  + ]:      28246 :         OStringToOUString(name, RTL_TEXTENCODING_UTF8), type, aConst);
                 [ +  - ]
     122         [ -  + ]:      14123 :     if (str)
     123         [ #  # ]:          0 :         delete[] str;
     124                 :            : 
     125                 :      14123 :     return sal_True;
     126                 :            : }
     127                 :            : 
     128                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10