public static StackObject *TypeEquals(ILIntepreter intp, StackObject *esp, IList <object> mStack, CLRMethod method, bool isNewObj) { var ret = ILIntepreter.Minus(esp, 2); var p = esp - 1; AppDomain dommain = intp.AppDomain; var other = StackObject.ToObject(p, dommain, mStack); intp.Free(p); p = ILIntepreter.Minus(esp, 2); var instance = StackObject.ToObject(p, dommain, mStack); intp.Free(p); if (instance is ILRuntimeType) { if (other is ILRuntimeType) { if (((ILRuntimeType)instance).ILType == ((ILRuntimeType)other).ILType) { return(ILIntepreter.PushOne(ret)); } else { return(ILIntepreter.PushZero(ret)); } } else { return(ILIntepreter.PushZero(ret)); } } else { if (((Type)typeof(Type).CheckCLRTypes(instance)).Equals(((Type)typeof(Type).CheckCLRTypes(other)))) { return(ILIntepreter.PushOne(ret)); } else { return(ILIntepreter.PushZero(ret)); } } }
/*public unsafe static object DelegateRemove(ILContext ctx, object instance, object[] param, IType[] genericArguments) * { * var esp = ctx.ESP; * var mStack = ctx.ManagedStack; * var domain = ctx.AppDomain; * * var dele1 = StackObject.ToObject((esp - 1 - 1), domain, mStack); * var dele2 = StackObject.ToObject((esp - 1), domain, mStack); * * if (dele1 != null) * { * if (dele2 != null) * { * if (dele1 is IDelegateAdapter) * { * if (dele2 is IDelegateAdapter) * { * if (dele1 == dele2) * return ((IDelegateAdapter)dele1).Next; * else * ((IDelegateAdapter)dele1).Remove((IDelegateAdapter)dele2); * } * else * ((IDelegateAdapter)dele1).Remove((Delegate)dele2); * return dele1; * } * else * { * if (dele2 is IDelegateAdapter) * return Delegate.Remove((Delegate)dele1, ((IDelegateAdapter)dele2).GetConvertor(dele1.GetType())); * else * return Delegate.Remove((Delegate)dele1, (Delegate)dele2); * } * } * else * return dele1; * } * else * return null; * }*/ public unsafe static StackObject *DelegateEqulity(ILIntepreter intp, StackObject *esp, IList <object> mStack, CLRMethod method, bool isNewObj) { //Don't ask me why not esp -2, unity won't return the right result var ret = esp - 1 - 1; AppDomain domain = intp.AppDomain; var param = esp - 1; object dele2 = StackObject.ToObject(param, domain, mStack); intp.Free(param); param = esp - 1 - 1; object dele1 = StackObject.ToObject(param, domain, mStack); intp.Free(param); bool res = false; if (dele1 != null) { if (dele2 != null) { if (dele1 is IDelegateAdapter) { if (dele2 is IDelegateAdapter) { res = ((IDelegateAdapter)dele1).Equals((IDelegateAdapter)dele2); } else { res = ((IDelegateAdapter)dele1).Equals((Delegate)dele2); } } else { if (dele2 is IDelegateAdapter) { res = (Delegate)dele1 == ((IDelegateAdapter)dele2).GetConvertor(dele1.GetType()); } else { res = (Delegate)dele1 == (Delegate)dele2; } } } else { res = dele1 == null; } } else { res = dele2 == null; } if (res) { return(ILIntepreter.PushOne(ret)); } else { return(ILIntepreter.PushZero(ret)); } }