LCOV - code coverage report
Current view: top level - idlc/source - astconstant.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 48 52 92.3 %
Date: 2015-06-13 12:38:46 Functions: 3 5 60.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             : #include <idlc/astconstant.hxx>
      21             : #include <idlc/astscope.hxx>
      22             : 
      23             : #include <registry/writer.hxx>
      24             : 
      25          41 : AstConstant::AstConstant(const ExprType type,
      26             :                          const NodeType nodeType,
      27             :                          AstExpression* pExpr,
      28             :                          const OString& name,
      29             :                          AstScope* pScope)
      30             :     : AstDeclaration(nodeType, name, pScope)
      31             :     , m_pConstValue(pExpr)
      32          41 :     , m_constValueType(type)
      33             : {
      34          41 : }
      35             : 
      36          73 : AstConstant::AstConstant(const ExprType type,
      37             :                          AstExpression* pExpr,
      38             :                          const OString& name,
      39             :                          AstScope* pScope)
      40             :     : AstDeclaration(NT_const, name, pScope)
      41             :     , m_pConstValue(pExpr)
      42          73 :     , m_constValueType(type)
      43             : {
      44          73 : }
      45             : 
      46           0 : AstConstant::~AstConstant()
      47             : {
      48             : 
      49           0 : }
      50             : 
      51          94 : bool AstConstant::dumpBlob(
      52             :     typereg::Writer & rBlob, sal_uInt16 index, bool published)
      53             : {
      54          94 :     RTConstValue    aConst;
      55             : 
      56          94 :     AstExprValue *exprVal = getConstValue()->getExprValue();
      57          94 :     switch (getConstValueType())
      58             :     {
      59             :         case ET_short:
      60           7 :             aConst.m_type = RT_TYPE_INT16;
      61           7 :             aConst.m_value.aShort = exprVal->u.sval;
      62           7 :             break;
      63             :         case ET_ushort:
      64           6 :             aConst.m_type = RT_TYPE_UINT16;
      65           6 :             aConst.m_value.aUShort = exprVal->u.usval;
      66           6 :             break;
      67             :         case ET_long:
      68          49 :             aConst.m_type = RT_TYPE_INT32;
      69          49 :             aConst.m_value.aLong = exprVal->u.lval;
      70          49 :             break;
      71             :         case ET_ulong:
      72           6 :             aConst.m_type = RT_TYPE_UINT32;
      73           6 :             aConst.m_value.aULong = exprVal->u.ulval;
      74           6 :             break;
      75             :         case ET_hyper:
      76           7 :             aConst.m_type = RT_TYPE_INT64;
      77           7 :             aConst.m_value.aHyper = exprVal->u.hval;
      78           7 :             break;
      79             :         case ET_uhyper:
      80           6 :             aConst.m_type = RT_TYPE_UINT64;
      81           6 :             aConst.m_value.aUHyper = exprVal->u.uhval;
      82           6 :             break;
      83             :         case ET_float:
      84           1 :             aConst.m_type = RT_TYPE_FLOAT;
      85           1 :             aConst.m_value.aFloat = exprVal->u.fval;
      86           1 :             break;
      87             :         case ET_double:
      88           1 :             aConst.m_type = RT_TYPE_DOUBLE;
      89           1 :             aConst.m_value.aDouble = exprVal->u.dval;
      90           1 :             break;
      91             :         case ET_byte:
      92          10 :             aConst.m_type = RT_TYPE_BYTE;
      93          10 :             aConst.m_value.aByte = exprVal->u.byval;
      94          10 :             break;
      95             :         case ET_boolean:
      96           1 :             aConst.m_type = RT_TYPE_BOOL;
      97           1 :             aConst.m_value.aBool = exprVal->u.bval;
      98           1 :             break;
      99             :         default:
     100             :             {
     101             :                 fprintf(stderr, "%s: exprtype to const type: cannot convert ExprType\n",
     102           0 :                         idlc()->getOptions()->getProgramName().getStr());
     103           0 :                 return false;
     104             :             }
     105             :     }
     106             : 
     107          94 :     OString name = getLocalName();
     108             : 
     109         188 :     OUString type;
     110          94 :     if ( getNodeType() != NT_enum_val )
     111             :     {
     112          66 :         type = OStringToOUString(exprTypeToString(getConstValueType()), RTL_TEXTENCODING_UTF8);
     113             :     }
     114             : 
     115             :     rBlob.setFieldData(
     116          94 :         index, getDocumentation(), OUString(),
     117         188 :         RTFieldAccess::CONST | (published ? RTFieldAccess::PUBLISHED : RTFieldAccess::NONE),
     118         376 :         OStringToOUString(name, RTL_TEXTENCODING_UTF8), type, aConst);
     119             : 
     120         188 :     return true;
     121             : }
     122             : 
     123             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11