Exemple #1
0
        protected override void Executed(Params args, IConsoleOutput target)
        {
            if (target is ScriptTargetWrapper i)
            {
                if (i.Session.Scope.Any(o => o.HasReturnPoint))
                {
                    while (true)
                    {
                        ScopeLoopPoint loopPoint = i.Session.Scope.Pop();

                        if (loopPoint.HasReturnPoint)
                        {
                            i.Session.Index = loopPoint.ReturnPoint - (Break ? 0 : 1);

                            //Makes sure to 'break' not 'continue'
                            if (Break)
                            {
                                i.Session.Scope.Push(new ScopeLoopPoint(ignoreLines: true, target: i));
                            }
                            break;
                        }
                    }
                }
                else
                {
                    ThrowGenericError("Cannot use break! Not in loop or function", ErrorCode.INVALID_CONTEXT);
                }
            }
            else
            {
                ThrowGenericError("This command is only valid in script files", ErrorCode.INVALID_CONTEXT);
            }
        }
        protected override void Executed(Params args, IConsoleOutput target)
        {
            if (target is ScriptTargetWrapper)
            {
                if ((target as ScriptTargetWrapper).Session.ScopeDepth.Any())
                {
                    ScopeLoopPoint item = (target as ScriptTargetWrapper).Session.ScopeDepth.Pop();

                    if (item.HasLoopPoint)
                    {
                        (target as ScriptTargetWrapper).Session.Index = item.LoopPoint - 1; //TODO double check
                    }
                    return;
                }

                ThrowGenericError("Stack underflow", ErrorCode.NUMBER_TOO_SMALL);
            }
        }