Exemple #1
0
        public static void PrintCInitialize(ArrayType pThis, PEREffectiveConstraint cns,
            Asn1Value defauleVal, StreamWriterLevel c, string typeName, string varName, int lev, int arrayDepth)
        {
            long min = pThis.minItems(cns);
            long max = pThis.maxItems(cns);
            string i = "i" + arrayDepth.ToString();
            string prefix = "";
            bool topLevel = !varName.Contains("->");
            if (topLevel)
                prefix = varName + "->";
            else
            {
                prefix = varName + ".";
            }

            ArrayValue arVal = defauleVal as ArrayValue;
            if (arVal == null)
            {
                c.P(lev);
                c.WriteLine("{0}nCount = 0;", prefix);

                c.P(lev); c.WriteLine("for({0}=0;{0}<{1};{0}++)", i, pThis.maxItems(cns));
                c.P(lev); c.WriteLine("{");
                ((ISCCType)pThis.m_type).PrintCInitialize(pThis.m_type.PEREffectiveConstraint, pThis.m_type.GetOneValidValue(), c,
                    typeName + "_arr", prefix + "arr[" + i + "]", lev + 1, arrayDepth + 1);
                c.P(lev); c.WriteLine("}");
            }
            else
            {
                c.P(lev);
                c.WriteLine("{0}nCount = {1};", prefix, arVal.m_children.Count);
                for (int k = 0; k < arVal.m_children.Count; k++)
                {
                    c.P(lev); c.WriteLine("{");
                    ((ISCCType)pThis.m_type).PrintCInitialize(pThis.m_type.PEREffectiveConstraint, arVal.m_children[k], c,
                        typeName + "_arr", prefix + "arr[" + k.ToString() + "]", lev + 1, arrayDepth + 1);
                    c.P(lev); c.WriteLine("}");
                }
            }
        }
Exemple #2
0
        public static void PrintCIsConstraintValid(ArrayType pThis, PEREffectiveConstraint cns, StreamWriterLevel c, string errorCode, string typeName, string varName, int lev, int arrayDepth)
        {
            long min = pThis.minItems(cns);
            long max = pThis.maxItems(cns);
            string i = "i" + arrayDepth.ToString();
            string prefix = "";
            bool topLevel = !varName.Contains("->");

            CSSType.PrintCIsConstraintValid(pThis, cns, c, errorCode, typeName, varName, lev, arrayDepth);

            c.WriteLine();
            if (topLevel)
                prefix = varName + "->";
            else
            {
                prefix = varName + ".";
            }

            c.P(lev); c.WriteLine("for({0}=0;{0}<{1}nCount;{0}++)", i, prefix);
            c.P(lev); c.WriteLine("{");
            ((ISCCType)pThis.m_type).PrintCIsConstraintValid(pThis.m_type.PEREffectiveConstraint, c, errorCode + "_elem",
                typeName + "_arr", prefix + "arr[" + i + "]", lev + 1, arrayDepth + 1);
            c.P(lev); c.WriteLine("}");
        }
Exemple #3
0
        public static void PrintHTypeDeclaration(ArrayType pThis, PEREffectiveConstraint cns, StreamWriterLevel h, string typeName, string varName, int lev)
        {
            long min = pThis.minItems(cns);
            long max = pThis.maxItems(cns);

            h.WriteLine("struct {");
            //            h.WriteLine("struct {0} {{", typeName);
            //            if (min != max)
            {
                h.P(lev + 2);
                h.WriteLine("long nCount;");
            }
            h.P(lev + 2); ((ISCCType)pThis.m_type).PrintHTypeDeclaration(pThis.m_type.PEREffectiveConstraint, h, typeName + "_arr"/*+varName*/, "arr", lev + 1);
            h.WriteLine(" arr[{0}];", max);
            h.P(lev+1);
            h.Write("}");
        }