Exemple #1
0
        public void Set(double value)
        {
            var asNum = Val as NumBox;

            if (asNum == null)
            {
                Val = asNum = new NumBox();
            }
            asNum.Value = value;
        }
Exemple #2
0
        internal void WriteValue(int loc, ref Value val)
        {
            Debug.Assert(loc != 0);

            var rVal = val.RefVal;

            if (rVal == Value.NumTypeTag)
            {
                //reuse an existing box if we can

                var box = (loc > 0 ? array[loc - 1].Val : nodes[-loc - 1].Value.Val) as NumBox;
                if (box == null)
                {
                    box = new NumBox();
                }
                box.Value = val.NumVal;

                rVal = box;
            }

            if (loc > 0)
            {
                array[loc - 1].Val = rVal;
            }
            else
            {
                loc = -loc - 1;

                nodes[loc].Value.Val = rVal;

                if (rVal == null)
                {
                    //don't have a GC to sweep up later,
                    //so we need to clear the key out now,
                    //but we can't break any chains!
                    nodes[loc].Key.Val = DeadKey;
                }
            }
        }