Exemplo n.º 1
0
        public ScopeLoopPoint(IEnumerator <string> enumerator, int loopPoint, ScriptTargetWrapper target)
        {
            IgnoreLines    = false;
            HasReturnPoint = true;
            ReturnPoint    = loopPoint;
            Enumerator     = enumerator;

            if (target.Session.Scope.Any())
            {
                Locals = new VariableCollection(target.Session.Scope.Peek().Locals);
            }
            else
            {
                Locals = VariableCollection.GlobalVariables;
            }
        }
Exemplo n.º 2
0
        public ScopeLoopPoint(bool ignoreLines, ScriptTargetWrapper target)
        {
            IgnoreLines    = ignoreLines;
            HasReturnPoint = false;
            ReturnPoint    = -1;
            Enumerator     = null;

            if (target.Session.Scope.Any())
            {
                Locals = new VariableCollection(target.Session.Scope.Peek().Locals);
            }
            else
            {
                Locals = VariableCollection.GlobalVariables;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Executes the next line of the script
        /// </summary>
        /// <param name="output">Output device to write to</param>
        /// <param name="errorCode">Variable to store error code of the command executed</param>
        /// <returns></returns>
        private bool Step(IConsoleOutput output, out int errorCode)
        {
            if (!(output is ScriptTargetWrapper))
            {
                output = new ScriptTargetWrapper(output, this);
            }

            Index++;
            if (Index >= Lines.Count)
            {
                errorCode = -1;
                return(false);
            }


            //If we are skipping lines and the current line is not a block ender
            if (Scope.Any(i => i.IgnoreLines) && Lines[Index].Trim() != "}")
            {
                Command cmd = Command.GetByName(Lines[Index].Split(' ').First());

                //If the current line is a block command (and not a block ender (see above)), push a new object to the stack
                if (cmd != null && cmd.IsCodeBlockCommand())
                {
                    this.Scope.Push(new ScopeLoopPoint(true, output as ScriptTargetWrapper));
                }

                errorCode = 0;
                return(true);
            }

            errorCode = Command.ParseLine(Lines[Index], output);

            if (ShouldBreakDebugger)
            {
                Debugger.Break();
            }
            return(true);
        }