/// <summary> /// The Run method executes the code and allows for an injected inspector /// to perform inspection operations and return a break code if desired. /// /// Inspectors inspect each line of code. While the inspector cannot alter /// the linePointer or accumulator values, it can alter the single command /// that it inspects, enabling some debugging. /// </summary> public long Run(IInspector inspector = null, bool WriteOut = true) { if (inspector != null) { Inspector = inspector; } while (linePointer <= Code.Length) { GBCommand Cmd = ParseLine(Code[linePointer - 1]); long inspection = inspector.Inspect(ref Cmd, linePointer, Accumulator); if (BreakValue(inspection, Cmd)) { return(Break(Cmd, WriteOut)); } long execution = Command[Cmd.Name].Run(Cmd.Value, ref linePointer, ref Accumulator); History.Add(Cmd); if (BreakValue(execution, Cmd)) { return(Break(Cmd, WriteOut)); } } return(Break(new GBCommand("COMPLETE", 0))); }
public static Task <InspectionInfo> InspectAsync(this IInspector inspector, ImageInfo imageInfo) { return(Task.Run(() => inspector.Inspect(imageInfo))); }