コード例 #1
0
        private static void HandleGet(ExecutionContext context)
        {
            context.EnsureStack(2);
            var y = context.Values.Pop();
            var x = context.Values.Pop();
            var target = context.Find(new Point(x, y));

            if (target != null)
            {
                context.Values.Push(target.Value);
            }
            else
            {
                context.Values.Push(' ');
            }
        }
コード例 #2
0
        private static void HandlePut(ExecutionContext context)
        {
            context.EnsureStack(3);
            var y = context.Values.Pop();
            var x = context.Values.Pop();
            var value = Convert.ToChar(context.Values.Pop());

            var location = new Point(x, y);
            var target = context.Find(location);

            if (target != null)
            {
                context.Cells[context.Cells.IndexOf(target)] = new Cell(location, value);
            }
            else if (value != ' ')
            {
                context.Cells.Add(new Cell(location, value));
            }
        }