public virtual object Execute(NamedArgumentList arguments) { ToolScriptFunctionArgs args = new ToolScriptFunctionArgs(arguments); if(Invoked != null) Invoked(this, args); return args.ReturnValue; }
public object Execute(NamedArgumentList arguments) { //List<MethodInfo> try_again = new List<MethodInfo>(Methods.Length); foreach(MethodInfo method in Methods) { ParameterInfo[] aparams = method.GetParameters(); if(aparams.Length != arguments.Count) continue; object[] vals = new object[aparams.Length]; for(int i = 0; i < aparams.Length; i++) { object val = arguments.GetValue(aparams[i].Name, i); vals[i] = val; Type m_type = aparams[i].ParameterType; if(val != null) { Type p_type = val.GetType(); if(!(m_type == p_type || p_type.IsSubclassOf(m_type))) goto NextMethod; } else { if(m_type.IsValueType) goto NextMethod; } } using(Log.Scope("Trying invoke {0}", method)) { try { return method.Invoke(Instance, vals); } catch(TargetInvocationException err) { // unwrap exception if(err.InnerException != null) throw err.InnerException; else throw err; } } NextMethod: ; } StringBuilder sb = new StringBuilder("Patřičná metoda nebyla nalezena. Varianty "); sb.AppendLine(Methods.Length.ToString()); foreach(MethodInfo method in Methods) sb.AppendLine(method.ToString()); throw new InvalidOperationException(sb.ToString()); }
public object Execute(NamedArgumentList arguments) { try { Parameters.InitVariables(this.Context, arguments); Body.Run(this.Context); return SpecialValue.Void; } catch(IterationTermination info) { if(info.Reason == TerminationReason.Return) return info.ReturnValue; else throw new InvalidOperationException("volání funkce bylo přerušeno jiným důvodem než return: " + info.Reason.ToString()); } }
public NewExpression(QualifiedName TypeName, NamedArgumentList Arguments) { this.TypeName = TypeName; this.Arguments = Arguments; }
public ToolScriptFunctionArgs(NamedArgumentList Args) { this.Args = Args; this.ReturnValue = SpecialValue.Void; }
public FunctionExpression(string name, NamedArgumentList parameters, IStatement body) { this.Name = name; this.Parameters = parameters; this.Body = body; }
public FunctionCall(IExpression Function, NamedArgumentList Args) { this.Function = Function; this.Args = Args; // can be null }