xref: /AOO41X/main/idlc/source/astarray.cxx (revision 2fe1ca3d80babb7c0b18eb5dd968c2181ca17fa3)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_idlc.hxx"
26 #include <idlc/astarray.hxx>
27 
28 using namespace ::rtl;
29 
AstArray(const OString & name,AstType * pType,const ExprList & rDimExpr,AstScope * pScope)30 AstArray::AstArray(const OString& name, AstType* pType, const ExprList& rDimExpr, AstScope* pScope)
31     : AstType(NT_array, name, pScope)
32     , m_pType(pType)
33     , m_dimension((sal_uInt32)(rDimExpr.size()))
34     , m_dimExpressions(rDimExpr)
35 {
36     if ( m_pType )
37         setName(makeName());
38 }
39 
AstArray(AstType * pType,const ExprList & rDimExpr,AstScope * pScope)40 AstArray::AstArray(AstType* pType, const ExprList& rDimExpr, AstScope* pScope)
41     : AstType(NT_array, OString("arrary_"), pScope)
42     , m_pType(pType)
43     , m_dimension((sal_uInt32)(rDimExpr.size()))
44     , m_dimExpressions(rDimExpr)
45 {
46     if ( m_pType )
47         setName(makeName());
48 }
49 
makeName()50 OString AstArray::makeName()
51 {
52     if ( m_pType )
53     {
54         OString name(m_pType->getScopedName());
55         OString openBracket("[");
56         OString closeBracket("]");
57         ExprList::iterator iter = m_dimExpressions.begin();
58         ExprList::iterator end = m_dimExpressions.end();
59 
60         while ( iter != end )
61         {
62             name += openBracket;
63             name += (*iter)->toString();
64             name += closeBracket;
65             ++iter;
66         }
67         return name;
68     }
69     return OString();
70 }
71