Exemple #1
0
        /// <summary>
        /// Do of While boven op de stack?
        /// Eraf halen
        /// Dit is weer reachable
        /// </summary>
        /// <param name="l"></param>
        public void Visit(LoopStatement l)
        {
            Reachable();
            if (CheckInclude(l))
            {
                return;
            }

            if (CheckGeneric(l))
            {
                return;
            }

            // Expressie gevonden?
            if (l.Param != String.Empty)
            {
                _errors.Add(new UnexpectedInputException(l.SourceCodeContext, l.Param));
            }

            if (_tomatch.Count > 0 &&
                (_tomatch[_tomatch.Count - 1] is DoStatement ||
                 _tomatch[_tomatch.Count - 1] is WhileStatement))
            {
                _tomatch.RemoveAt(_tomatch.Count - 1);
            }
            else
            {
                _errors.Add(new LoopNotMatchedException(l.SourceCodeContext));
            }
        }
 public virtual T Visit(LoopStatement node)
 {
     Visit((Statement)node);
     traverse(node.condition);
     traverse(node.block);
     return(DefaultReturnValue());
 }
        public void LoopStatementWithRequiresStatement()
        {
            LoopStatement statement = null;

            Expect.Throw <ArgumentNullException>(() => statement.Do(new Statement[0]));
            Expect.Throw <ArgumentNullException>(() => statement.Do(new List <Statement>()));
        }
 //-----------------------------------------------------------
 private Type Visit(LoopStatement node, Table table)
 {
     LoopNestingLevel++;
     VisitChildren(node, table);
     LoopNestingLevel--;
     return(Type.VOID);
 }
Exemple #5
0
 public void VisitLoop(LoopStatement node)
 {
     node.Initialization?.Accept(this);
     node.Condition.Accept(this);
     node.Increments?.ForEach(e => e.Accept(this));
     node.Body.Accept(this);
 }
Exemple #6
0
 public override bool Visit(LoopStatement node)
 {
     Visit((Statement)node);
     TraversePrint(node.condition);
     TraversePrint(node.block);
     return(true);
 }
Exemple #7
0
        private ForStatement ForStatement(ParseNode node)
        {
            var forStatement = new ForStatement();

            _enclosure = forStatement;

            _scopes.Push(new VarScope());

            var children = node.Children;

            children.Skip(TokenTag.FOR);
            children.Skip(TokenTag.OPEN_PAREN);
            var declarations = children.Check(ParseNodeTag.VarDeclaration)
                ? children.GetAndMove(VarDeclarations)
                : new List <VarDeclaration>();

            children.Skip(TokenTag.SEMICOLON);
            var condition = children.Check(child => !child.IsTerminal)
                ? children.GetAndMove(Expression)
                : new EmptyExpression();

            children.Skip(TokenTag.SEMICOLON);
            var postIteration = children.Check(child => !child.IsTerminal)
                ? children.GetAndMove(StatementExpression)
                : new EmptyExpression();

            children.Skip(TokenTag.CLOSE_PAREN);
            var body = children.GetAndMove(Statement);

            _scopes.Pop();

            forStatement.Init(declarations, condition, postIteration, body);
            return(forStatement);
        }
Exemple #8
0
        public void TestLoopStatement()
        {
            ExecutionEnvironment e = new ExecutionEnvironment();

            e.RegisterValue("a", true);
            e.RegisterValue("b", true);
            e.RegisterValue("c", 5);
            e.RegisterValue("d", 6);
            LoopStatement s = new LoopStatement();

            s.Loop = new BinaryExpression()
            {
                Left = new Identifier()
                {
                    Variable = "a"
                }, Right = new Identifier()
                {
                    Variable = "b"
                }, Operator = Operator.And
            };
            s.Body = new BlockStatement();
            s.Body.Body.Add(new ExpressionStatement()
            {
                Expression = new AssignmentExpression()
                {
                    Left = new Identifier()
                    {
                        Variable = "c"
                    }, Right = new BinaryExpression()
                    {
                        Left = new Identifier()
                        {
                            Variable = "c"
                        }, Operator = Operator.Add, Right = new Literal()
                        {
                            Raw = "2"
                        }
                    }
                }
            });
            s.Body.Body.Add(new ExpressionStatement()
            {
                Expression = new AssignmentExpression()
                {
                    Left = new Identifier()
                    {
                        Variable = "a"
                    }, Right = new Literal()
                    {
                        Raw = "false"
                    }
                }
            });
            var c = s.Execute(e);

            Assert.AreEqual(c.Type, CompletionType.Value);
        }
