예제 #1
0
파일: Value.cs 프로젝트: pdjonov/HenchLua
        public void Set(double value)
        {
            var asNum = Val as NumBox;

            if (asNum == null)
            {
                Val = asNum = new NumBox();
            }
            asNum.Value = value;
        }
예제 #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;
                }
            }
        }