/* Production 72, chapter 3.4, corba 2.3.1 */ public void union_type() { /*@bgen(jjtree) union_type */ ASTunion_type jjtn000 = new ASTunion_type(this, IDLParserTreeConstants.JJTUNION_TYPE); bool jjtc000 = true; jjtree.openNodeScope(jjtn000);String ident = ""; try { jj_consume_token(62); ident = identifier(); // recursive definition using a sequence is permitted --> publish symbol already here Scope currentScope = m_symbolTable.getCurrentScope(); currentScope.addSymbol(ident); jjtn000.setIdent(ident); jj_consume_token(63); jj_consume_token(29); m_symbolTable.openScope(ident, true); // open a scope for type declaration inside the union switch_type_spec(); jj_consume_token(30); jj_consume_token(14); switch_body(); jj_consume_token(15); jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; m_symbolTable.closeScope(); } catch (Exception jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } {if (true) throw ;} } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } }
/** * @see parser.IDLParserVisitor#visit(ASTunion_type, Object) */ public Object visit(ASTunion_type node, Object data) { // generate the struct for this union CheckParameterForBuildInfo(data, node); BuildInfo buildInfo = (BuildInfo) data; Symbol forSymbol = buildInfo.GetBuildScope().getSymbol(node.getIdent()); // check if type is known from a previous run over a parse tree --> if so: skip // not needed to check if struct is a nested types, because parent type should already be skipped // --> code generation for all nested types skipped too if (m_typeManager.CheckSkip(forSymbol)) { return m_typeManager.GetKnownType(forSymbol); } // create Helper for union generation String fullyQualName = buildInfo.GetBuildScope().GetFullyQualifiedNameForSymbol(forSymbol.getSymbolName()); UnionGenerationHelper genHelper = m_typeManager.StartUnionTypeDefinition(forSymbol, fullyQualName); UnionBuildInfo thisInfo = new UnionBuildInfo(buildInfo.GetBuildScope().getChildScope(forSymbol.getSymbolName()), genHelper, forSymbol); Node switchBody = node.jjtGetChild(1); TypeContainer discrType = (TypeContainer)node.jjtGetChild(0).jjtAccept(this, thisInfo); if (discrType == null) { throw new InvalidIdlException( String.Format("dicriminator type {0} not (yet) defined for union {1}", ((SimpleNode)node.jjtGetChild(0)).GetIdentification(), node.GetIdentification())); } discrType = ReplaceByCustomMappedIfNeeded(discrType); ArrayList coveredDiscriminatorRange = ExtractCoveredDiscriminatorRange((ASTswitch_body)switchBody, discrType, thisInfo); genHelper.AddDiscriminatorFieldAndProperty(discrType, coveredDiscriminatorRange); switchBody.jjtAccept(this, thisInfo); // create the resulting type Type resultType = m_typeManager.EndUnionTypeDefinition(forSymbol, genHelper); return new TypeContainer(resultType); }