Exemple #9
0
        private void loopStmt()
        {
            EnterRule_loopStmt();
            EnterRule("loopStmt", 3);
            TraceIn("loopStmt", 3);
            try { DebugEnterRule(GrammarFileName, "loopStmt");
                  DebugLocation(45, 1);
                  try
                  {
                      // Analyze.g:46:2: ( ( WHILE_STMT | FOR_STMT | DO_WHILE_STMT ) )
                      DebugEnterAlt(1);
                      // Analyze.g:46:4: ( WHILE_STMT | FOR_STMT | DO_WHILE_STMT )
                      {
                          DebugLocation(46, 4);
                          if (input.LA(1) == DO_WHILE_STMT || input.LA(1) == FOR_STMT || input.LA(1) == WHILE_STMT)
                          {
                              input.Consume();
                              state.errorRecovery = false; state.failed = false;
                          }
                          else
                          {
                              if (state.backtracking > 0)
                              {
                                  state.failed = true; return;
                              }
                              MismatchedSetException mse = new MismatchedSetException(null, input);
                              DebugRecognitionException(mse);
                              throw mse;
                          }

                          DebugLocation(47, 3);
                          if (state.backtracking == 1)
                          {
                              if (currentBranch != null)
                              {
                                  LoopStatement loop = new LoopStatement(currentBranch);
                                  currentBranch.SetNextStatement(loop);
                                  currentBranch = loop;
                              }
                          }
                      }
                  }
                  catch (RecognitionException re)
                  {
                      ReportError(re);
                      Recover(input, re);
                  }
                  finally
                  {
                      TraceOut("loopStmt", 3);
                      LeaveRule("loopStmt", 3);
                      LeaveRule_loopStmt();
                  }
                  DebugLocation(55, 1); } finally { DebugExitRule(GrammarFileName, "loopStmt"); }
            return;
        }
        public void LoopStatementHasWithHelpers()
        {
            LoopStatement statement1 = JS.For().Do(JS.Return());
            LoopStatement statement2 = JS.For().Do(new List <Statement> {
                JS.Return()
            });

            Assert.AreEqual(JS.Return(), statement1.Statement);
            Assert.AreEqual(JS.Return(), statement2.Statement);
        }
        public override SqlStatement VisitLoopStatement(PlSqlParser.LoopStatementContext context)
        {
            LoopStatement loop;

            if (context.WHILE() != null)
            {
                var condition = Expression.Build(context.condition());
                loop = new WhileLoopStatement(condition);
            }
            else if (context.FOR() != null)
            {
                var param = context.cursorLoopParam();
                if (param.lowerBound() != null &&
                    param.upperBound() != null)
                {
                    var lower     = Expression.Build(param.lowerBound());
                    var upper     = Expression.Build(param.upperBound());
                    var indexName = Name.Simple(param.id());

                    var reverse = param.REVERSE() != null;
                    loop = new ForLoopStatement(indexName, lower, upper)
                    {
                        Reverse = reverse
                    };
                }
                else
                {
                    throw new NotImplementedException();
                }
            }
            else
            {
                loop = new LoopStatement();
            }

            if (context.labelDeclaration() != null)
            {
                var labelName = Name.Simple(context.labelDeclaration().id());
                loop.Label = labelName;
            }

            var seqOfStatements = context.seqOfStatements();

            if (seqOfStatements != null)
            {
                var statements = seqOfStatements.statement().Select(Visit);
                foreach (var statement in statements)
                {
                    loop.Statements.Add(statement);
                }
            }

            return(loop);
        }
Exemple #12
0
        public object VisitLoopStatement(LoopStatement statement)
        {
            scope.EnterLoop();
            Resolve(statement.Initializer);
            Resolve(statement.Condition);
            Resolve(statement.Increment);
            Resolve(statement.Body);
            scope.ExitLoop();

            return(null);
        }
        public void LoopAndExitWithNoReturn()
        {
            var loop = new LoopStatement();

            loop.Statements.Add(new ReturnStatement(SqlExpression.Constant(45)));

            var result = AdminQuery.ExecuteStatement(loop);

            Assert.IsNotNull(result);
            Assert.AreEqual(StatementResultType.Result, result.Type);
        }
