protected override FieldInfo GetConversionSiteField(Type toType) { return(AllocateDynamicSite( new Type[] { typeof(CallSite), typeof(RubyContext), typeof(object), toType }, (site) => Expression.Assign( Expression.Field(null, site), Expression.Call( null, site.FieldType.GetMethod("Create"), ProtocolConversionAction.GetConversionAction(null, toType, true).CreateExpression() ) ) )); }
public static CallSite <Func <CallSite, RubyContext, object, T> > /*!*/ GetConversionSite <T>() { if (_conversionSites == null) { Interlocked.CompareExchange(ref _conversionSites, new Dictionary <Type, CallSite>(), null); } Type toType = typeof(T); lock (_conversionSites) { CallSite site; if (_conversionSites.TryGetValue(toType, out site)) { return((CallSite <Func <CallSite, RubyContext, object, T> >)site); } var newSite = CallSite <Func <CallSite, RubyContext, object, T> > .Create(ProtocolConversionAction.GetConversionAction(null, toType, true)); _conversionSites[toType] = newSite; return(newSite); } }
internal CallSite <Func <CallSite, object, TResult> > /*!*/ GetDefaultConversionSite() { return(RubyUtils.GetCallSite(ref Site, ProtocolConversionAction.GetConversionAction(Context, typeof(TResult), true))); }