示例#1
0
文件: bf.cs 项目: wyrover/benchmarks
        private void _run(List <Op> program, Tape tape)
        {
            foreach (Op op in program)
            {
                switch (op.op)
                {
                case OpT.INC: tape.Inc(op.v); break;

                case OpT.MOVE: tape.Move(op.v); break;

                case OpT.LOOP: while (tape.Get() > 0)
                    {
                        _run(op.loop, tape);
                    }
                    break;

                case OpT.PRINT: Console.Write((char)tape.Get()); break;
                }
            }
        }
示例#2
0
        private void _run(Op[] program, Tape tape)
        {
            foreach (Op op in program)
            {
                switch (op.op)
                {
                case OpT.INC: tape.Inc(op.v); break;

                case OpT.MOVE: tape.Move(op.v); break;

                case OpT.LOOP: while (tape.Get() > 0)
                    {
                        _run(op.loop, tape);
                    }
                    break;

                case OpT.PRINT: p.Print(tape.Get()); break;
                }
            }
        }
示例#3
0
        private void _run(Op[] program, Tape tape)
        {
            foreach (Op op in program)
            {
                switch (op.op)
                {
                case OpT.INC: tape.Inc(op.v); break;

                case OpT.MOVE: tape.Move(op.v); break;

                case OpT.LOOP: while (tape.Get() > 0)
                    {
                        _run(op.loop, tape);
                    }
                    break;

                case OpT.INPUT: tape.Set((int)Console.ReadKey().KeyChar); break;

                case OpT.PRINT: Console.Write((char)tape.Get()); break;
                }
            }
        }
示例#4
0
文件: bf.cs 项目: 9il/benchmarks
 private void _run(List<Op> program, Tape tape)
 {
     foreach (Op op in program) {
         switch (op.op) {
             case OpT.INC: tape.Inc(op.v); break;
             case OpT.MOVE: tape.Move(op.v); break;
             case OpT.LOOP: while (tape.Get() != 0) _run(op.loop, tape); break;
             case OpT.PRINT: Console.Write((char)tape.Get()); break;
         }
     }
 }