Exemple #14
0
        public override void Visit(LoopStatement stmt)
        {
            StartElement("loopStatement");
            Attribute("conditionPosition", stmt.ConditionPos);
            stmt.ConditionExp.AcceptVisitor(this);
            if (stmt.Stmt != null)
            {
                stmt.Stmt.AcceptVisitor(this);
            }

            EndElement();
        }
Exemple #15
0
        void LoopStatement(out Statement stat)
        {
            LoopStatement ls = new LoopStatement(GetPragma(la)); stat = ls;

            Expect(8);
            Expect(7);
            Expect(30);
            Expect(1);
            ls.name = t.val; BeginScope();
            if (la.kind == 1)
            {
                ls.StartOperation(GetPragma(la));
                Get();
                ls.SetOperationFunction(GetFunction(t.val));
                if (la.kind == 30)
                {
                    Get();
                }
                Expect(1);
                ls.SetLoopVariable(GetPragma(t), GetVariable(t.val)); SetEndPragma(ls.operation); SetEndPragma(((ls.operation as AssignmentStatement).rval as FunctionExpression).arguments[0]); SetEndPragma((ls.operation as AssignmentStatement).rval); SetEndPragma((ls.operation as AssignmentStatement).lval);
            }
            if (la.kind == 31 || la.kind == 32)
            {
                if (la.kind == 31)
                {
                    Get();
                    ls.type = LoopType.Until;
                }
                else
                {
                    Get();
                    ls.type = LoopType.While;
                }
                Expression(out ls.condition);
            }
            SetEndPragma(stat);
            Expect(5);
            while (la.kind == 5)
            {
                Get();
            }
            Statements(out ls.statements);
            Expect(8);
            Expect(9);
            Expect(30);
            Expect(1);
            if (t.val != ls.name)
            {
                Error("Loop terminator label does not match loop label");
            }
            EndScope();
        }
Exemple #16
0
        //-----------------------------------------------------------
        private string Visit(LoopStatement node, Table table)
        {
            string retString      = "";
            string loopStartLabel = GenerateLabel();
            string loopEndLabel   = GenerateLabel();

            loopLabels.Push(loopEndLabel);
            retString += "\t\t" + loopStartLabel + ":\n";
            retString += VisitChildren(node, table);
            retString += "\t\tbr " + loopStartLabel + "\n";
            loopLabels.Pop();
            retString += "\t\t" + loopEndLabel + ":\n";
            return(retString);
        }
        public void LoopStatementProducesLoopWithAllTheBellsAndWhistlesThroughProperties()
        {
            var a = JS.Id("a");
            var initialization = JS.Var(a.AssignWith(0));
            var condition = a.IsLessThan(10);
            var iteration = a.PostIncrement();
            var alert = JS.Alert(a);
            var statement = new LoopStatement();
            statement.Initialization = initialization;
            statement.Condition = condition;
            statement.Iteration = iteration;
            statement.Statement = alert;

            Assert.AreEqual("for(var a=0;a<10;a++)alert(a);", statement.ToString());
        }
        public void LoopStatementProducesLoopWithAllTheBellsAndWhistles()
        {
            var a = JS.Id("a");
            var initialization = JS.Var(a.AssignWith(0));
            var condition      = a.IsLessThan(10);
            var iteration      = a.PostIncrement();
            var alert          = JS.Alert(a);
            var statement      = new LoopStatement(initialization, condition, iteration, alert);

            Assert.AreEqual("var a=0;", statement.Initialization.ToString());
            Assert.AreEqual("a++;", statement.Iteration.ToString());
            Assert.AreEqual("a<10;", statement.Condition.ToString());
            Assert.AreEqual("alert(a);", statement.Statement.ToString());
            Assert.AreEqual("for(var a=0;a<10;a++)alert(a);", statement.ToString());
        }
