Inheritance: ExecutionEnvironment
示例#1
0
            public override IEnumerable <Position> Execute(UnreadableEnv env)
            {
                // Evaluate the condition
                foreach (var pos in _argCond.Execute(env))
                {
                    yield return(pos);
                }

                yield return(Position);

                var value = env.Pop();

                if (value == null)
                {
                    throw new Exception("If condition cannot be void.");
                }

                var codeToExecute = value.Value.IsZero ? _argNCode : _argYCode;

                // Execute the code
                foreach (var pos in codeToExecute.Execute(env))
                {
                    yield return(pos);
                }

                // Last result is now on the stack
                yield return(Position);
            }
示例#2
0
 public IEnumerable<Position> Execute(UnreadableEnv env)
 {
     foreach (var node in _nodes)
     {
         foreach (var pos in node.Execute(env))
             yield return pos;
     }
     yield return _posEnd;
 }
示例#3
0
 public IEnumerable <Position> Execute(UnreadableEnv env)
 {
     foreach (var node in _nodes)
     {
         foreach (var pos in node.Execute(env))
         {
             yield return(pos);
         }
     }
     yield return(_posEnd);
 }
示例#4
0
            public override IEnumerable <Position> Execute(UnreadableEnv env)
            {
                foreach (var arg in _args)
                {
                    foreach (var pos in arg.Execute(env))
                    {
                        yield return(pos);
                    }
                }
                yield return(Position);

                _executor(env);
            }
示例#5
0
            public override IEnumerable <Position> Execute(UnreadableEnv env)
            {
                env.Push(null);

again:

                // Evaluate the condition
                foreach (var pos in _argCond.Execute(env))
                {
                    yield return(pos);
                }

                yield return(Position);

                var value = env.Pop();

                if (value == null)
                {
                    throw new Exception("While condition cannot be void.");
                }

                if (!value.Value.IsZero)
                {
                    // Discard result from previous iteration
                    env.Pop();

                    // Execute the code
                    foreach (var pos in _argCode.Execute(env))
                    {
                        yield return(pos);
                    }

                    yield return(Position);

                    goto again;
                }

                // Last result is now on the stack
                yield return(Position);
            }
示例#6
0
 public abstract IEnumerable <Position> Execute(UnreadableEnv env);
示例#7
0
            public override IEnumerable<Position> Execute(UnreadableEnv env)
            {
                env.Push(null);

                again:

                // Evaluate the condition
                foreach (var pos in _argCond.Execute(env))
                    yield return pos;

                yield return Position;
                var value = env.Pop();
                if (value == null)
                    throw new Exception("While condition cannot be void.");

                if (!value.Value.IsZero)
                {
                    // Discard result from previous iteration
                    env.Pop();

                    // Execute the code
                    foreach (var pos in _argCode.Execute(env))
                        yield return pos;

                    yield return Position;
                    goto again;
                }

                // Last result is now on the stack
                yield return Position;
            }
示例#8
0
 public override IEnumerable<Position> Execute(UnreadableEnv env)
 {
     foreach (var arg in _args)
         foreach (var pos in arg.Execute(env))
             yield return pos;
     yield return Position;
     _executor(env);
 }
示例#9
0
 public abstract IEnumerable<Position> Execute(UnreadableEnv env);
示例#10
0
            public override IEnumerable<Position> Execute(UnreadableEnv env)
            {
                // Evaluate the condition
                foreach (var pos in _argCond.Execute(env))
                    yield return pos;

                yield return Position;
                var value = env.Pop();
                if (value == null)
                    throw new Exception("If condition cannot be void.");

                var codeToExecute = value.Value.IsZero ? _argNCode : _argYCode;

                // Execute the code
                foreach (var pos in codeToExecute.Execute(env))
                    yield return pos;

                // Last result is now on the stack
                yield return Position;
            }