/* Production 80, chapter 3.4, corba 2.3.1 */ public void sequence_type() { /*@bgen(jjtree) sequence_type */ ASTsequence_type jjtn000 = new ASTsequence_type(this, IDLParserTreeConstants.JJTSEQUENCE_TYPE); bool jjtc000 = true; jjtree.openNodeScope(jjtn000); try { jj_consume_token(67); jj_consume_token(68); simple_type_spec(); switch ((jj_ntk==-1)?jj_ntk_calc():jj_ntk) { case 20: jj_consume_token(20); positive_int_const(); break; default: jj_la1[68] = jj_gen; ; break; } jj_consume_token(69); } 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(ASTsequence_type, Object) * @param data the buildinfo in use for the current scope * @return the type container for the IDLSequence type */ public Object visit(ASTsequence_type node, Object data) { CheckParameterForBuildInfo(data, node); BuildInfo containerInfo = (BuildInfo) data; SimpleNode elemTypeNode = (SimpleNode)node.jjtGetChild(0); if (containerInfo.GetContainterType() != null) { // inform the type-manager of structs/unions in creation, because // recursion using seuqneces is the only allowed recursion for structs/unions m_typeManager.PublishTypeForSequenceRecursion(containerInfo.GetContainerSymbol(), containerInfo.GetContainterType()); } Debug.WriteLine("determine element type of IDLSequence"); TypeContainer elemType = (TypeContainer)elemTypeNode.jjtAccept(this, data); // disallow further recursive use of union/struct (before next seq recursion) m_typeManager.UnpublishTypeForSequenceRecursion(); if (elemType == null) { throw new InvalidIdlException( String.Format("sequence element type not defined for {0}", node.GetIdentification())); } elemType = ReplaceByCustomMappedIfNeeded(elemType); // use here the fusioned type as element type; potential unboxing of element type // should be done by users of TypeContainer (if needed)! Debug.WriteLine("seq type determined: " + elemType.GetCompactClsType()); // create CLS array type with the help of GetType(), otherwise not possible Type arrayType; // because not fully defined types are possible, use module and not assembly to get type from Module declModule = elemType.GetCompactClsType().Module; arrayType = declModule.GetType(elemType.GetCompactClsType().FullName + "[]"); // not nice, better solution ? Debug.WriteLine("created array type: " + arrayType); // determin if sequence is bounded or unbounded long bound = 0; if (node.jjtGetNumChildren() > 1) { // bounded sequnece bound = (long) node.jjtGetChild(1).jjtAccept(this, data); } // determine the needed attributes: IdlSequence is required by the sequence itself; // combine with the attribute from the element type // possible are: IdlSequence (for sequence of sequence), ObjectIdlType, // WideChar, StringValue // invariant: boxed value attribute is not among them, because elem type // is in the compact form AttributeExtCollection elemAttributes = elemType.GetCompactTypeAttrInstances(); long seqAttrOrderNr = IdlSequenceAttribute.DetermineSequenceAttributeOrderNr(elemAttributes); IdlSequenceAttribute seqAttr = new IdlSequenceAttribute(seqAttrOrderNr, bound); AttributeExtCollection sequenceAttributes = new AttributeExtCollection(elemAttributes); sequenceAttributes = sequenceAttributes.MergeAttribute(seqAttr); TypeContainer result = new TypeContainer(arrayType, sequenceAttributes ); return result; }