public sealed override T BindDelegate <T>(CallSite <T> site, object[] args)
        {
            object        firstArg     = args[0];
            ArgumentArray argArray     = firstArg as ArgumentArray;
            Type          delegateType = typeof(T);
            T             result;

            if (argArray != null)
            {
                firstArg = argArray.GetArgument(0);
            }
            else
            {
                object precompiled = BindPrecompiled(delegateType, args);
                if (precompiled != null)
                {
                    result = (T)precompiled;
                    CacheTarget(result);
                    return(result);
                }
            }

            RubyContext context = _context ?? ((Signature.HasScope) ? ((RubyScope)firstArg).RubyContext : (RubyContext)firstArg);

            if (context.Options.NoAdaptiveCompilation)
            {
                return(null);
            }

#if DEBUG
            if (RubyOptions.ShowRules)
            {
                var sb = new StringBuilder();
                for (int i = 1; i < args.Length; i++)
                {
                    sb.Append(RubyUtils.ObjectToMutableString(context, args[i]));
                    sb.Append(", ");
                }

                Utils.Log(String.Format(
                              "{0}: {1}; {2} <: {3}",
                              this,
                              sb,
                              args.Length > 1 ? context.GetImmediateClassOf(args[1]).DebugName : null,
                              args.Length > 1 ? context.GetImmediateClassOf(args[1]).SuperClass.DebugName : null
                              ), "BIND");
            }
#endif
            result = this.LightBind <T>(args, context.Options.CompilationThreshold);
            CacheTarget(result);
            return(result);
        }
Example #2
0
        public override string /*!*/ ToString()
        {
#if DEBUG && !SILVERLIGHT && CLR2
            if (RubyBinder._DumpingExpression)
            {
                return(RubyUtils.ObjectBaseToMutableString(this).ToString());
            }
#endif
            var    site           = _immediateClass.ToStringSite;
            object toStringResult = site.Target(site, this);
            if (ReferenceEquals(toStringResult, RubyOps.ForwardToBase))
            {
                return(((IRubyObject)this).BaseToString());
            }

            string str = toStringResult as string;
            if (str != null)
            {
                return(str);
            }

            var mstr = toStringResult as MutableString ?? RubyUtils.ObjectToMutableString(_immediateClass.Context, toStringResult);
            return(mstr.ToString());
        }
Example #3
0
 public override string /*!*/ ToString()
 {
     return(RubyUtils.ObjectToMutableString(_context, this).ToString());
 }
Example #4
0
 public static MutableString /*!*/ Inspect(RubyContext /*!*/ context, MatchData /*!*/ self)
 {
     return(RubyUtils.ObjectToMutableString(context, self));
 }