private void EvaluateNormal(ScriptThread thread) { var mTable = target.Evaluate(thread) as MethodTable; bool createNew = mTable == null; var binding = thread.Runtime.BuiltIns.Bind(new BindingRequest(thread, this, target.Symbol, TypeInfo.NotDefined, BindingRequestFlags.Existing | BindingRequestFlags.Extern | BindingRequestFlags.Read)); if (binding == null) { thread.ThrowScriptError("Extern Symbol {0} not found.", target.Symbol); } var obj = binding.GetValueRef(thread) as MethodTable; if (obj == null) { thread.ThrowScriptError("Extern symbol {0} was not a method table!", target.Symbol); } 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; if (createNew) { mTable = new MethodTable(target.Symbol); mTable.Add(tar); target.DoCreate(thread, mTable, TypeInfo.Function); } else { if (mTable.GetIndex(parameters.ParamTypes) != null) { thread.ThrowScriptError("Function {0}({1}) is already defined!", target.Symbol, string.Join(", ", parameters.ParamNames)); } mTable.Add(tar); target.DoSetValue(thread, mTable, TypeInfo.Function); } }
private object EvaluateNormal(ScriptThread thread) { MethodTable mTable = NameNode.Evaluate(thread) as MethodTable; bool createNew = mTable == null; if (mTable == null) { mTable = new MethodTable((NameNode as IdentifierNode).Symbol); } var closure = Lambda.EvaluateNamed(thread, mTable); if (createNew) { NameNode.DoCreate(thread, mTable, TypeInfo.Function); } else { NameNode.DoSetValue(thread, mTable, TypeInfo.Function); } return(closure); }