1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <idlc/fehelper.hxx>
21 #include <idlc/errorhandler.hxx>
22 #include <idlc/astarray.hxx>
23 #include "idlc/idlc.hxx"
25 using namespace ::rtl
;
27 FeDeclarator::FeDeclarator(const OString
& name
, DeclaratorType declType
, AstDeclaration
* pComplPart
)
28 : m_pComplexPart(pComplPart
)
30 , m_declType(declType
)
34 FeDeclarator::~FeDeclarator()
38 sal_Bool
FeDeclarator::checkType(AstDeclaration
const * type
)
41 sal_Int32 count
= m_name
.lastIndexOf( ':' );
43 tmp
= m_name
.copy( count
+1 );
45 if (tmp
== type
->getLocalName())
51 AstType
const * FeDeclarator::compose(AstDeclaration
const * pDecl
)
60 if ( !pDecl
->isType() )
62 idlc()->error()->noTypeError(pDecl
);
65 pType
= (AstType
*)pDecl
;
66 if (m_declType
== FD_simple
|| m_pComplexPart
== NULL
)
69 if (m_pComplexPart
->getNodeType() == NT_array
)
71 pArray
= (AstArray
*)m_pComplexPart
;
72 pArray
->setType(pType
);
74 // insert array type in global scope
75 AstScope
* pScope
= idlc()->scopes()->bottom();
78 AstDeclaration
* pDecl2
= pScope
->addDeclaration(pArray
);
79 if ( (AstDeclaration
*)pArray
!= pDecl2
)
81 delete m_pComplexPart
;
82 m_pComplexPart
= pDecl2
;
88 return NULL
; // return through this statement should not happen
91 FeInheritanceHeader::FeInheritanceHeader(
92 NodeType nodeType
, OString
* pName
, OString
* pInherits
,
93 std::vector
< OString
> * typeParameters
)
94 : m_nodeType(nodeType
)
98 if (typeParameters
!= 0) {
99 m_typeParameters
= *typeParameters
;
101 initializeInherits(pInherits
);
104 void FeInheritanceHeader::initializeInherits(OString
* pInherits
)
108 AstScope
* pScope
= idlc()->scopes()->topNonNull();
109 AstDeclaration
* pDecl
= pScope
->lookupByName(*pInherits
);
112 AstDeclaration
const * resolved
= resolveTypedefs(pDecl
);
113 if ( resolved
->getNodeType() == getNodeType()
114 && (resolved
->getNodeType() != NT_interface
115 || static_cast< AstInterface
const * >(
116 resolved
)->isDefined()) )
118 if ( idlc()->error()->checkPublished( pDecl
) )
125 idlc()->error()->inheritanceError(
126 getNodeType(), getName(), pDecl
);
131 idlc()->error()->lookupError(*pInherits
);
136 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */