/** * @see parser.IDLParserVisitor#visit(ASTswitch_body, Object) */ public Object visit(ASTswitch_body node, Object data) { if (!(data is UnionBuildInfo)) { throw new InternalCompilerException("invalid parameter in visit ASTswitch_body"); } UnionBuildInfo buildInfo = (UnionBuildInfo)data; // visit the different switch cases: node.childrenAccept(this, buildInfo); return null; }
/* Production 74, chapter 3.4, corba 2.3.1 */ public void switch_body() { /*@bgen(jjtree) switch_body */ ASTswitch_body jjtn000 = new ASTswitch_body(this, IDLParserTreeConstants.JJTSWITCH_BODY); bool jjtc000 = true; jjtree.openNodeScope(jjtn000); try { while (true) { casex(); switch ((jj_ntk==-1)?jj_ntk_calc():jj_ntk) { case 64: case 65: ; break; default: jj_la1[64] = jj_gen; goto label_19; break; } } label_19: ; } catch (Exception jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } {if (true) throw ;} } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } }
/// <summary> /// collects all explicitely used discriminator values in switch cases. /// </summary> private ArrayList ExtractCoveredDiscriminatorRange(ASTswitch_body node, TypeContainer discrType, BuildInfo unionInfo) { ArrayList result = new ArrayList(); for (int i = 0; i < node.jjtGetNumChildren(); i++) { ASTcasex caseNode = (ASTcasex)node.jjtGetChild(i); object[] discrValsForCase = CollectDiscriminatorValuesForCase(caseNode, discrType, unionInfo); foreach (object discrVal in discrValsForCase) { if (discrVal.Equals(UnionGenerationHelper.DefaultCaseDiscriminator)) { continue; // do not add default case here } if (result.Contains(discrVal)) { throw new InvalidIdlException( String.Format("discriminator value {0} used more than once in {1}", discrVal, node.GetIdentification())); } result.Add(discrVal); } } return result; }