private bool TryOptimizedCall(object[] args, out object ret) { // create the target if it doesn't already exist. We cache the // target incase the user stores the reflected method somewhere // and continues to call the unoptimized version. if (optimizedTarget == null) { OptimizeMethod(); } if (optimizedTarget != null) { BuiltinFunction optimized = optimizedTarget; if (HasInstance) { optimized = optimized.Clone(); optimized.inst = inst; } ret = optimized.Call(args); return(true); } ret = null; return(false); }
public object GetAttribute(object instance, object owner) { if (instance != null) { CheckSelf(instance); BuiltinFunction res = template.Clone() as BuiltinFunction; res.inst = instance; return(res); } return(this); }
public bool TryGetAttr(ICallerContext context, SymbolId name, out object value) { if (name == SymbolTable.GeneratorNext) { // next is the most common call on generators, we optimize that call here. We get // two benefits out of this: // 1. Avoid the dictionary lookup for next // 2. Avoid the self-check in the method descriptor (because we know we're binding to a generator) BuiltinFunction res = nextFunction.Clone(); res.inst = this; value = res; return(true); } return(generatorType.TryGetAttr(context, this, name, out value)); }