LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/idlc/source - fehelper.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 39 54 72.2 %
Date: 2013-07-09 Functions: 7 7 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             : #include <idlc/fehelper.hxx>
      21             : #include <idlc/errorhandler.hxx>
      22             : #include <idlc/astarray.hxx>
      23             : #include "idlc/idlc.hxx"
      24             : 
      25             : using namespace ::rtl;
      26             : 
      27      165498 : FeDeclarator::FeDeclarator(const OString& name, DeclaratorType declType, AstDeclaration* pComplPart)
      28             :     : m_pComplexPart(pComplPart)
      29             :     , m_name(name)
      30      165498 :     , m_declType(declType)
      31             : {
      32      165498 : }
      33             : 
      34      158898 : FeDeclarator::~FeDeclarator()
      35             : {
      36      158898 : }
      37             : 
      38      142203 : sal_Bool FeDeclarator::checkType(AstDeclaration const * type)
      39             : {
      40      142203 :     OString tmp(m_name);
      41      142203 :     sal_Int32 count = m_name.lastIndexOf( ':' );
      42      142203 :     if( count != -1 )
      43           0 :         tmp = m_name.copy( count+1 );
      44             : 
      45      142203 :     if (tmp == type->getLocalName())
      46         714 :         return sal_False;
      47             :     else
      48      141489 :         return sal_True;
      49             : }
      50             : 
      51      165467 : AstType const * FeDeclarator::compose(AstDeclaration const * pDecl)
      52             : {
      53             :     AstArray*   pArray;
      54             :     AstType*    pType;
      55             : 
      56      165467 :     if ( pDecl == 0 )
      57             :     {
      58           1 :         return NULL;
      59             :     }
      60      165466 :     if ( !pDecl->isType() )
      61             :     {
      62           0 :         idlc()->error()->noTypeError(pDecl);
      63           0 :         return NULL;
      64             :     }
      65      165466 :     pType = (AstType*)pDecl;
      66      165466 :     if (m_declType == FD_simple || m_pComplexPart == NULL)
      67      165466 :         return pType;
      68             : 
      69           0 :     if (m_pComplexPart->getNodeType() == NT_array)
      70             :     {
      71           0 :         pArray = (AstArray*)m_pComplexPart;
      72           0 :         pArray->setType(pType);
      73             : 
      74             :         // insert array type in global scope
      75           0 :         AstScope* pScope = idlc()->scopes()->bottom();
      76           0 :         if ( pScope )
      77             :         {
      78           0 :             AstDeclaration* pDecl2 = pScope->addDeclaration(pArray);
      79           0 :             if ( (AstDeclaration*)pArray != pDecl2 )
      80             :             {
      81           0 :                 delete m_pComplexPart;
      82           0 :                 m_pComplexPart = pDecl2;
      83             :             }
      84             :         }
      85           0 :         return pArray;
      86             :     }
      87             : 
      88           0 :     return NULL; // return through this statement should not happen
      89             : }
      90             : 
      91       53282 : FeInheritanceHeader::FeInheritanceHeader(
      92             :     NodeType nodeType, OString* pName, OString* pInherits,
      93             :     std::vector< OString > * typeParameters)
      94             :     : m_nodeType(nodeType)
      95             :     , m_pName(pName)
      96       53282 :     , m_pInherits(NULL)
      97             : {
      98       53282 :     if (typeParameters != 0) {
      99         119 :         m_typeParameters = *typeParameters;
     100             :     }
     101       53282 :     initializeInherits(pInherits);
     102       53282 : }
     103             : 
     104       53282 : void FeInheritanceHeader::initializeInherits(OString* pInherits)
     105             : {
     106       53282 :     if ( pInherits )
     107             :     {
     108       36188 :         AstScope* pScope = idlc()->scopes()->topNonNull();
     109       36188 :         AstDeclaration* pDecl = pScope->lookupByName(*pInherits);
     110       36188 :         if ( pDecl )
     111             :         {
     112       36188 :             AstDeclaration const * resolved = resolveTypedefs(pDecl);
     113       72376 :             if ( resolved->getNodeType() == getNodeType()
     114       72373 :                  && (resolved->getNodeType() != NT_interface
     115       22437 :                      || static_cast< AstInterface const * >(
     116       22437 :                          resolved)->isDefined()) )
     117             :             {
     118       36185 :                 if ( idlc()->error()->checkPublished( pDecl ) )
     119             :                 {
     120       36182 :                     m_pInherits = pDecl;
     121             :                 }
     122             :             }
     123             :             else
     124             :             {
     125             :                 idlc()->error()->inheritanceError(
     126           3 :                     getNodeType(), getName(), pDecl);
     127             :             }
     128             :         }
     129             :         else
     130             :         {
     131           0 :             idlc()->error()->lookupError(*pInherits);
     132             :         }
     133             :     }
     134       53282 : }
     135             : 
     136             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10