/// <summary> /// Protocol for determining value equality in Ruby (uses IsTrue protocol on result of == call) /// </summary> public static bool IsEqual(CallSite<Func<CallSite, object, object, object>>/*!*/ site, object lhs, object rhs) { // check reference equality first: if (lhs == rhs) { return true; } return IsTrue(site.Target(site, lhs, rhs)); }
internal static int IndexOf(CallSite<Func<CallSite, object, object, object>>/*!*/ equalitySite, IList/*!*/ self, object item) { for (int i = 0; i < self.Count; i++) { if (Protocols.IsTrue(equalitySite.Target(equalitySite, item, self[i]))) { return i; } } return -1; }
/// <summary> /// Converts an object to string using to_path-to_str protocol. /// Protocol: /// ? to_path => to_path() and to_str conversion on the result /// ? to_str => to_str() /// </summary> public static MutableString/*!*/ CastToPath(CallSite<Func<CallSite, object, MutableString>>/*!*/ toPath, object obj) { MutableString result = toPath.Target(toPath, obj); if (result == null) { throw RubyExceptions.CreateTypeConversionError("nil", "String"); } return result; }
public static bool RespondTo(CallSite<Func<CallSite, object, object, object>>/*!*/ respondToSite, RubyContext/*!*/ context, object target, string/*!*/ methodName) { return IsTrue(respondToSite.Target(respondToSite, target, context.EncodeIdentifier(methodName))); }
private void AssignSiteDelegates(CallSite<Func<CallSite, object, int>> hashSite, CallSite<Func<CallSite, object, object, bool>> equalSite) { _hashFunc = (o) => hashSite.Target(hashSite, o); _eqFunc = (o1, o2) => equalSite.Target(equalSite, o1, o2); }
public static bool ExistsUnsplat(CallSite<Func<CallSite, object, object, object>>/*!*/ comparisonSite, object splattee, object value) { var list = splattee as IList; if (list != null) { foreach (var item in list) { if (IsTrue(comparisonSite.Target(comparisonSite, item, value))) { return true; } } return false; } else { return IsTrue(comparisonSite.Target(comparisonSite, splattee, value)); } }
public void SetBacktrace(CallSite<Action<CallSite, RubyContext, Exception, RubyArray>> setBacktraceCallSite, RubyContext context, RubyArray backtrace) { _backtraceInitialized = true; if (context == null) { // TODO: If we do not have a RubyContext, we cannot dispatch to the overriden Exception#set_backtrace method. // We need to ensure that we have a non-null RubyContext. Backtrace = backtrace; } else { setBacktraceCallSite.Target(setBacktraceCallSite, context, _exception, backtrace); } }
public static object CallHelper10(CallSite<Func<CallSite, object, object, object, object, object, object, object, object, object, object, object>> site, object[] args) { return site.Target(site, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9]); }
public static object CallHelper5(CallSite<Func<CallSite, object, object, object, object, object, object>> site, object[] args) { return site.Target(site, args[0], args[1], args[2], args[3], args[4]); }
public static object CallHelper1(CallSite<Func<CallSite, object, object>> site, object[] args) { return site.Target(site, args[0]); }