xref: /trunk/main/idlc/source/astunion.cxx (revision cf6516809c57e1bb0a940545cca99cdad54d4ce2)
1*2fe1ca3dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2fe1ca3dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2fe1ca3dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2fe1ca3dSAndrew Rist  * distributed with this work for additional information
6*2fe1ca3dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2fe1ca3dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2fe1ca3dSAndrew Rist  * "License"); you may not use this file except in compliance
9*2fe1ca3dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*2fe1ca3dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*2fe1ca3dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2fe1ca3dSAndrew Rist  * software distributed under the License is distributed on an
15*2fe1ca3dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2fe1ca3dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*2fe1ca3dSAndrew Rist  * specific language governing permissions and limitations
18*2fe1ca3dSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*2fe1ca3dSAndrew Rist  *************************************************************/
21*2fe1ca3dSAndrew Rist 
22*2fe1ca3dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_idlc.hxx"
26cdf0e10cSrcweir #include <idlc/astunion.hxx>
27cdf0e10cSrcweir #include <idlc/astbasetype.hxx>
28cdf0e10cSrcweir #include <idlc/errorhandler.hxx>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include "registry/version.h"
31cdf0e10cSrcweir #include "registry/writer.hxx"
32cdf0e10cSrcweir 
33cdf0e10cSrcweir using namespace ::rtl;
34cdf0e10cSrcweir 
AstUnion(const::rtl::OString & name,AstType * pDiscType,AstScope * pScope)35cdf0e10cSrcweir AstUnion::AstUnion(const ::rtl::OString& name, AstType* pDiscType, AstScope* pScope)
36cdf0e10cSrcweir     : AstStruct(NT_union, name, NULL, pScope)
37cdf0e10cSrcweir     , m_pDiscriminantType(pDiscType)
38cdf0e10cSrcweir     , m_discExprType(ET_long)
39cdf0e10cSrcweir {
40cdf0e10cSrcweir     AstBaseType* pBaseType;
41cdf0e10cSrcweir 
42cdf0e10cSrcweir     if ( !pDiscType )
43cdf0e10cSrcweir     {
44cdf0e10cSrcweir         m_pDiscriminantType = NULL;
45cdf0e10cSrcweir         m_discExprType = ET_none;
46cdf0e10cSrcweir         return;
47cdf0e10cSrcweir     }
48cdf0e10cSrcweir     /*
49cdf0e10cSrcweir      * If the discriminator type is a predefined type
50cdf0e10cSrcweir      * then install the equivalent coercion target type in
51cdf0e10cSrcweir      * the pd_udisc_type field.
52cdf0e10cSrcweir      */
53cdf0e10cSrcweir     if ( pDiscType->getNodeType() == NT_predefined )
54cdf0e10cSrcweir     {
55cdf0e10cSrcweir         pBaseType = (AstBaseType*)pDiscType;
56cdf0e10cSrcweir         if ( !pBaseType )
57cdf0e10cSrcweir         {
58cdf0e10cSrcweir             m_pDiscriminantType = NULL;
59cdf0e10cSrcweir             m_discExprType = ET_none;
60cdf0e10cSrcweir             return;
61cdf0e10cSrcweir         }
62cdf0e10cSrcweir         m_pDiscriminantType = pDiscType;
63cdf0e10cSrcweir         switch (pBaseType->getExprType())
64cdf0e10cSrcweir         {
65cdf0e10cSrcweir             case ET_long:
66cdf0e10cSrcweir             case ET_ulong:
67cdf0e10cSrcweir             case ET_short:
68cdf0e10cSrcweir             case ET_ushort:
69cdf0e10cSrcweir             case ET_char:
70cdf0e10cSrcweir             case ET_boolean:
71cdf0e10cSrcweir                 m_discExprType = pBaseType->getExprType();
72cdf0e10cSrcweir                 break;
73cdf0e10cSrcweir             default:
74cdf0e10cSrcweir                 m_discExprType = ET_none;
75cdf0e10cSrcweir                 m_pDiscriminantType = NULL;
76cdf0e10cSrcweir                 break;
77cdf0e10cSrcweir         }
78cdf0e10cSrcweir     } else
79cdf0e10cSrcweir         if (pDiscType->getNodeType() == NT_enum)
80cdf0e10cSrcweir         {
81cdf0e10cSrcweir             m_discExprType = ET_any;
82cdf0e10cSrcweir             m_pDiscriminantType = pDiscType;
83cdf0e10cSrcweir         } else
84cdf0e10cSrcweir         {
85cdf0e10cSrcweir             m_discExprType = ET_none;
86cdf0e10cSrcweir             m_pDiscriminantType = NULL;
87cdf0e10cSrcweir         }
88cdf0e10cSrcweir 
89cdf0e10cSrcweir     if ( !m_pDiscriminantType )
90cdf0e10cSrcweir         idlc()->error()->error2(EIDL_DISC_TYPE, this, pDiscType);
91cdf0e10cSrcweir }
92cdf0e10cSrcweir 
~AstUnion()93cdf0e10cSrcweir AstUnion::~AstUnion()
94cdf0e10cSrcweir {
95cdf0e10cSrcweir }
96cdf0e10cSrcweir 
addDeclaration(AstDeclaration * pDecl)97cdf0e10cSrcweir AstDeclaration* AstUnion::addDeclaration(AstDeclaration* pDecl)
98cdf0e10cSrcweir {
99cdf0e10cSrcweir     if ( pDecl->getNodeType() == NT_union_branch )
100cdf0e10cSrcweir     {
101cdf0e10cSrcweir         AstUnionBranch* pBranch = (AstUnionBranch*)pDecl;
102cdf0e10cSrcweir         if ( lookupBranch(pBranch) )
103cdf0e10cSrcweir         {
104cdf0e10cSrcweir             idlc()->error()->error2(EIDL_MULTIPLE_BRANCH, this, pDecl);
105cdf0e10cSrcweir             return NULL;
106cdf0e10cSrcweir         }
107cdf0e10cSrcweir     }
108cdf0e10cSrcweir 
109cdf0e10cSrcweir     return AstScope::addDeclaration(pDecl);
110cdf0e10cSrcweir }
111cdf0e10cSrcweir 
lookupBranch(AstUnionBranch * pBranch)112cdf0e10cSrcweir AstUnionBranch* AstUnion::lookupBranch(AstUnionBranch* pBranch)
113cdf0e10cSrcweir {
114cdf0e10cSrcweir     AstUnionLabel* pLabel = NULL;
115cdf0e10cSrcweir 
116cdf0e10cSrcweir     if ( pBranch )
117cdf0e10cSrcweir         pLabel = pBranch->getLabel();
118cdf0e10cSrcweir 
119cdf0e10cSrcweir     if ( pLabel )
120cdf0e10cSrcweir     {
121cdf0e10cSrcweir         if (pLabel->getLabelKind() == UL_default)
122cdf0e10cSrcweir             return lookupDefault();
123cdf0e10cSrcweir         if (m_discExprType == ET_any)
124cdf0e10cSrcweir             /* CONVENTION: indicates enum discr */
125cdf0e10cSrcweir             return lookupEnum(pBranch);
126cdf0e10cSrcweir         return lookupLabel(pBranch);
127cdf0e10cSrcweir     }
128cdf0e10cSrcweir     return NULL;
129cdf0e10cSrcweir }
130cdf0e10cSrcweir 
lookupDefault(sal_Bool bReportError)131cdf0e10cSrcweir AstUnionBranch* AstUnion::lookupDefault(sal_Bool bReportError)
132cdf0e10cSrcweir {
133cdf0e10cSrcweir     DeclList::const_iterator iter = getIteratorBegin();
134cdf0e10cSrcweir     DeclList::const_iterator end = getIteratorEnd();
135cdf0e10cSrcweir     AstUnionBranch      *pBranch = NULL;
136cdf0e10cSrcweir     AstDeclaration      *pDecl = NULL;
137cdf0e10cSrcweir 
138cdf0e10cSrcweir     while ( iter != end )
139cdf0e10cSrcweir     {
140cdf0e10cSrcweir         pDecl = *iter;
141cdf0e10cSrcweir         if ( pDecl->getNodeType() == NT_union_branch )
142cdf0e10cSrcweir         {
143cdf0e10cSrcweir             pBranch = (AstUnionBranch*)pDecl;
144cdf0e10cSrcweir             if (pBranch == NULL)
145cdf0e10cSrcweir             {
146cdf0e10cSrcweir                 ++iter;
147cdf0e10cSrcweir                 continue;
148cdf0e10cSrcweir             }
149cdf0e10cSrcweir             if ( pBranch->getLabel() != NULL &&
150cdf0e10cSrcweir                  pBranch->getLabel()->getLabelKind() == UL_default)
151cdf0e10cSrcweir             {
152cdf0e10cSrcweir                 if ( bReportError )
153cdf0e10cSrcweir                     idlc()->error()->error2(EIDL_MULTIPLE_BRANCH, this, pBranch);
154cdf0e10cSrcweir                 return pBranch;
155cdf0e10cSrcweir             }
156cdf0e10cSrcweir         }
157cdf0e10cSrcweir         ++iter;
158cdf0e10cSrcweir     }
159cdf0e10cSrcweir     return NULL;
160cdf0e10cSrcweir }
161cdf0e10cSrcweir 
lookupLabel(AstUnionBranch * pBranch)162cdf0e10cSrcweir AstUnionBranch* AstUnion::lookupLabel(AstUnionBranch* pBranch)
163cdf0e10cSrcweir {
164cdf0e10cSrcweir     AstUnionLabel* pLabel = pBranch->getLabel();
165cdf0e10cSrcweir 
166cdf0e10cSrcweir     if ( !pLabel->getLabelValue() )
167cdf0e10cSrcweir         return pBranch;
168cdf0e10cSrcweir //  pLabel->getLabelValue()->setExprValue(pLabel->getLabelValue()->coerce(m_discExprType, sal_False));
169cdf0e10cSrcweir     AstExprValue* pLabelValue = pLabel->getLabelValue()->coerce(
170cdf0e10cSrcweir         m_discExprType, sal_False);
171cdf0e10cSrcweir     if ( !pLabelValue )
172cdf0e10cSrcweir     {
173cdf0e10cSrcweir         idlc()->error()->evalError(pLabel->getLabelValue());
174cdf0e10cSrcweir         return pBranch;
175cdf0e10cSrcweir     } else
176cdf0e10cSrcweir     {
177cdf0e10cSrcweir         pLabel->getLabelValue()->setExprValue(pLabelValue);
178cdf0e10cSrcweir     }
179cdf0e10cSrcweir 
180cdf0e10cSrcweir     DeclList::const_iterator iter = getIteratorBegin();
181cdf0e10cSrcweir     DeclList::const_iterator end = getIteratorEnd();
182cdf0e10cSrcweir     AstUnionBranch* pB = NULL;
183cdf0e10cSrcweir     AstDeclaration* pDecl = NULL;
184cdf0e10cSrcweir 
185cdf0e10cSrcweir     while ( iter != end )
186cdf0e10cSrcweir     {
187cdf0e10cSrcweir         pDecl = *iter;
188cdf0e10cSrcweir         if ( pDecl->getNodeType() == NT_union_branch )
189cdf0e10cSrcweir         {
190cdf0e10cSrcweir             pB = (AstUnionBranch*)pDecl;
191cdf0e10cSrcweir             if ( !pB )
192cdf0e10cSrcweir             {
193cdf0e10cSrcweir                 ++iter;
194cdf0e10cSrcweir                 continue;
195cdf0e10cSrcweir             }
196cdf0e10cSrcweir             if ( pB->getLabel() != NULL &&
197cdf0e10cSrcweir                  pB->getLabel()->getLabelKind() == UL_label &&
198cdf0e10cSrcweir                  pB->getLabel()->getLabelValue()->compare(pLabel->getLabelValue()) )
199cdf0e10cSrcweir             {
200cdf0e10cSrcweir                 idlc()->error()->error2(EIDL_MULTIPLE_BRANCH, this, pBranch);
201cdf0e10cSrcweir                 return pBranch;
202cdf0e10cSrcweir             }
203cdf0e10cSrcweir         }
204cdf0e10cSrcweir         ++iter;
205cdf0e10cSrcweir     }
206cdf0e10cSrcweir     return NULL;
207cdf0e10cSrcweir }
208cdf0e10cSrcweir 
lookupEnum(AstUnionBranch * pBranch)209cdf0e10cSrcweir AstUnionBranch* AstUnion::lookupEnum(AstUnionBranch* pBranch)
210cdf0e10cSrcweir {
211cdf0e10cSrcweir     AstDeclaration const * pType = resolveTypedefs(m_pDiscriminantType);
212cdf0e10cSrcweir     if ( pType->getNodeType() != NT_enum )
213cdf0e10cSrcweir         return NULL;
214cdf0e10cSrcweir 
215cdf0e10cSrcweir     AstUnionLabel* pLabel = pBranch->getLabel();
216cdf0e10cSrcweir     AstExpression* pExpr = pLabel->getLabelValue();
217cdf0e10cSrcweir     if ( !pExpr )
218cdf0e10cSrcweir         return pBranch;
219cdf0e10cSrcweir 
220cdf0e10cSrcweir     /*
221cdf0e10cSrcweir      * Expecting a symbol label
222cdf0e10cSrcweir      */
223cdf0e10cSrcweir     if ( pExpr->getCombOperator() != EC_symbol)
224cdf0e10cSrcweir     {
225cdf0e10cSrcweir         idlc()->error()->enumValExpected(this);
226cdf0e10cSrcweir         return pBranch;
227cdf0e10cSrcweir     }
228cdf0e10cSrcweir 
229cdf0e10cSrcweir     /*
230cdf0e10cSrcweir      * See if the symbol defines a constant in the discriminator enum
231cdf0e10cSrcweir      */
232cdf0e10cSrcweir     AstEnum* pEnum = (AstEnum*)pType;
233cdf0e10cSrcweir     AstDeclaration* pDecl = pEnum->lookupByName(*pExpr->getSymbolicName());
234cdf0e10cSrcweir     if ( pDecl == NULL || pDecl->getScope() != pEnum)
235cdf0e10cSrcweir     {
236cdf0e10cSrcweir         idlc()->error()->enumValLookupFailure(this, pEnum, *pExpr->getSymbolicName());
237cdf0e10cSrcweir         return pBranch;
238cdf0e10cSrcweir     }
239cdf0e10cSrcweir 
240cdf0e10cSrcweir 
241cdf0e10cSrcweir     DeclList::const_iterator iter = getIteratorBegin();
242cdf0e10cSrcweir     DeclList::const_iterator end = getIteratorEnd();
243cdf0e10cSrcweir     AstUnionBranch* pB = NULL;
244cdf0e10cSrcweir     pDecl = NULL;
245cdf0e10cSrcweir 
246cdf0e10cSrcweir     while ( iter != end )
247cdf0e10cSrcweir     {
248cdf0e10cSrcweir         pDecl = *iter;
249cdf0e10cSrcweir         if ( pDecl->getNodeType() == NT_union_branch )
250cdf0e10cSrcweir         {
251cdf0e10cSrcweir             pB = (AstUnionBranch*)pDecl;
252cdf0e10cSrcweir             if ( !pB )
253cdf0e10cSrcweir             {
254cdf0e10cSrcweir                 ++iter;
255cdf0e10cSrcweir                 continue;
256cdf0e10cSrcweir             }
257cdf0e10cSrcweir             if ( pB->getLabel() != NULL &&
258cdf0e10cSrcweir                  pB->getLabel()->getLabelKind() == UL_label &&
259cdf0e10cSrcweir                  pB->getLabel()->getLabelValue()->compare(pLabel->getLabelValue()) )
260cdf0e10cSrcweir             {
261cdf0e10cSrcweir                 idlc()->error()->error2(EIDL_MULTIPLE_BRANCH, this, pBranch);
262cdf0e10cSrcweir                 return pBranch;
263cdf0e10cSrcweir             }
264cdf0e10cSrcweir         }
265cdf0e10cSrcweir         ++iter;
266cdf0e10cSrcweir     }
267cdf0e10cSrcweir     return NULL;
268cdf0e10cSrcweir }
269cdf0e10cSrcweir 
dump(RegistryKey & rKey)270cdf0e10cSrcweir sal_Bool AstUnion::dump(RegistryKey& rKey)
271cdf0e10cSrcweir {
272cdf0e10cSrcweir     RegistryKey localKey;
273cdf0e10cSrcweir     if (rKey.createKey( OStringToOUString(getFullName(), RTL_TEXTENCODING_UTF8 ), localKey))
274cdf0e10cSrcweir     {
275cdf0e10cSrcweir         fprintf(stderr, "%s: warning, could not create key '%s' in '%s'\n",
276cdf0e10cSrcweir                 idlc()->getOptions()->getProgramName().getStr(),
277cdf0e10cSrcweir                 getFullName().getStr(), OUStringToOString(rKey.getRegistryName(), RTL_TEXTENCODING_UTF8).getStr());
278cdf0e10cSrcweir         return sal_False;
279cdf0e10cSrcweir     }
280cdf0e10cSrcweir 
281cdf0e10cSrcweir     sal_uInt16 nMember = getNodeCount(NT_union_branch);
282cdf0e10cSrcweir 
283cdf0e10cSrcweir     OUString emptyStr;
284cdf0e10cSrcweir     typereg::Writer aBlob(
285cdf0e10cSrcweir         TYPEREG_VERSION_0, getDocumentation(), emptyStr, RT_TYPE_UNION,
286cdf0e10cSrcweir         false, OStringToOUString(getRelativName(), RTL_TEXTENCODING_UTF8), 1,
287cdf0e10cSrcweir         nMember, 0, 0);
288cdf0e10cSrcweir     aBlob.setSuperTypeName(
289cdf0e10cSrcweir         0,
290cdf0e10cSrcweir         OStringToOUString(
291cdf0e10cSrcweir             getDiscrimantType()->getScopedName(), RTL_TEXTENCODING_UTF8));
292cdf0e10cSrcweir 
293cdf0e10cSrcweir     if ( nMember > 0 )
294cdf0e10cSrcweir     {
295cdf0e10cSrcweir         DeclList::const_iterator iter = getIteratorBegin();
296cdf0e10cSrcweir         DeclList::const_iterator end = getIteratorEnd();
297cdf0e10cSrcweir         AstDeclaration* pDecl = NULL;
298cdf0e10cSrcweir         AstUnionBranch* pBranch = NULL;
299cdf0e10cSrcweir         AstUnionBranch* pDefault = lookupDefault(sal_False);
300cdf0e10cSrcweir         AstUnionLabel*  pLabel = NULL;
301cdf0e10cSrcweir         AstExprValue*   pExprValue = NULL;
302cdf0e10cSrcweir         RTConstValue    aConst;
303cdf0e10cSrcweir         RTFieldAccess   access = RT_ACCESS_READWRITE;
304cdf0e10cSrcweir         OUString    docu;
305cdf0e10cSrcweir         sal_uInt16  index = 0;
306cdf0e10cSrcweir         if ( pDefault )
307cdf0e10cSrcweir             index = 1;
308cdf0e10cSrcweir 
309cdf0e10cSrcweir         sal_Int64   disc = 0;
310cdf0e10cSrcweir         while ( iter != end )
311cdf0e10cSrcweir         {
312cdf0e10cSrcweir             pDecl = *iter;
313cdf0e10cSrcweir             if ( pDecl->getNodeType() == NT_union_branch )
314cdf0e10cSrcweir             {
315cdf0e10cSrcweir                 pBranch = (AstUnionBranch*)pDecl;
316cdf0e10cSrcweir                 if (pBranch == pDefault)
317cdf0e10cSrcweir                 {
318cdf0e10cSrcweir                     ++iter;
319cdf0e10cSrcweir                     continue;
320cdf0e10cSrcweir                 }
321cdf0e10cSrcweir 
322cdf0e10cSrcweir                 pLabel = pBranch->getLabel();
323cdf0e10cSrcweir                 pExprValue = pLabel->getLabelValue()->coerce(ET_hyper, sal_False);
324cdf0e10cSrcweir                 aConst.m_type = RT_TYPE_INT64;
325cdf0e10cSrcweir                 aConst.m_value.aHyper = pExprValue->u.hval;
326cdf0e10cSrcweir                 if ( aConst.m_value.aHyper > disc )
327cdf0e10cSrcweir                     disc = aConst.m_value.aHyper;
328cdf0e10cSrcweir 
329cdf0e10cSrcweir                 aBlob.setFieldData(
330cdf0e10cSrcweir                     index++, pBranch->getDocumentation(), emptyStr, RT_ACCESS_READWRITE,
331cdf0e10cSrcweir                     OStringToOUString(
332cdf0e10cSrcweir                         pBranch->getLocalName(), RTL_TEXTENCODING_UTF8),
333cdf0e10cSrcweir                     OStringToOUString(
334cdf0e10cSrcweir                         pBranch->getType()->getRelativName(),
335cdf0e10cSrcweir                         RTL_TEXTENCODING_UTF8),
336cdf0e10cSrcweir                     aConst);
337cdf0e10cSrcweir             }
338cdf0e10cSrcweir             ++iter;
339cdf0e10cSrcweir         }
340cdf0e10cSrcweir 
341cdf0e10cSrcweir         if ( pDefault )
342cdf0e10cSrcweir         {
343cdf0e10cSrcweir             access = RT_ACCESS_DEFAULT;
344cdf0e10cSrcweir             aConst.m_type = RT_TYPE_INT64;
345cdf0e10cSrcweir             aConst.m_value.aHyper = disc + 1;
346cdf0e10cSrcweir             aBlob.setFieldData(
347cdf0e10cSrcweir                 0, pDefault->getDocumentation(), emptyStr, RT_ACCESS_DEFAULT,
348cdf0e10cSrcweir                 OStringToOUString(
349cdf0e10cSrcweir                     pDefault->getLocalName(), RTL_TEXTENCODING_UTF8),
350cdf0e10cSrcweir                 OStringToOUString(
351cdf0e10cSrcweir                     pDefault->getType()->getRelativName(),
352cdf0e10cSrcweir                     RTL_TEXTENCODING_UTF8),
353cdf0e10cSrcweir                 aConst);
354cdf0e10cSrcweir         }
355cdf0e10cSrcweir     }
356cdf0e10cSrcweir 
357cdf0e10cSrcweir     sal_uInt32 aBlobSize;
358cdf0e10cSrcweir     void const * pBlob = aBlob.getBlob(&aBlobSize);
359cdf0e10cSrcweir 
360cdf0e10cSrcweir     if (localKey.setValue(OUString(), RG_VALUETYPE_BINARY,
361cdf0e10cSrcweir                           (RegValue)pBlob, aBlobSize))
362cdf0e10cSrcweir     {
363cdf0e10cSrcweir         fprintf(stderr, "%s: warning, could not set value of key \"%s\" in %s\n",
364cdf0e10cSrcweir                 idlc()->getOptions()->getProgramName().getStr(),
365cdf0e10cSrcweir                 getFullName().getStr(), OUStringToOString(localKey.getRegistryName(), RTL_TEXTENCODING_UTF8).getStr());
366cdf0e10cSrcweir         return sal_False;
367cdf0e10cSrcweir     }
368cdf0e10cSrcweir 
369cdf0e10cSrcweir     return sal_True;
370cdf0e10cSrcweir }
371cdf0e10cSrcweir 
AstUnionBranch(AstUnionLabel * pLabel,AstType const * pType,const::rtl::OString & name,AstScope * pScope)372cdf0e10cSrcweir AstUnionBranch::AstUnionBranch(AstUnionLabel* pLabel, AstType const * pType, const ::rtl::OString& name, AstScope* pScope)
373cdf0e10cSrcweir     : AstMember(NT_union_branch, pType, name, pScope)
374cdf0e10cSrcweir     , m_pLabel(pLabel)
375cdf0e10cSrcweir {
376cdf0e10cSrcweir }
377cdf0e10cSrcweir 
~AstUnionBranch()378cdf0e10cSrcweir AstUnionBranch::~AstUnionBranch()
379cdf0e10cSrcweir {
380cdf0e10cSrcweir     if ( m_pLabel )
381cdf0e10cSrcweir         delete m_pLabel;
382cdf0e10cSrcweir }
383cdf0e10cSrcweir 
AstUnionLabel(UnionLabel labelKind,AstExpression * pExpr)384cdf0e10cSrcweir AstUnionLabel::AstUnionLabel(UnionLabel labelKind, AstExpression* pExpr)
385cdf0e10cSrcweir     : m_label(labelKind)
386cdf0e10cSrcweir     , m_pLabelValue(pExpr)
387cdf0e10cSrcweir {
388cdf0e10cSrcweir     if ( m_pLabelValue )
389cdf0e10cSrcweir         m_pLabelValue->evaluate(EK_const);
390cdf0e10cSrcweir }
391cdf0e10cSrcweir 
~AstUnionLabel()392cdf0e10cSrcweir AstUnionLabel::~AstUnionLabel()
393cdf0e10cSrcweir {
394cdf0e10cSrcweir     if ( m_pLabelValue )
395cdf0e10cSrcweir         delete m_pLabelValue;
396cdf0e10cSrcweir }
397