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 #ifndef _IDLC_ASTUNION_HXX_ 24 #define _IDLC_ASTUNION_HXX_ 25 26 #include <idlc/aststruct.hxx> 27 #include <idlc/astunionbranch.hxx> 28 29 class AstUnion : public AstStruct 30 { 31 public: 32 AstUnion(const ::rtl::OString& name, AstType* pDiscType, AstScope* pScope); 33 virtual ~AstUnion(); 34 getDiscrimantType()35 AstType* getDiscrimantType() 36 { return m_pDiscriminantType; } getDiscrimantExprType()37 ExprType getDiscrimantExprType() 38 { return m_discExprType; } 39 40 virtual sal_Bool dump(RegistryKey& rKey); 41 42 virtual AstDeclaration* addDeclaration(AstDeclaration* pDecl); 43 protected: 44 // Look up a branch by node pointer 45 AstUnionBranch* lookupBranch(AstUnionBranch* pBranch); 46 47 // Look up the branch with the "default" label 48 AstUnionBranch* lookupDefault(sal_Bool bReportError = sal_True ); 49 50 // Look up a branch given a branch with a label. This is used to 51 // check for duplicate labels 52 AstUnionBranch* lookupLabel(AstUnionBranch* pBranch); 53 54 // Look up a union branch given an enumerator. This is used to 55 // check for duplicate enum labels 56 AstUnionBranch* lookupEnum(AstUnionBranch* pBranch); 57 58 private: 59 AstType* m_pDiscriminantType; 60 ExprType m_discExprType; 61 }; 62 63 #endif // _IDLC_ASTUNION_HXX_ 64 65