Exemple #19
0
        public LoopStatement ParseLoopStatement(LoopStatementContext node)
        {
            LoopStatement statement = new LoopStatement();

            statement.Name = new TokenInfo(node.uid().First());

            foreach (var child in node.children)
            {
                if (child is ProcedureSqlStatementContext sql)
                {
                    statement.Statements.AddRange(this.ParseProcedureStatement(sql));
                }
            }

            return(statement);
        }
Exemple #20
0
        public Node LoopStatement()
        {
            var result = new LoopStatement()
            {
                AnchorToken = Expect(TokenCategory.LOOP)
            };

            while (firstOfStatement.Contains(CurrentToken))
            {
                result.Add(Statement());
            }

            Expect(TokenCategory.END);
            Expect(TokenCategory.SEMICOLON);

            return(result);
        }
Exemple #21
0
        public object VisitLoopStatement(LoopStatement statement)
        {
            Execute(statement.Initializer);

            while (IsTruthy(Evaluate(statement.Condition)))
            {
                try
                {
                    Execute(statement.Body);
                }
                catch (LoxBreakException) { break; }
                catch (LoxContinueException) { continue; }
                finally
                {
                    Evaluate(statement.Increment);
                }
            }

            return(null);
        }
        public void PushLoop(LoopStatement loop, TargetType breakTarget, TargetType continueTarget)
        {
            //update the continue label of the loop's label
            Statement statement = loop;

            for (var i = _labels.Count - 1; i >= 0; --i)
            {
                var info = _labels[i];
                if (info.Label != null && info.Label.Target == statement)
                {
                    info.ContinueTarget = continueTarget;
                    statement           = info.Label;
                }
                else
                {
                    break;
                }
            }
            InternalPushLabel(null, breakTarget).ContinueTarget = continueTarget;
        }
Exemple #23
0
        /// <summary>
        /// Visit a parse tree produced by <see cref="Z80AsmParser.iterationTest"/>.
        /// <para>
        /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
        /// on <paramref name="context"/>.
        /// </para>
        /// </summary>
        /// <param name="context">The parse tree.</param>
        /// <return>The visitor result.</return>
        public override object VisitIterationTest(Z80AsmParser.IterationTestContext context)
        {
            IToken        token = null;
            StatementBase stmt  = null;

            if (context.LOOP() != null || context.IDENTIFIER()?.GetText().ToLower() == "loop")
            {
                token = context.LOOP()?.Symbol;
                stmt  = new LoopStatement(this, context.expr());
            }
            else if (context.WHILE() != null || context.IDENTIFIER()?.GetText().ToLower() == "while")
            {
                token = context.WHILE()?.Symbol;
                stmt  = new WhileStatement(this, context.expr());
            }
            else if (context.UNTIL() != null || context.IDENTIFIER()?.GetText().ToLower() == "until")
            {
                token = context.UNTIL()?.Symbol;
                stmt  = new UntilStatement(this, context.expr());
            }
            else if (context.ELIF() != null || context.IDENTIFIER()?.GetText().ToLower() == "elif")
            {
                token = context.ELIF()?.Symbol;
                stmt  = new ElifStatement(this, context.expr());
            }
            else
            {
                return(null);
            }

            if (token == null)
            {
                token = context.IDENTIFIER().Symbol;
            }
            KeywordSpan = new TextSpan(token.StartIndex, token.StopIndex + 1);
            return(stmt);
        }
        public void LoopStatementProducesInfiniteLoop()
        {
            var statement = new LoopStatement(null, null, null, JS.Empty());

            Assert.AreEqual("for(;;);", statement.ToString());
        }
 protected internal virtual void PostWalk(LoopStatement node) { }
 // LoopStatement
 protected internal virtual bool Walk(LoopStatement node) { return true; }
        public void LoopStatementRequiresStatement()
        {
            var statement = new LoopStatement();

            Expect.Throw <InvalidOperationException>(() => statement.ToString());
        }
Exemple #28
0
 public virtual void Visit(LoopStatement stmt)
 {
 }
