コード例 #1
0
        internal static void Run(IInstructionHandler handler, List<Cell> cells,
			Action<ExecutionContext> before, Action<ExecutionContext, string> after,
			SecureRandom randomizer)
        {
            using (var reader = new StringReader(string.Empty))
            {
                InstructionHandlerTests.Run(handler, cells, before, after,
                    randomizer, reader);
            }
        }
コード例 #2
0
        internal static void Run(IInstructionHandler handler, List<Cell> cells,
			Action<ExecutionContext> before, Action<ExecutionContext, string> after,
			TextReader reader)
        {
            using (var random = new SecureRandom())
            {
                InstructionHandlerTests.Run(handler, cells, before, after,
                    random, reader);
            }
        }
コード例 #3
0
ファイル: Interpreter.cs プロジェクト: JasonBock/IronBefunge
        public Interpreter(FileInfo file, TextReader reader, TextWriter writer, SecureRandom randomizer)
            : base()
        {
            if (file == null)
            {
                throw new ArgumentNullException(nameof(file));
            }

            this.executor = new Executor(
                new Parser(File.ReadAllLines(file.FullName)).Parse(), reader, writer, randomizer);
        }
コード例 #4
0
        internal ExecutionContext(List<Cell> cells, TextReader reader, TextWriter writer, SecureRandom randomizer)
            : base()
        {
            this.Cells = cells;
            this.CurrentPosition = new Point();
            this.Direction = Direction.Right;
            this.InStringMode = false;
            this.Randomizer = randomizer;
            this.Values = new Stack<int>();
            this.Reader = reader;
            this.Writer = writer;

            this.Next();
        }
コード例 #5
0
        private static void Run(IInstructionHandler handler, List<Cell> cells,
			Action<ExecutionContext> before, Action<ExecutionContext, string> after,
			SecureRandom randomizer, TextReader reader)
        {
            using (var writer = new StringWriter(CultureInfo.CurrentCulture))
            {
                using (reader)
                {
                    var context = new ExecutionContext(cells, reader, writer, randomizer);

                    before?.Invoke(context);

                    handler.Handle(context);
                    var result = writer.GetStringBuilder().ToString();

                    after?.Invoke(context, result);
                }
            }
        }
コード例 #6
0
ファイル: Executor.cs プロジェクト: JasonBock/IronBefunge
        public Executor(ImmutableArray<Cell> cells, TextReader reader, TextWriter writer, SecureRandom randomizer)
        {
            if (reader == null)
            {
                throw new ArgumentNullException(nameof(reader));
            }

            if (writer == null)
            {
                throw new ArgumentNullException(nameof(writer));
            }

            if (randomizer == null)
            {
                throw new ArgumentNullException(nameof(randomizer));
            }

            this.cells = cells;
            this.reader = reader;
            this.writer = writer;
            this.randomizer = randomizer;
        }
コード例 #7
0
ファイル: Interpreter.cs プロジェクト: JasonBock/IronBefunge
 public Interpreter(string[] lines, TextReader reader, TextWriter writer, SecureRandom randomizer)
     : base()
 {
     this.executor = new Executor(
         new Parser(lines).Parse(), reader, writer, randomizer);
 }