LCOV - code coverage report
Current view: top level - libreoffice/idlc/source - fehelper.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 36 53 67.9 %
Date: 2012-12-27 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      157967 : FeDeclarator::FeDeclarator(const OString& name, DeclaratorType declType, AstDeclaration* pComplPart)
      28             :     : m_pComplexPart(pComplPart)
      29             :     , m_name(name)
      30      157967 :     , m_declType(declType)
      31             : {
      32      157967 : }
      33             : 
      34      153052 : FeDeclarator::~FeDeclarator()
      35             : {
      36      153052 : }
      37             : 
      38      135222 : sal_Bool FeDeclarator::checkType(AstDeclaration const * type)
      39             : {
      40      135222 :     OString tmp(m_name);
      41      135222 :     sal_Int32 count = m_name.lastIndexOf( ':' );
      42      135222 :     if( count != -1 )
      43           0 :         tmp = m_name.copy( count+1 );
      44             : 
      45      135222 :     if (tmp == type->getLocalName())
      46         539 :         return sal_False;
      47             :     else
      48      134683 :         return sal_True;
      49             : }
      50             : 
      51      157967 : AstType const * FeDeclarator::compose(AstDeclaration const * pDecl)
      52             : {
      53             :     AstArray*   pArray;
      54             :     AstType*    pType;
      55             : 
      56      157967 :     if ( pDecl == 0 )
      57             :     {
      58           0 :         return NULL;
      59             :     }
      60      157967 :     if ( !pDecl->isType() )
      61             :     {
      62           0 :         idlc()->error()->noTypeError(pDecl);
      63           0 :         return NULL;
      64             :     }
      65      157967 :     pType = (AstType*)pDecl;
      66      157967 :     if (m_declType == FD_simple || m_pComplexPart == NULL)
      67      157967 :         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       50459 : FeInheritanceHeader::FeInheritanceHeader(
      92             :     NodeType nodeType, ::rtl::OString* pName, ::rtl::OString* pInherits,
      93             :     std::vector< rtl::OString > * typeParameters)
      94             :     : m_nodeType(nodeType)
      95             :     , m_pName(pName)
      96       50459 :     , m_pInherits(NULL)
      97             : {
      98       50459 :     if (typeParameters != 0) {
      99          52 :         m_typeParameters = *typeParameters;
     100             :     }
     101       50459 :     initializeInherits(pInherits);
     102       50459 : }
     103             : 
     104       50459 : void FeInheritanceHeader::initializeInherits(::rtl::OString* pInherits)
     105             : {
     106       50459 :     if ( pInherits )
     107             :     {
     108       34440 :         AstScope* pScope = idlc()->scopes()->topNonNull();
     109       34440 :         AstDeclaration* pDecl = pScope->lookupByName(*pInherits);
     110       34440 :         if ( pDecl )
     111             :         {
     112       34440 :             AstDeclaration const * resolved = resolveTypedefs(pDecl);
     113       90320 :             if ( resolved->getNodeType() == getNodeType()
     114       34440 :                  && (resolved->getNodeType() != NT_interface
     115             :                      || static_cast< AstInterface const * >(
     116       21440 :                          resolved)->isDefined()) )
     117             :             {
     118       34440 :                 if ( idlc()->error()->checkPublished( pDecl ) )
     119             :                 {
     120       34440 :                     m_pInherits = pDecl;
     121             :                 }
     122             :             }
     123             :             else
     124             :             {
     125             :                 idlc()->error()->inheritanceError(
     126           0 :                     getNodeType(), getName(), pDecl);
     127             :             }
     128             :         }
     129             :         else
     130             :         {
     131           0 :             idlc()->error()->lookupError(*pInherits);
     132             :         }
     133             :     }
     134       50459 : }
     135             : 
     136             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10