Esempio n. 1
0
 /// <summary>
 /// Check useType node for defined-type reference, or call checkComplexType for complex node.
 /// </summary>
 /// <remarks>
 /// This check should apply to the following scenarios:
 /// <list>
 /// Wherever a useType element is found (in struct, array, union, dataset),
 /// Empty typeName attribute is given for a useType element
 /// The typeName given by the useType element is not already defined before this reference in the definitions section
 /// </list>
 /// </remarks>
 /// <param name="aNode"></param>
 /// <param name="defs"></param>
 /// <param name="report"></param>
 private static void checkUseType(AbstractNode aNode, Hashtable defs, ArrayList report)
 {
     if (aNode.GetType().Equals(typeof(UseTypeNode)))
     {
         string sTypeName = aNode.getTypeName();
         if (sTypeName == null || sTypeName.Length < 1)
         {
             report.Add("Error: invalid type name at '" + aNode.toNodeText() + "'.");
         }
         else if (sTypeName.Equals(typeNameJustDefined))
         {
             report.Add("Error: recursively referencing the type for '" + aNode.toNodeText() + "'.");
         }
         else
         {
             if (!defs.Contains(sTypeName))
             {
                 report.Add("Error: type '" + sTypeName + "' used before defined at '" + aNode.toNodeText() + "'.");
             }
         }
     }
     else if (aNode.isComplex())
     {
         checkComplexType((ComplexNode)aNode, defs, report);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Parse and load a union element type
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        protected static UnionNode LoadUnion(XmlTextReader reader)
        {
            string    vname     = reader.GetAttribute("varName");
            string    blocksize = reader.GetAttribute("blockSize");
            UnionNode ut        = new UnionNode();

            if (vname != null)
            {
                ut.setVarName(vname);
            }
            if (blocksize != null)
            {
                ut.setBlockSize(Convert.ToInt32(blocksize));
            }
            bool   inDiscriminantSection = false;
            bool   inCaseSection         = false;
            string dv = null;

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    if (reader.LocalName.Equals("discriminant"))
                    {
                        inDiscriminantSection = true;
                    }
                    else if (reader.LocalName.Equals("case"))
                    {
                        inCaseSection = true;
                        dv            = reader.GetAttribute("discriminantValue");
                    }
                    else
                    {
                        AbstractNode it = ParseNode(reader);
                        if (inDiscriminantSection)
                        {
                            ut.setDiscriminantType(it.getTypeName());
                        }
                        else if (inCaseSection)
                        {
                            CaseNode c = new CaseNode(dv, it);
                            ut.addCase(c);
                        }
                    }
                }
                else if (reader.NodeType == XmlNodeType.EndElement)
                {
                    if (reader.LocalName.Equals("discriminant"))
                    {
                        inDiscriminantSection = false;
                    }
                    else if (reader.LocalName.Equals("case"))
                    {
                        inCaseSection = false;
                    }
                    else if (reader.LocalName.Equals("union"))
                    {
                        break;
                    }
                }
            }
            return(ut);
        }
Esempio n. 3
0
 /// <summary>
 /// Check useType node for defined-type reference, or call checkComplexType for complex node.
 /// </summary>
 /// <remarks>
 /// This check should apply to the following scenarios:
 /// <list>
 /// Wherever a useType element is found (in struct, array, union, dataset),
 /// Empty typeName attribute is given for a useType element
 /// The typeName given by the useType element is not already defined before this reference in the definitions section
 /// </list>
 /// </remarks>
 /// <param name="aNode"></param>
 /// <param name="defs"></param>
 /// <param name="report"></param>
 private static void checkUseType(AbstractNode aNode, Hashtable defs, ArrayList report)
 {
     if (aNode.GetType().Equals(typeof(UseTypeNode)))
     {
         string sTypeName = aNode.getTypeName();
         if (sTypeName==null || sTypeName.Length < 1)
         {
             report.Add("Error: invalid type name at '" + aNode.toNodeText() + "'.");
         }
         else if (sTypeName.Equals(typeNameJustDefined))
         {
             report.Add("Error: recursively referencing the type for '" + aNode.toNodeText() + "'.");
         }
         else
         {
             if (!defs.Contains(sTypeName))
             {
                 report.Add("Error: type '" + sTypeName + "' used before defined at '" + aNode.toNodeText() + "'.");
             }
         }
     }
     else if (aNode.isComplex())
     {
         checkComplexType((ComplexNode)aNode, defs, report);
     }
 }