Exemplo n.º 1
0
 private void TruncateStack(Pointer x, bool fromTop)
 {
     if (!fromTop)
     {
         x.ReverseStack();
     }
     while (x.GetStackSize() > x.GetMana() + 10)
     {
         x.Pop();
     }
     if (!fromTop)
     {
         x.ReverseStack();
     }
 }
Exemplo n.º 2
0
        public Func <bool> Eval(Pointer pointer, string code, out int size)
        {
            RunicEnvironment context;
            ParseError       err = Parser.Parse(code, "", out context);

            if (modifiers[pointer.position.x, pointer.position.y] == '͍')
            {
                context.SetReader(() =>
                {
                    if (pointer.GetStackSize() > 0)
                    {
                        return(pointer.Pop());
                    }
                    return(null);
                });
                context.SetWriter((o) =>
                {
                    pointer.Push(o);
                });
            }
            else
            {
                context.SetWriter((o) =>
                {
                    outputWriter(o);
                });
            }
            if (err.type != ParseErrorType.NONE || context == null)
            {
                size = 0;
                return(() => true);
            }
            context.Initialize();
            size = context.runes.GetLength(0) + context.runes.GetLength(1);
            return(() =>
            {
                bool continueExecuting = false;
                continueExecuting = context.Tick();
                return !continueExecuting;
            });
        }