/// <summary> /// Add a new method for achieving this task /// </summary> /// <param name="weight">The relative probability of this method being tried before the other methods</param> /// <param name="argumentPattern">Terms (variables or values) to unify with the arguments in a call to test whether this method is appropriate</param> /// <param name="localVariableNames">LocalVariables used in this method</param> /// <param name="stepChain">Linked list of Step objects to attempt to execute when running this method</param> /// <param name="path">File from which the method was read</param> /// <param name="lineNumber">Line number where the method starts in the file</param> /// <param name="newFlags">Additional flags to set for the task</param> internal void AddMethod(float weight, object[] argumentPattern, LocalVariableName[] localVariableNames, Step stepChain, TaskFlags newFlags, string path, int lineNumber) { Flags |= newFlags; if (!ContainsCoolStep && stepChain != null && stepChain.AnyStep(s => s is CoolStep)) { Flags |= TaskFlags.ContainsCoolStep; } Methods.Add(new Method(this, weight, argumentPattern, localVariableNames, stepChain, path, lineNumber)); }
/// <summary> /// True if some step in this step chain satisfies the predicate. /// </summary> public virtual bool AnyStep(Predicate <Step> p) => p(this) || Next != null && Next.AnyStep(p);