Exemple #29
0
        private static StatementBlock ParseStatementBlock(BinaryReader reader, Encoding encoding, BinaryWriter lineOffestWriter, BinaryWriter blockOffestWriter)
        {
            var block = new StatementBlock();

            while (!(reader.BaseStream.Position == reader.BaseStream.Length))
            {
                var type = reader.ReadByte();
                while (Array.BinarySearch(KnownTypeId, type) < 0)
                {
                    // 尝试跳过未知信息
                    type = reader.ReadByte();
                }
                var startOffest = (int)reader.BaseStream.Position - 1; // typeId到代码数据开头的偏移位置
                if (lineOffestWriter != null)
                {
                    if (true && // 部分数据不需要将位置写入LineOffest(一般为在IDE无显示的数据)
                        type != 0x50 && // 否则
                        type != 0x51 && // 如果结束
                        type != 0x52 && // 如果真结束
                        type != 0x55 && // 循环块结束标识:0x71前
                        type != 0x54 && // .判断结束
                        type != 0x53 && // .判断 某Case结束
                        type != 0x6D && // .判断开始(紧接着就是 0x6E)
                        type != 0x6F)    // .默认)
                    {
                        lineOffestWriter.Write(startOffest);
                    }
                }
                switch (type)
                {
                case 0x50:     // 否则
                case 0x51:     // 如果结束
                case 0x52:     // 如果真结束
                case 0x53:     // .判断 某Case结束
                case 0x54:     // .判断结束
                case 0x6F:     // .默认
                case 0x71:     // 循环结束语句:XX循环尾(参数...)
                    reader.BaseStream.Position = startOffest;
                    return(block);

                case 0x55:     // 循环体结束标识(0x71前)
                    continue;

                case 0x6D:     // .判断开始(紧接着就是 0x6E)
                {
                    blockOffestWriter.Write((byte)4);
                    blockOffestWriter.Write(startOffest);
                    long posToFillEndOffest = blockOffestWriter.BaseStream.Position;
                    blockOffestWriter.Write(0);
                    var s = new SwitchStatement();
                    if (reader.ReadByte() != 0x6E)         // .判断 某Case开始
                    {
                        throw new Exception();
                    }
                    byte switch_type;
                    do
                    {
                        lineOffestWriter.Write((int)reader.BaseStream.Position - 1);
                        var caseInfo = new SwitchStatement.CaseInfo();
                        caseInfo.Condition      = ParseCallExpressionWithoutType(reader, encoding, out var caseInfo_UnexaminedCode, out var caseInfo_Comment, out var caseInfo_Mask).ParamList.ElementAtOrDefault(0);
                        caseInfo.UnexaminedCode = caseInfo_UnexaminedCode;
                        caseInfo.Comment        = caseInfo_Comment;
                        caseInfo.Mask           = caseInfo_Mask;
                        caseInfo.Block          = ParseStatementBlock(reader, encoding, lineOffestWriter, blockOffestWriter);
                        s.Case.Add(caseInfo);
                        if (reader.ReadByte() != 0x53)
                        {
                            throw new Exception();
                        }
                    } while ((switch_type = reader.ReadByte()) == 0x6E);
                    if (switch_type != 0x6F)         // .默认
                    {
                        throw new Exception();
                    }
                    s.DefaultBlock = ParseStatementBlock(reader, encoding, lineOffestWriter, blockOffestWriter);
                    if (reader.ReadByte() != 0x54)         // .判断结束
                    {
                        throw new Exception();
                    }
                    int endOffest = (int)reader.BaseStream.Position;
                    blockOffestWriter.BaseStream.Position = posToFillEndOffest;
                    blockOffestWriter.Write(endOffest);
                    blockOffestWriter.BaseStream.Seek(0, SeekOrigin.End);
                    reader.ReadByte();         // 0x74
                    block.Add(s);
                }
                    continue;
                }
                var exp = ParseCallExpressionWithoutType(reader, encoding, out string unexaminedCode, out string comment, out bool mask);
                switch (type)
                {
                case 0x70:     // 循环开始语句:XX循环首(参数...)
                {
                    blockOffestWriter.Write((byte)3);
                    blockOffestWriter.Write(startOffest);
                    long posToFillEndOffest = blockOffestWriter.BaseStream.Position;
                    blockOffestWriter.Write(0);

                    var            loopblock = ParseStatementBlock(reader, encoding, lineOffestWriter, blockOffestWriter);
                    CallExpression endexp    = null;

                    var endOffest = (int)reader.BaseStream.Position;
                    blockOffestWriter.BaseStream.Position = posToFillEndOffest;
                    blockOffestWriter.Write(endOffest);
                    blockOffestWriter.BaseStream.Seek(0, SeekOrigin.End);

                    string endexp_unexaminedCode;
                    string endexp_comment;
                    bool   endexp_mask;
                    switch (reader.ReadByte())
                    {
                    case 0x71:
                        endexp = ParseCallExpressionWithoutType(reader, encoding, out endexp_unexaminedCode, out endexp_comment, out endexp_mask);
                        break;

                    default:
                        throw new Exception();
                    }
                    if (exp.LibraryId != 0)
                    {
                        throw new Exception();
                    }
                    LoopStatement s = null;
                    switch (exp.MethodId)
                    {
                    case 3:
                        s = new WhileStatement()
                        {
                            Condition      = exp.ParamList.ElementAtOrDefault(0),
                            Block          = loopblock,
                            UnexaminedCode = unexaminedCode
                        };
                        break;

                    case 5:
                        s = new DoWhileStatement()
                        {
                            Condition      = endexp.ParamList.ElementAtOrDefault(0),
                            Block          = loopblock,
                            UnexaminedCode = endexp_unexaminedCode
                        };
                        break;

                    case 7:
                        s = new CounterStatement()
                        {
                            Count          = exp.ParamList.ElementAtOrDefault(0),
                            Var            = exp.ParamList.ElementAtOrDefault(1),
                            Block          = loopblock,
                            UnexaminedCode = unexaminedCode
                        };
                        break;

                    case 9:
                        s = new ForStatement()
                        {
                            Start          = exp.ParamList.ElementAtOrDefault(0),
                            End            = exp.ParamList.ElementAtOrDefault(1),
                            Step           = exp.ParamList.ElementAtOrDefault(2),
                            Var            = exp.ParamList.ElementAtOrDefault(3),
                            Block          = loopblock,
                            UnexaminedCode = unexaminedCode
                        };
                        break;

                    default:
                        throw new Exception();
                    }

                    s.CommentOnStart = comment;
                    s.CommentOnEnd   = endexp_comment;

                    s.MaskOnStart = mask;
                    s.MaskOnEnd   = endexp_mask;

                    block.Add(s);
                }
                break;

                case 0x6C:     // 如果真
                {
                    blockOffestWriter.Write((byte)2);
                    blockOffestWriter.Write(startOffest);
                    long posToFillEndOffest = blockOffestWriter.BaseStream.Position;
                    blockOffestWriter.Write(0);

                    var s = new IfStatement()
                    {
                        Condition      = exp.ParamList.ElementAtOrDefault(0),
                        UnexaminedCode = unexaminedCode,
                        Block          = ParseStatementBlock(reader, encoding, lineOffestWriter, blockOffestWriter),
                        Comment        = comment,
                        Mask           = mask
                    };
                    if (reader.ReadByte() != 0x52)
                    {
                        throw new Exception();
                    }

                    var endOffest = (int)reader.BaseStream.Position;
                    blockOffestWriter.BaseStream.Position = posToFillEndOffest;
                    blockOffestWriter.Write(endOffest);
                    blockOffestWriter.BaseStream.Seek(0, SeekOrigin.End);

                    reader.ReadByte();         // 0x73

                    block.Add(s);
                }
                break;

                case 0x6B:     // 如果
                {
                    var s = new IfElseStatement()
                    {
                        Condition      = exp.ParamList.ElementAtOrDefault(0),
                        UnexaminedCode = unexaminedCode,
                        Comment        = comment,
                        Mask           = mask
                    };
                    blockOffestWriter.Write((byte)1);
                    blockOffestWriter.Write(startOffest);
                    long posToFillEndOffest = blockOffestWriter.BaseStream.Position;
                    blockOffestWriter.Write(0);

                    s.BlockOnTrue = ParseStatementBlock(reader, encoding, lineOffestWriter, blockOffestWriter);
                    if (reader.ReadByte() != 0x50)
                    {
                        throw new Exception();
                    }
                    s.BlockOnFalse = ParseStatementBlock(reader, encoding, lineOffestWriter, blockOffestWriter);
                    if (reader.ReadByte() != 0x51)
                    {
                        throw new Exception();
                    }
                    var endOffest = (int)reader.BaseStream.Position;

                    blockOffestWriter.BaseStream.Position = posToFillEndOffest;
                    blockOffestWriter.Write(endOffest);
                    blockOffestWriter.BaseStream.Seek(0, SeekOrigin.End);

                    reader.ReadByte();         // 0x72

                    block.Add(s);
                }
                break;

                case 0x6A:     // 常规Call
                {
                    if (unexaminedCode != null)
                    {
                        block.Add(new UnexaminedStatement()
                            {
                                UnexaminedCode = unexaminedCode,
                                Mask           = mask
                            });
                    }
                    else
                    {
                        if (exp.LibraryId == -1)
                        {
                            block.Add(new ExpressionStatement()
                                {
                                    Expression = null,
                                    Comment    = comment
                                });
                        }
                        else
                        {
                            block.Add(new ExpressionStatement()
                                {
                                    Expression = exp,
                                    Comment    = comment,
                                    Mask       = mask
                                });
                        }
                    }
                }
                break;
                }
            }
            return(block);
        }
        public void LoopStatementProducesInfiniteLoop()
        {
            var statement = new LoopStatement(null, null, null, JS.Empty());

            Assert.AreEqual("for(;;);", statement.ToString());
        }
 public BreakStatement(LoopStatement enclosure)
 {
     Enclosure = enclosure;
 }
