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); }
private bool V_ToString(ref TValue v) { if (!v.TtIsNumber()) { return(false); } v.SetSValue(v.NValue.ToString()); return(true); }
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; }
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 }
private bool IsPositiveInteger(ref TValue v) { return(v.TtIsNumber() && v.NValue > 0 && (v.NValue % 1) == 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 }
private bool V_ToString(ref TValue v) { if(!v.TtIsNumber()) { return false; } v.SetSValue(v.NValue.ToString()); return true; }
private bool IsPositiveInteger(ref TValue v) { return (v.TtIsNumber() && v.NValue > 0 && (v.NValue % 1) == 0); }