LCOV - code coverage report
Current view: top level - idlc/source - astconstant.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 47 51 92.2 %
Date: 2014-11-03 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          82 : 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          82 :     , m_constValueType(type)
      33             : {
      34          82 : }
      35             : 
      36         146 : 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         146 :     , m_constValueType(type)
      43             : {
      44         146 : }
      45             : 
      46           0 : AstConstant::~AstConstant()
      47             : {
      48             : 
      49           0 : }
      50             : 
      51         188 : bool AstConstant::dumpBlob(
      52             :     typereg::Writer & rBlob, sal_uInt16 index, bool published)
      53             : {
      54         188 :     RTConstValue    aConst;
      55             : 
      56         188 :     AstExprValue *exprVal = getConstValue()->getExprValue();
      57         188 :     switch (getConstValueType())
      58             :     {
      59             :         case ET_short:
      60          14 :             aConst.m_type = RT_TYPE_INT16;
      61          14 :             aConst.m_value.aShort = exprVal->u.sval;
      62          14 :             break;
      63             :         case ET_ushort:
      64          12 :             aConst.m_type = RT_TYPE_UINT16;
      65          12 :             aConst.m_value.aUShort = exprVal->u.usval;
      66          12 :             break;
      67             :         case ET_long:
      68          98 :             aConst.m_type = RT_TYPE_INT32;
      69          98 :             aConst.m_value.aLong = exprVal->u.lval;
      70          98 :             break;
      71             :         case ET_ulong:
      72          12 :             aConst.m_type = RT_TYPE_UINT32;
      73          12 :             aConst.m_value.aULong = exprVal->u.ulval;
      74          12 :             break;
      75             :         case ET_hyper:
      76          14 :             aConst.m_type = RT_TYPE_INT64;
      77          14 :             aConst.m_value.aHyper = exprVal->u.hval;
      78          14 :             break;
      79             :         case ET_uhyper:
      80          12 :             aConst.m_type = RT_TYPE_UINT64;
      81          12 :             aConst.m_value.aUHyper = exprVal->u.uhval;
      82          12 :             break;
      83             :         case ET_float:
      84           2 :             aConst.m_type = RT_TYPE_FLOAT;
      85           2 :             aConst.m_value.aFloat = exprVal->u.fval;
      86           2 :             break;
      87             :         case ET_double:
      88           2 :             aConst.m_type = RT_TYPE_DOUBLE;
      89           2 :             aConst.m_value.aDouble = exprVal->u.dval;
      90           2 :             break;
      91             :         case ET_byte:
      92          20 :             aConst.m_type = RT_TYPE_BYTE;
      93          20 :             aConst.m_value.aByte = exprVal->u.byval;
      94          20 :             break;
      95             :         case ET_boolean:
      96           2 :             aConst.m_type = RT_TYPE_BOOL;
      97           2 :             aConst.m_value.aBool = exprVal->u.bval;
      98           2 :             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         188 :     OString name = getLocalName();
     108             : 
     109         376 :     OUString type;
     110         188 :     if ( getNodeType() != NT_enum_val )
     111             :     {
     112         132 :         type = OStringToOUString(exprTypeToString(getConstValueType()), RTL_TEXTENCODING_UTF8);
     113             :     }
     114             : 
     115             :     rBlob.setFieldData(
     116         188 :         index, getDocumentation(), OUString(),
     117             :         RT_ACCESS_CONST | (published ? RT_ACCESS_PUBLISHED : 0),
     118         376 :         OStringToOUString(name, RTL_TEXTENCODING_UTF8), type, aConst);
     119             : 
     120         376 :     return true;
     121             : }
     122             : 
     123             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10