示例#1
0
        private StkId NewTableKey(ref TValue k)
        {
            if (k.TtIsNil())
            {
                L.G_RunError("table index is nil");
            }

            if (k.TtIsNumber() && System.Double.IsNaN(k.NValue))
            {
                L.G_RunError("table index is NaN");
            }

            var mp = GetHashNode(ref k);

            // if main position is taken
            if (!mp.Val.V.TtIsNil() || mp == DummyNode)
            {
                var n = GetFreePos();
                if (n == null)
                {
                    Rehash(ref k);
                    var cell = Get(ref k);
                    if (cell != TheNilValue)
                    {
                        return(cell);
                    }

                    return(NewTableKey(ref k));
                }

                Utl.Assert(n != DummyNode);
                var othern = GetHashNode(ref mp.Key.V);
                // is colliding node out of its main position?
                if (othern != mp)
                {
                    while (othern.Next != mp)
                    {
                        othern = othern.Next;
                    }

                    othern.Next = n;
                    n.CopyFrom(mp);
                    mp.Next = null;
                    mp.Val.V.SetNilValue();
                }
                // colliding node is in its own main position
                else
                {
                    n.Next  = mp.Next;
                    mp.Next = n;
                    mp      = n;
                }
            }

            mp.Key.V.SetObj(ref k);
            Utl.Assert(mp.Val.V.TtIsNil());
            return(mp.Val);
        }
示例#2
0
文件: VM.cs 项目: weimingtom/cslua
        private bool V_ToString(ref TValue v)
        {
            if (!v.TtIsNumber())
            {
                return(false);
            }

            v.SetSValue(v.NValue.ToString());
            return(true);
        }
示例#3
0
        private StkId NewTableKey(ref TValue k)
        {
            if(k.TtIsNil()) { L.G_RunError("table index is nil"); }

            if(k.TtIsNumber() && System.Double.IsNaN(k.NValue))
                { L.G_RunError("table index is NaN"); }

            var mp = GetHashNode(ref k);

            // if main position is taken
            if(!mp.Val.V.TtIsNil() || mp == DummyNode) {
                var n = GetFreePos();
                if(n == null) {
                    Rehash(ref k);
                    var cell = Get(ref k);
                    if(cell != TheNilValue) { return cell; }
                    return NewTableKey(ref k);
                }

                Utl.Assert(n != DummyNode);
                var othern = GetHashNode(ref mp.Key.V);
                // is colliding node out of its main position?
                if(othern != mp) {
                    while(othern.Next != mp) { othern = othern.Next; }
                    othern.Next = n;
                    n.CopyFrom(mp);
                    mp.Next = null;
                    mp.Val.V.SetNilValue();
                }
                // colliding node is in its own main position
                else {
                    n.Next = mp.Next;
                    mp.Next = n;
                    mp = n;
                }
            }

            mp.Key.V.SetObj(ref k);
            Utl.Assert(mp.Val.V.TtIsNil());
            return mp.Val;
        }
示例#4
0
 private bool IsPositiveInteger(ref TValue v)
 {
     return (v.TtIsNumber() && v.NValue > 0 && (v.NValue % 1) == 0 && v.NValue <= int.MaxValue); //fix large number key bug
 }
示例#5
0
 private bool IsPositiveInteger(ref TValue v)
 {
     return(v.TtIsNumber() && v.NValue > 0 && (v.NValue % 1) == 0);
 }
示例#6
0
 private bool IsPositiveInteger(ref TValue v)
 {
     return(v.TtIsNumber() && v.NValue > 0 && (v.NValue % 1) == 0 && v.NValue <= int.MaxValue);              //fix large number key bug
 }
示例#7
0
文件: VM.cs 项目: Jornason/UniLua
		private bool V_ToString(ref TValue v)
		{
			if(!v.TtIsNumber()) { return false; }

			v.SetSValue(v.NValue.ToString());
			return true;
		}
示例#8
0
 private bool IsPositiveInteger(ref TValue v)
 {
     return (v.TtIsNumber() && v.NValue > 0 && (v.NValue % 1) == 0);
 }