Пример #1
0
    static EmitInstanceBuffer AddBuffer(XBuffer xb,
                                        XType et, bool embed, int off, int len)
    {
        EmitInstanceBuffer eib;
        EmitInstance       ei;

        if (toEmit.TryGetValue(xb, out ei))
        {
            eib = ei as EmitInstanceBuffer;
            if (eib == null)
            {
                throw new Exception(string.Format("buffer not associated with an appropriate EmitInstanceBuffer"));
            }
        }
        else
        {
            eib        = new EmitInstanceBuffer(xb, et, embed);
            toEmit[xb] = eib;
        }
        eib.AddRange(off, len);

        /*
         * All values in the referenced range must be added.
         */
        if (embed)
        {
            for (int i = 0; i < len; i++)
            {
                int j = off + i;
                AddInstance(xb.Get(j).XObject, eib, j);
            }
        }
        else
        {
            for (int i = 0; i < len; i++)
            {
                int j = off + i;
                AddValueInner(xb.Get(j));
            }
        }
        return(eib);
    }
Пример #2
0
 internal XValue this[int index] {
     get {
         CheckIndex(index);
         XValue xv = dataBuf.Get(dataOff + index);
         if (xv.IsUninitialized)
         {
             throw new Exception("reading uninitialized array element");
         }
         return(xv);
     }
     set {
         CheckIndex(index);
         dataBuf.Set(dataOff + index, value);
     }
 }
Пример #3
0
        internal override void PrintValue(TextWriter tw)
        {
            string eCType = GetEltCType();
            int    n      = ranges.Count;

            for (int i = 0; i < n; i++)
            {
                IndexRange ir = ranges[i];
                tw.WriteLine();
                tw.Write(
                    "static const {0}t1b_{1}_{2}[] = {{",
                    eCType, buf.Serial, i);
                for (int j = ir.Start; j < ir.End; j++)
                {
                    if (j == ir.Start)
                    {
                        tw.WriteLine();
                    }
                    else
                    {
                        tw.WriteLine(",");
                    }
                    Compiler.Indent(tw, 1);
                    XValue xv = buf.Get(j);
                    if (embed)
                    {
                        XObject xo = xv.XObject;
                        PrintValueElementEmbed(tw, xo);
                    }
                    else
                    {
                        CCValues.PrintRef(tw, xv);
                    }
                }
                tw.WriteLine();
                tw.WriteLine("};");
            }
        }