private void EvaluateExtension(ScriptThread thread) { var ident = target.Symbol; IBindingSource cons; MethodTable mTable = null; if (thread.Runtime.ExtensionFunctions.TryGetValue(ident, out cons)) { mTable = ((cons as BuiltInCallableTargetInfo).BindingInstance as ConstantBinding).Target as MethodTable; } else { mTable = new MethodTable(ident); var targetInfo = new BuiltInCallableTargetInfo(mTable); thread.Runtime.ExtensionFunctions.Add(ident, targetInfo); } var binding = thread.Runtime.BuiltIns.Bind(new BindingRequest(thread, this, ident, TypeInfo.Function, BindingRequestFlags.Existing | BindingRequestFlags.Extern | BindingRequestFlags.Read)); if (binding == null) { thread.ThrowScriptError("Extern Symbol {0} not found.", ident); } var obj = binding.GetValueRef(thread) as MethodTable; if (obj == null) { thread.ThrowScriptError("Extern symbol {0} was not a method table!", ident); } var tar = obj.GetIndex(parameters.ParamTypes) as BuiltInCallTarget; if (tar == null) { thread.ThrowScriptError("Extern symbol {0} with {1} parameters was not found.", target.Symbol, parameters.ChildNodes.Count); } tar.ParamCount = parameters.ChildNodes.Count; tar.ParamNames = parameters.ParamNames; tar.HasParamsArg = parameters.HasParamsArg; tar.ParamTypes = parameters.ParamTypes; mTable.Add(tar); }
private object EvaluateExtension(ScriptThread thread) { var ident = NameNode.Symbol; IBindingSource cons; MethodTable mTable = null; if (thread.Runtime.ExtensionFunctions.TryGetValue(ident, out cons)) { mTable = ((cons as BuiltInCallableTargetInfo).BindingInstance as ConstantBinding).Target as MethodTable; } else { mTable = new MethodTable(ident); BuiltInCallableTargetInfo targetInfo = new BuiltInCallableTargetInfo(mTable); thread.Runtime.ExtensionFunctions.Add(ident, targetInfo); } var closure = Lambda.EvaluateNamed(thread, mTable); return(closure); }