Exemple #32
0
        //protected override void Visit(Statement node)
        //{
        //  var cloned = unfinishedClone;

        //  unfinishedClone = cloned;
        //  base.Visit(node);
        //}

        //protected override void Visit(Literal node)
        //{
        //  var cloned = unfinishedClone;
        //  //
        //  unfinishedClone = cloned;
        //  base.Visit(node);
        //}

        //protected override void Visit(Reference node)
        //{
        //  var cloned = unfinishedClone;
        //  //
        //  unfinishedClone = cloned;
        //  base.Visit(node);
        //}

        //protected override void Visit(ConversionExpression node)
        //{
        //  var cloned = unfinishedClone;
        //  //
        //  unfinishedClone = cloned;
        //  base.Visit(node);
        //}

        //protected override void Visit(InternalExpression node)
        //{
        //  var cloned = unfinishedClone;
        //  //
        //  unfinishedClone = cloned;
        //  base.Visit(node);
        //}

        protected override void Visit(LoopStatement node)
        {
            base.Visit(node);
        }
Exemple #33
0
 void LoopStatement(out Statement stat)
 {
     LoopStatement ls = new LoopStatement(GetPragma(la)); stat = ls;
     Expect(8);
     Expect(7);
     Expect(30);
     Expect(1);
     ls.name = t.val; BeginScope();
     if (la.kind == 1) {
     ls.StartOperation(GetPragma(la));
     Get();
     ls.SetOperationFunction(GetFunction(t.val));
     if (la.kind == 30) {
         Get();
     }
     Expect(1);
     ls.SetLoopVariable(GetPragma(t), GetVariable(t.val)); SetEndPragma(ls.operation); SetEndPragma(((ls.operation as AssignmentStatement).rval as FunctionExpression).arguments[0]); SetEndPragma((ls.operation as AssignmentStatement).rval); SetEndPragma((ls.operation as AssignmentStatement).lval);
     }
     if (la.kind == 31 || la.kind == 32) {
     if (la.kind == 31) {
         Get();
         ls.type = LoopType.Until;
     } else {
         Get();
         ls.type = LoopType.While;
     }
     Expression(out ls.condition);
     }
     SetEndPragma(stat);
     Expect(5);
     while (la.kind == 5) {
     Get();
     }
     Statements(out ls.statements);
     Expect(8);
     Expect(9);
     Expect(30);
     Expect(1);
     if(t.val != ls.name) Error("Loop terminator label does not match loop label"); EndScope();
 }
 public void PopLoop(LoopStatement loop)
 {
     PopLabel(null);
 }
        public void LoopStatementRequiresStatement()
        {
            var statement = new LoopStatement();

            Expect.Throw<InvalidOperationException>(() => statement.ToString());
        }
Exemple #36
0
 protected override void Visit(LoopStatement node)
 {
     Visit((Statement)node);
 }