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/fehelper.hxx>
21 : : #include <idlc/errorhandler.hxx>
22 : : #include <idlc/astarray.hxx>
23 : : #include "idlc/idlc.hxx"
24 : :
25 : : using namespace ::rtl;
26 : :
27 : 185619 : FeDeclarator::FeDeclarator(const OString& name, DeclaratorType declType, AstDeclaration* pComplPart)
28 : : : m_pComplexPart(pComplPart)
29 : : , m_name(name)
30 : 185619 : , m_declType(declType)
31 : : {
32 : 185619 : }
33 : :
34 : 92671 : FeDeclarator::~FeDeclarator()
35 : : {
36 [ - + ]: 185342 : }
37 : :
38 : 156405 : sal_Bool FeDeclarator::checkType(AstDeclaration const * type)
39 : : {
40 : 156405 : OString tmp(m_name);
41 : 156405 : sal_Int32 count = m_name.lastIndexOf( ':' );
42 [ - + ]: 156405 : if( count != -1 )
43 : 0 : tmp = m_name.copy( count+1 );
44 : :
45 [ + + ]: 156405 : if (tmp == type->getLocalName())
46 : 687 : return sal_False;
47 : : else
48 : 156405 : return sal_True;
49 : : }
50 : :
51 : 185619 : AstType const * FeDeclarator::compose(AstDeclaration const * pDecl)
52 : : {
53 : : AstArray* pArray;
54 : : AstType* pType;
55 : :
56 [ - + ]: 185619 : if ( pDecl == 0 )
57 : : {
58 : 0 : return NULL;
59 : : }
60 [ - + ]: 185619 : if ( !pDecl->isType() )
61 : : {
62 : 0 : idlc()->error()->noTypeError(pDecl);
63 : 0 : return NULL;
64 : : }
65 : 185619 : pType = (AstType*)pDecl;
66 [ - + ][ # # ]: 185619 : if (m_declType == FD_simple || m_pComplexPart == NULL)
67 : 185619 : 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 : 185619 : return NULL; // return through this statement should not happen
89 : : }
90 : :
91 : 57198 : 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 : 57198 : , m_pInherits(NULL)
97 : : {
98 [ + + ]: 57198 : if (typeParameters != 0) {
99 [ + - ]: 49 : m_typeParameters = *typeParameters;
100 : : }
101 [ + - ]: 57198 : initializeInherits(pInherits);
102 : 57198 : }
103 : :
104 : 57198 : void FeInheritanceHeader::initializeInherits(::rtl::OString* pInherits)
105 : : {
106 [ + + ]: 57198 : if ( pInherits )
107 : : {
108 : 38214 : AstScope* pScope = idlc()->scopes()->topNonNull();
109 : 38214 : AstDeclaration* pDecl = pScope->lookupByName(*pInherits);
110 [ + - ]: 38214 : if ( pDecl )
111 : : {
112 : 38214 : AstDeclaration const * resolved = resolveTypedefs(pDecl);
113 [ + - ][ + - : 101430 : if ( resolved->getNodeType() == getNodeType()
+ + + - ]
114 : 38214 : && (resolved->getNodeType() != NT_interface
115 : : || static_cast< AstInterface const * >(
116 : 25002 : resolved)->isDefined()) )
117 : : {
118 [ + - ]: 38214 : if ( idlc()->error()->checkPublished( pDecl ) )
119 : : {
120 : 38214 : 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 : 57198 : }
135 : :
136 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|