Пример #1
0
        private bool V_EqualObject(ref TValue t1, ref TValue t2, bool rawEq)
        {
            Utl.Assert(t1.Tt == t2.Tt);
            StkId tm = null;

            switch (t1.Tt)
            {
            case (int)LuaType.LUA_TNIL:
                return(true);

            case (int)LuaType.LUA_TNUMBER:
                return(t1.NValue == t2.NValue);

            case (int)LuaType.LUA_TUINT64:
                return(t1.UInt64Value == t2.UInt64Value);

            case (int)LuaType.LUA_TBOOLEAN:
                return(t1.BValue() == t2.BValue());

            case (int)LuaType.LUA_TSTRING:
                return(t1.SValue() == t2.SValue());

            case (int)LuaType.LUA_TUSERDATA:
            {
                var ud1 = t1.RawUValue();
                var ud2 = t2.RawUValue();
                if (ud1.Value == ud2.Value)
                {
                    return(true);
                }
                if (rawEq)
                {
                    return(false);
                }
                tm = GetEqualTM(ud1.MetaTable, ud2.MetaTable, TMS.TM_EQ);
                break;
            }

            case (int)LuaType.LUA_TTABLE:
            {
                var tbl1 = t1.HValue();
                var tbl2 = t2.HValue();
                if (System.Object.ReferenceEquals(tbl1, tbl2))
                {
                    return(true);
                }
                if (rawEq)
                {
                    return(false);
                }
                tm = GetEqualTM(tbl1.MetaTable, tbl2.MetaTable, TMS.TM_EQ);
                break;
            }

            default:
                return(t1.OValue == t2.OValue);
            }
            if (tm == null)              // no TM?
            {
                return(false);
            }
            CallTM(ref tm.V, ref t1, ref t2, Top, true);              // call TM
            return(!IsFalse(ref Top.V));
        }
Пример #2
0
		private bool V_EqualObject( ref TValue t1, ref TValue t2, bool rawEq )
		{
			Utl.Assert( t1.Tt == t2.Tt );
			StkId tm = null;
			switch( t1.Tt )
			{
				case (int)LuaType.LUA_TNIL:
					return true;
				case (int)LuaType.LUA_TNUMBER:
					return t1.NValue == t2.NValue;
				case (int)LuaType.LUA_TUINT64:
					return t1.UInt64Value == t2.UInt64Value;
				case (int)LuaType.LUA_TBOOLEAN:
					return t1.BValue() == t2.BValue();
				case (int)LuaType.LUA_TSTRING:
					return t1.SValue() == t2.SValue();
				case (int)LuaType.LUA_TUSERDATA:
				{
					var ud1 = t1.RawUValue();
					var ud2 = t2.RawUValue();
					if(ud1.Value == ud2.Value)
						return true;
					if(rawEq)
						return false;
					tm = GetEqualTM( ud1.MetaTable, ud2.MetaTable, TMS.TM_EQ );
					break;
				}
				case (int)LuaType.LUA_TTABLE:
				{
					var tbl1 = t1.HValue();
					var tbl2 = t2.HValue();
					if( System.Object.ReferenceEquals( tbl1, tbl2 ) )
						return true;
					if( rawEq )
						return false;
					tm = GetEqualTM( tbl1.MetaTable, tbl2.MetaTable, TMS.TM_EQ );
					break;
				}
				default:
					return t1.OValue == t2.OValue;
			}
			if( tm == null ) // no TM?
				return false;
			CallTM(ref tm.V, ref t1, ref t2, Top, true ); // call TM
			return !IsFalse(ref Top.V);
		}