コード例 #1
0
        public void DoWhileStatementTest()
        {
            DoWhileStatement loopStmt = ParseUtilCSharp.ParseStatement <DoWhileStatement>("do { } while (true);");

            Assert.IsTrue(loopStmt.Condition is PrimitiveExpression);
            Assert.IsTrue(loopStmt.EmbeddedStatement is BlockStatement);
        }
コード例 #2
0
        public override AstNode VisitDoWhileStatement(DoWhileStatement forStatement)
        {
            var visitor = new LambdaVisitor();

            forStatement.EmbeddedStatement.AcceptVisitor(visitor);

            if (visitor.LambdaExpression.Count == 0 && forStatement.EmbeddedStatement is BlockStatement)
            {
                return(base.VisitDoWhileStatement(forStatement));
            }

            var clonForStatement = (DoWhileStatement)base.VisitDoWhileStatement(forStatement);

            if (clonForStatement != null)
            {
                forStatement = clonForStatement;
            }

            if (!(forStatement.EmbeddedStatement is BlockStatement))
            {
                var l     = (DoWhileStatement)forStatement.Clone();
                var block = new BlockStatement();
                block.Statements.Add(l.EmbeddedStatement.Clone());
                l.EmbeddedStatement = block;

                return(l);
            }

            return(forStatement.Clone());
        }
コード例 #3
0
ファイル: EmptyLambdaFixer.cs プロジェクト: theolivenbaum/h5
        public override AstNode VisitDoWhileStatement(DoWhileStatement forStatement)
        {
            if (forStatement.EmbeddedStatement is BlockStatement)
            {
                return(base.VisitDoWhileStatement(forStatement));
            }

            var clonForStatement = (DoWhileStatement)base.VisitDoWhileStatement(forStatement);

            if (clonForStatement != null)
            {
                forStatement = clonForStatement;
            }

            if (!(forStatement.EmbeddedStatement is BlockStatement))
            {
                var l     = (DoWhileStatement)forStatement.Clone();
                var block = new BlockStatement();
                block.Statements.Add(l.EmbeddedStatement.Clone());
                l.EmbeddedStatement = block;

                return(l);
            }

            return(forStatement.Clone());
        }
コード例 #4
0
ファイル: StatementInterpreter.cs プロジェクト: zhongzf/jint
        /// <summary>
        /// http://www.ecma-international.org/ecma-262/5.1/#sec-12.6.1
        /// </summary>
        /// <param name="doWhileStatement"></param>
        /// <returns></returns>
        public Completion ExecuteDoWhileStatement(DoWhileStatement doWhileStatement)
        {
            JsValue v = Undefined.Instance;
            bool    iterating;

            do
            {
                var stmt = ExecuteStatement(doWhileStatement.Body);
                if (stmt.Value.HasValue)
                {
                    v = stmt.Value.Value;
                }
                if (stmt.Type != Completion.Continue || stmt.Identifier != doWhileStatement.LabelSet)
                {
                    if (stmt.Type == Completion.Break && (stmt.Identifier == null || stmt.Identifier == doWhileStatement.LabelSet))
                    {
                        return(new Completion(Completion.Normal, v, null));
                    }

                    if (stmt.Type != Completion.Normal)
                    {
                        return(stmt);
                    }
                }
                var exprRef = _engine.EvaluateExpression(doWhileStatement.Test);
                iterating = TypeConverter.ToBoolean(_engine.GetValue(exprRef));
            } while (iterating);

            return(new Completion(Completion.Normal, v, null));
        }
コード例 #5
0
 public DoWhileExpressionInterpreter(ExpressionInterpreterHandler expressionInterpreterHandler, DoWhileStatement doWhileStatement, LabelTarget brk, LabelTarget cont)
 {
     this.expressionInterpreterHandler = expressionInterpreterHandler;
     this.doWhileStatement             = doWhileStatement;
     this.brk  = brk;
     this.cont = cont;
 }
コード例 #6
0
		static void ConvertToWhileLoop(Script script, DoWhileStatement originalStatement)
		{
			script.Replace(originalStatement, new WhileStatement {
				Condition = originalStatement.Condition.Clone(),
				EmbeddedStatement = originalStatement.EmbeddedStatement.Clone()
			});
		}
コード例 #7
0
        protected void VisitDoWhileStatement()
        {
            DoWhileStatement doWhileStatement = this.DoWhileStatement;
            var jumpStatements = this.Emitter.JumpStatements;

            this.Emitter.JumpStatements = null;

            this.WriteDo();
            this.EmitBlockOrIndentedLine(doWhileStatement.EmbeddedStatement);

            if (doWhileStatement.EmbeddedStatement is BlockStatement)
            {
                this.WriteSpace();
            }

            this.WriteWhile();
            this.WriteOpenParentheses();

            doWhileStatement.Condition.AcceptVisitor(this.Emitter);

            this.WriteCloseParentheses();
            this.WriteSemiColon();

            this.WriteNewLine();

            this.Emitter.JumpStatements = jumpStatements;
        }
コード例 #8
0
        bool ParseDoWhileStatement(out DoWhileStatement doWhileStatement)
        {
            doWhileStatement = new DoWhileStatement();

            if (tokenReader.Expect(LexKind.Keyword) && tokenReader.ExpectValue("do"))
            {
                tokenReader.Skip(1);
                if (ParseStatement(out Statement body))
                {
                    doWhileStatement.Body = body;
                    if (tokenReader.ExpectFatal(LexKind.Keyword) && tokenReader.ExpectValue("while"))
                    {
                        tokenReader.Skip(2);
                        if (ParseExpression(out Expression condition))
                        {
                            doWhileStatement.Condition = condition;
                            return(true);
                        }
                        else
                        {
                            throw new Exception("Condition expected in do-while loop");
                        }
                    }
                }
                else
                {
                    throw new Exception("Body expected in do-while loop");
                }
            }

            return(false);
        }
コード例 #9
0
ファイル: ScriptCompiler.cs プロジェクト: jhurliman/simian
        /// <summary>
        /// Generates the code for a DoWhileStatement node.
        /// </summary>
        /// <param name="dws">The DoWhileStatement node.</param>
        /// <returns>String containing C# code for DoWhileStatement dws.</returns>
        private string GenerateDoWhileStatement(DoWhileStatement dws)
        {
            string retstr = String.Empty;

            retstr += GenerateIndentedLine("do", dws);

            // CompoundStatement handles indentation itself but we need to do it
            // otherwise.
            bool indentHere = dws.kids.Top is Statement;

            if (indentHere)
            {
                m_braceCount++;
            }
            retstr += GenerateNode((SYMBOL)dws.kids.Pop());
            if (indentHere)
            {
                m_braceCount--;
            }

            retstr += GenerateIndented("while (", dws);
            retstr += GenerateNode((SYMBOL)dws.kids.Pop());
            retstr += GenerateLine(");");

            return(retstr);
        }
コード例 #10
0
ファイル: Visitor.Exception.cs プロジェクト: zwmyint/Bridge
 public virtual void VisitDoWhileStatement(DoWhileStatement doWhileStatement)
 {
     if (this.ThrowException)
     {
         throw (System.Exception) this.CreateException(doWhileStatement);
     }
 }
コード例 #11
0
ファイル: MethodVisitor.cs プロジェクト: JoeHosman/sharpDox
		public override void VisitDoWhileStatement(DoWhileStatement doWhileStatement)
		{
            var token = CreateBlock(string.Format("while ({0})", doWhileStatement.Condition.GetText()), SDNodeRole.DoWhileLoop);
            _tokenList.Add(token);

            VisitChildren(token.Statements, doWhileStatement.EmbeddedStatement);
		}
        private UstStmts.DoWhileStatement VisitDoWhileStatement(DoWhileStatement doWhileStatement)
        {
            var statement = VisitStatement(doWhileStatement.Body);
            var condition = VisitExpression(doWhileStatement.Test);

            return(new UstStmts.DoWhileStatement(statement, condition, GetTextSpan(doWhileStatement)));
        }
 static void ConvertToWhileLoop(Script script, DoWhileStatement originalStatement)
 {
     script.Replace(originalStatement, new WhileStatement {
         Condition         = originalStatement.Condition.Clone(),
         EmbeddedStatement = originalStatement.EmbeddedStatement.Clone()
     });
 }
コード例 #14
0
ファイル: LambdaVisitor.cs プロジェクト: retsimx/Bridge
 public override void VisitDoWhileStatement(DoWhileStatement doWhileStatement)
 {
     if (findReturn)
     {
         base.VisitDoWhileStatement(doWhileStatement);
     }
 }
コード例 #15
0
ファイル: Visitor.Exception.cs プロジェクト: theolivenbaum/h5
 public virtual void VisitDoWhileStatement(DoWhileStatement doWhileStatement)
 {
     if (ThrowException)
     {
         throw (Exception)CreateException(doWhileStatement);
     }
 }
コード例 #16
0
ファイル: ControlFlow.cs プロジェクト: xiaotie/NRefactory
            public override ControlFlowNode VisitDoWhileStatement(DoWhileStatement doWhileStatement, ControlFlowNode data)
            {
                // <data> do { <bodyStart> embeddedStmt; <bodyEnd>} <condition> while(cond); <end>
                ControlFlowNode end           = builder.CreateEndNode(doWhileStatement, addToNodeList: false);
                ControlFlowNode conditionNode = builder.CreateSpecialNode(doWhileStatement, ControlFlowNodeType.LoopCondition, addToNodeList: false);

                breakTargets.Push(end);
                continueTargets.Push(conditionNode);

                ControlFlowNode bodyStart = builder.CreateStartNode(doWhileStatement.EmbeddedStatement);

                Connect(data, bodyStart);
                ControlFlowNode bodyEnd = doWhileStatement.EmbeddedStatement.AcceptVisitor(this, bodyStart);

                Connect(bodyEnd, conditionNode);

                bool?cond = builder.EvaluateCondition(doWhileStatement.Condition);

                if (cond != false)
                {
                    Connect(conditionNode, bodyStart, ControlFlowEdgeType.ConditionTrue);
                }
                if (cond != true)
                {
                    Connect(conditionNode, end, ControlFlowEdgeType.ConditionFalse);
                }

                breakTargets.Pop();
                continueTargets.Pop();
                builder.nodes.Add(conditionNode);
                builder.nodes.Add(end);
                return(end);
            }
コード例 #17
0
ファイル: AstJson.cs プロジェクト: taljaardjcf/esprima-dotnet
 protected override void VisitDoWhileStatement(DoWhileStatement doWhileStatement)
 {
     using (StartNodeObject(doWhileStatement))
     {
         Member("body", doWhileStatement.Body);
         Member("test", doWhileStatement.Test);
     }
 }
コード例 #18
0
        public JNode VisitDoWhileStatement(DoWhileStatement node)
        {
            var node2 = new JDoWhileStatement {
                Statement = VisitStatement(node.EmbeddedStatement), Condition = VisitExpression(node.Condition)
            };

            return(node2);
        }
コード例 #19
0
        public override void VisitDoWhileStatement(DoWhileStatement doWhileStatement)
        {
            var token = CreateBlock(string.Format("while ({0})", doWhileStatement.Condition.GetText()), SDNodeRole.DoWhileLoop);

            _tokenList.Add(token);

            VisitChildren(token.Statements, doWhileStatement.EmbeddedStatement);
        }
コード例 #20
0
 public override void Visit(DoWhileStatement node)
 {
     VisitNode(node.Body);
     VisitNode(node.Condition);
     Visit((LoopStatement)node);
     WriteEdge(node, node.Body, "body");
     WriteEdge(node, node.Condition, "condition");
 }
コード例 #21
0
		void ApplyAction(Script script, WhileStatement statement) {
			var doWhile = new DoWhileStatement {
				Condition = statement.Condition.Clone(),
				EmbeddedStatement = statement.EmbeddedStatement.Clone()
			};

			script.Replace(statement, doWhile);
		}
コード例 #22
0
        public override void VisitDoWhileStatement(DoWhileStatement doWhileStatement)
        {
            this.loopLevel++;

            doWhileStatement.EmbeddedStatement = GetLoopBlock(doWhileStatement.EmbeddedStatement);
            base.VisitDoWhileStatement(doWhileStatement);

            this.loopLevel--;
        }
コード例 #23
0
        protected virtual IEnumerable <Syntax> TranslateDoWhileStatement(DoWhileStatement doWhileStatement, ILTranslationContext data)
        {
            var bs = new S.DoStatement();

            bs.Condition  = GetExpression(doWhileStatement.Condition, data);
            bs.Statements = GetStatements(doWhileStatement.EmbeddedStatement, data);

            yield return(bs);
        }
コード例 #24
0
        public override void VisitDoWhileStatement(DoWhileStatement doLoopStatement)
        {
            base.VisitDoWhileStatement(doLoopStatement);

            BranchesCounter++;
            var conditionComplexity = GetConditionComplexity(doLoopStatement.Condition);

            BranchesCounter += conditionComplexity;
        }
コード例 #25
0
        void ApplyAction(Script script, WhileStatement statement)
        {
            var doWhile = new DoWhileStatement {
                Condition         = statement.Condition.Clone(),
                EmbeddedStatement = statement.EmbeddedStatement.Clone()
            };

            script.Replace(statement, doWhile);
        }
コード例 #26
0
ファイル: EmptyLambdaFixer.cs プロジェクト: theolivenbaum/h5
        public override void VisitDoWhileStatement(DoWhileStatement whileStatement)
        {
            if (!(whileStatement.EmbeddedStatement is BlockStatement))
            {
                Found = true;
            }

            base.VisitDoWhileStatement(whileStatement);
        }
コード例 #27
0
 public object VisitDoWhileStatement(DoWhileStatement s, object context)
 {
     StringBuilder.Append("do ");
     s.Body.AcceptVisitor(this, context);
     StringBuilder.Append(" while (");
     s.Condition.AcceptVisitor(this, context);
     StringBuilder.Append(")");
     return(null);
 }
コード例 #28
0
ファイル: AstWriter.cs プロジェクト: vrajeshbhavsar/mcjs
 public void Visit(DoWhileStatement expression)
 {
     outStream.WriteLine("do {");
     expression.Statement.Accept(this);
     outStream.WriteLine();
     outStream.Write("} while (");
     expression.Condition.Accept(this);
     outStream.Write(")");
 }
コード例 #29
0
        public override void VisitDoWhileStatement(DoWhileStatement node)
        {
            int index = body.Instructions.Count;

            Visit(node.Body);

            Visit(node.Condition);

            cil.EmitInstruction(OpCodes.Brtrue, body.Instructions[index]);
        }
コード例 #30
0
            public RedILNode VisitDoWhileStatement(DoWhileStatement doWhileStatement, State data)
            {
                var doWhile = new DoWhileNode();

                doWhile.Condition = CastUtilities.CastRedILNode <ExpressionNode>(doWhileStatement.Condition.AcceptVisitor(this, data.NewState(doWhileStatement, doWhile)));
                doWhile.Body      = RemoveFirstLevelContinue(CastUtilities.CastRedILNode <BlockNode>(
                                                                 doWhileStatement.EmbeddedStatement.AcceptVisitor(this, data.NewState(doWhileStatement, doWhile))), data);

                return(doWhile);
            }
コード例 #31
0
        protected void VisitAsyncDoWhileStatement()
        {
            DoWhileStatement doWhileStatement = this.DoWhileStatement;

            var oldValue       = this.Emitter.ReplaceAwaiterByVar;
            var jumpStatements = this.Emitter.JumpStatements;

            this.Emitter.JumpStatements = new List <IJumpInfo>();

            var loopStep = this.Emitter.AsyncBlock.Steps.Last();

            if (!string.IsNullOrWhiteSpace(loopStep.Output.ToString()))
            {
                loopStep = this.Emitter.AsyncBlock.AddAsyncStep();
            }

            this.Emitter.IgnoreBlock = doWhileStatement.EmbeddedStatement;
            doWhileStatement.EmbeddedStatement.AcceptVisitor(this.Emitter);

            this.Emitter.AsyncBlock.Steps.Last().JumpToStep = this.Emitter.AsyncBlock.Step;
            var conditionStep = this.Emitter.AsyncBlock.AddAsyncStep();

            this.WriteAwaiters(doWhileStatement.Condition);

            this.WriteIf();
            this.WriteOpenParentheses(true);
            this.Emitter.ReplaceAwaiterByVar = true;
            doWhileStatement.Condition.AcceptVisitor(this.Emitter);
            this.WriteCloseParentheses(true);
            this.Emitter.ReplaceAwaiterByVar = oldValue;

            this.WriteSpace();
            this.BeginBlock();
            this.WriteNewLine();
            this.Write(JS.Vars.ASYNC_STEP + " = " + loopStep.Step + ";");
            this.WriteNewLine();
            this.Write("continue;");
            this.WriteNewLine();
            this.EndBlock();

            var nextStep = this.Emitter.AsyncBlock.AddAsyncStep();

            conditionStep.JumpToStep = nextStep.Step;

            if (this.Emitter.JumpStatements.Count > 0)
            {
                this.Emitter.JumpStatements.Sort((j1, j2) => - j1.Position.CompareTo(j2.Position));
                foreach (var jump in this.Emitter.JumpStatements)
                {
                    jump.Output.Insert(jump.Position, jump.Break ? nextStep.Step : conditionStep.Step);
                }
            }

            this.Emitter.JumpStatements = jumpStatements;
        }
コード例 #32
0
 public override void VisitDoWhileStatement(DoWhileStatement doWhileStatement)
 {
     bool oldIsInsideLoop = _isInsideLoop;
     try {
         _isInsideLoop = true;
         base.VisitDoWhileStatement(doWhileStatement);
     }
     finally {
         _isInsideLoop = oldIsInsideLoop;
     }
 }
コード例 #33
0
ファイル: CSharpWriter.cs プロジェクト: jma2400/cecil-old
 public override void VisitDoWhileStatement(DoWhileStatement node)
 {
     WriteKeyword("do");
     WriteLine();
     Visit(node.Body);
     WriteKeyword("while");
     WriteSpace();
     WriteBetweenParenthesis(node.Condition);
     WriteToken(";");
     WriteLine();
 }
コード例 #34
0
 public void Visit(DoWhileStatement node)
 {
     if (node != null)
     {
         // do-while statements TECHNICALLY should end with a semicolon.
         // but IE seems to parse do-while statements WITHOUT the semicolon, so
         // the terminating semicolon ends up being an empty statement AFTER the
         // do-while. Which throws off else or other do-while while-clauses.
         DoesRequire = true;
     }
 }
コード例 #35
0
 public override object VisitDoWhileStatement(DoWhileStatement doWhileStatement, object data)
 {
     if (doWhileStatement.EmbeddedStatement is BlockStatement)
     {
         foreach (Statement innerstatement in (BlockStatement)doWhileStatement.EmbeddedStatement)
         {
             if (innerstatement is WhileStatement || innerstatement is DoWhileStatement)
                 UnlockWith(doWhileStatement);
         }
     }
     return base.VisitDoWhileStatement(doWhileStatement, data);
 }
コード例 #36
0
ファイル: ReplaceJumpToWhile.cs プロジェクト: scemino/nscumm
        static BlockStatement ReplaceJump(JumpStatement jump, BlockStatement block)
        {
            if (jump.StartOffset < block.StartOffset)
                throw new ArgumentOutOfRangeException("jump", "jump should be inside the given block");
            if (jump.JumpOffset > block.EndOffset)
                throw new ArgumentOutOfRangeException("jump", "jump should be inside the given block");

            var newBlock = new BlockStatement();
            var doWhileStatement = new DoWhileStatement(jump.Condition, new BlockStatement()){ StartOffset = jump.StartOffset, EndOffset = jump.JumpOffset };
            var inside = false;
            foreach (var statement in block)
            {
                if (statement.StartOffset == jump.JumpOffset)
                {                    
                    ((BlockStatement)doWhileStatement.Statement).AddStatement(statement);
                    inside = true;
                }
                else if (statement.StartOffset == jump.StartOffset)
                {
                    if (doWhileStatement == null)
                        throw new InvalidOperationException("DoWhileStatement can't be null");
                    newBlock.AddStatement(doWhileStatement);
                    doWhileStatement = null;
                    inside = false;
                }
                else if (inside)
                {
                    ((BlockStatement)doWhileStatement.Statement).AddStatement(statement);
                }
                else
                {
                    var lastStatement = newBlock.LastOrDefault();
                    if (lastStatement != null && lastStatement.EndOffset > statement.StartOffset)
                    {
                        throw new NotSupportedException("invalid Statement");
                    }
                    newBlock.AddStatement(statement);
                }
            }
            return newBlock;
        }
コード例 #37
0
 public virtual void VisitDoWhileStatement(DoWhileStatement doWhileStatement)
 {
     if (this.ThrowException)
     {
         throw (Exception)this.CreateException(doWhileStatement);
     }
 }
コード例 #38
0
ファイル: AstWriter.cs プロジェクト: reshadi2/mcjs
 public void Visit(DoWhileStatement expression)
 {
     outStream.WriteLine("do {");
     expression.Statement.Accept(this);
     outStream.WriteLine();
     outStream.Write("} while (");
     expression.Condition.Accept(this);
     outStream.Write(")");
 }
コード例 #39
0
ファイル: Parser.cs プロジェクト: hesam/SketchSharp
 private Statement ParseDoWhile(TokenSet followers)
   //^ requires this.currentToken == Token.Do;
   //^ ensures followers[this.currentToken] || this.currentToken == Token.EndOfFile;
 {
   SourceLocationBuilder slb = new SourceLocationBuilder(this.scanner.SourceLocationOfLastScannedToken);
   this.GetNextToken();
   Statement body = this.ParseStatement(followers|Token.While);
   if (body is EmptyStatement)
     this.HandleError(body.SourceLocation, Error.PossibleMistakenNullStatement);
   this.Skip(Token.While);
   Expression condition = this.ParseParenthesizedExpression(false, followers|Token.Semicolon);
   DoWhileStatement result = new DoWhileStatement(body, condition, slb);
   this.SkipSemiColon(followers);
   return result;
 }
コード例 #40
0
 public override void VisitDoWhileStatement(DoWhileStatement doWhileStatement)
 {
     new DoWhileBlock(this, doWhileStatement).Emit();
 }
コード例 #41
0
		public override void VisitDoWhileStatement(DoWhileStatement doWhileStatement)
		{
			PlaceOnNewLine(policy.PlaceWhileOnNewLine, doWhileStatement.WhileToken);
			FixEmbeddedStatment(policy.StatementBraceStyle, policy.WhileBraceForcement, doWhileStatement.EmbeddedStatement);
		}
コード例 #42
0
ファイル: GlslVisitor.cs プロジェクト: mono-soc-2011/SLSharp
        public override StringBuilder VisitDoWhileStatement(DoWhileStatement doWhileStatement, int data)
        {
            var result = new StringBuilder("do");

            var stmt = doWhileStatement.EmbeddedStatement;
            result.Append(Indent(stmt, stmt.AcceptVisitor(this, data)));

            result.Append("while (").Append(doWhileStatement.Condition.AcceptVisitor(this, data)).Append(");");

            return result;
        }
コード例 #43
0
			public override object Visit (Do doStatement)
			{
				var result = new DoWhileStatement ();
				var location = LocationsBag.GetLocations (doStatement);
				result.AddChild (new CSharpTokenNode (Convert (doStatement.loc), "do".Length), DoWhileStatement.DoKeywordRole);
				result.AddChild ((MonoDevelop.CSharp.Ast.Statement)doStatement.EmbeddedStatement.Accept (this), WhileStatement.Roles.EmbeddedStatement);
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location[0]), "while".Length), DoWhileStatement.WhileKeywordRole);
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), DoWhileStatement.Roles.LPar);
				result.AddChild ((MonoDevelop.CSharp.Ast.Expression)doStatement.expr.Accept (this), DoWhileStatement.Roles.Condition);
				if (location != null) {
					result.AddChild (new CSharpTokenNode (Convert (location[2]), 1), DoWhileStatement.Roles.RPar);
					result.AddChild (new CSharpTokenNode (Convert (location[3]), 1), DoWhileStatement.Roles.Semicolon);
				}
				
				return result;
			}
コード例 #44
0
		public override void VisitDoWhileStatement(DoWhileStatement doWhileStatement)
		{
			FixEmbeddedStatment(policy.StatementBraceStyle, doWhileStatement.EmbeddedStatement);
			PlaceOnNewLine(doWhileStatement.EmbeddedStatement is BlockStatement ? policy.WhileNewLinePlacement : NewLinePlacement.NewLine, doWhileStatement.WhileToken);

			Align(doWhileStatement.LParToken, doWhileStatement.Condition, policy.SpacesWithinWhileParentheses);
			ForceSpacesBeforeRemoveNewLines(doWhileStatement.RParToken, policy.SpacesWithinWhileParentheses);
		}
コード例 #45
0
ファイル: DocAstVistor.cs プロジェクト: xuld/DocPlus
 public void VisitDoWhileStatement(DoWhileStatement doWhileStatement)
 {
     VisitExpression(doWhileStatement.Condition);
     VisitStatement(doWhileStatement.Body);
 }
コード例 #46
0
			public override void VisitDoWhileStatement (DoWhileStatement doWhileStatement)
			{
				base.VisitDoWhileStatement (doWhileStatement);

				CheckCondition (doWhileStatement.Condition);
			}
コード例 #47
0
ファイル: LambdaVisitor.cs プロジェクト: TinkerWorX/Bridge
 public override void VisitDoWhileStatement(DoWhileStatement doWhileStatement)
 {
     if (findReturn)
     {
         base.VisitDoWhileStatement(doWhileStatement);
     }
 }
コード例 #48
0
        public void DoWhileStatementRequiresStatement()
        {
            var d = new DoWhileStatement(JS.Null(), null);

            Expect.Throw<InvalidOperationException>(() => d.ToString());
        }
コード例 #49
0
        public void DoWhileStatementRequiresCondition()
        {
            var d = new DoWhileStatement();

            Expect.Throw<InvalidOperationException>(() => d.ToString());
        }
コード例 #50
0
ファイル: LambdaVisitor.cs プロジェクト: wangxueqzz/Bridge
 public override void VisitDoWhileStatement(DoWhileStatement doWhileStatement)
 {
 }
コード例 #51
0
        /// <summary>
        ///     Generates the code for a DoWhileStatement node.
        /// </summary>
        /// <param name="dws">The DoWhileStatement node.</param>
        /// <returns>String containing C# code for DoWhileStatement dws.</returns>
        private string GenerateDoWhileStatement(DoWhileStatement dws)
        {
            StringBuilder retVal = new StringBuilder();

            retVal.Append(GenerateIndentedLine("do", dws));
            if (IsParentEnumerable)
            {
                retVal.Append(GenerateLine("{")); // SLAM!
                retVal.Append(GenerateLine("if (CheckSlice()) yield return null;"));
            }

            // CompoundStatement handles indentation itself but we need to do it
            // otherwise.
            bool indentHere = dws.kids.Top is Statement;
            if (indentHere) m_braceCount++;
            retVal.Append(GenerateNode((SYMBOL) dws.kids.Pop()));
            if (indentHere) m_braceCount--;

            if (IsParentEnumerable)
                retVal.Append(GenerateLine("}"));

            bool marc = FuncCallsMarc();

            //Forces all functions to use MoveNext() instead of .Current, as it never changes otherwise, and the loop runs infinitely

            m_isInEnumeratedDeclaration = true;

            retVal.Append(GenerateIndented("while (", dws));
            retVal.Append(GenerateNode((SYMBOL) dws.kids.Pop()));
            retVal.Append(GenerateLine(");"));

            m_isInEnumeratedDeclaration = false; //End above

            return DumpFunc(marc) + retVal.ToString() + DumpAfterFunc(marc);
        }
コード例 #52
0
ファイル: DefaultVisitor.cs プロジェクト: scemino/nscumm
 public virtual void Visit(DoWhileStatement node)
 {
     DefaultVisit(node);
 }
コード例 #53
0
 public override void VisitDoWhileStatement(DoWhileStatement doWhileStatement)
 {
     var body = CreateInnerCompiler().Compile(doWhileStatement.EmbeddedStatement);
     var compiledCondition = CompileExpression(doWhileStatement.Condition, true);
     if (compiledCondition.AdditionalStatements.Count > 0)
         body = new JsBlockStatement(body.Statements.Concat(compiledCondition.AdditionalStatements));
     _result.Add(new JsDoWhileStatement(compiledCondition.Expression, body));
 }
		public virtual void VisitDoWhileStatement (DoWhileStatement doWhileStatement)
		{
			VisitChildren (doWhileStatement);
		}
コード例 #55
0
		public override void VisitDoWhileStatement(DoWhileStatement doWhileStatement) {
			var body = CreateInnerCompiler().Compile(doWhileStatement.EmbeddedStatement);
			var compiledCondition = CompileExpression(doWhileStatement.Condition, CompileExpressionFlags.ReturnValueIsImportant);
			if (compiledCondition.AdditionalStatements.Count > 0)
				body = JsStatement.Block(body.Statements.Concat(compiledCondition.AdditionalStatements));
			_result.Add(JsStatement.DoWhile(compiledCondition.Expression, body));
		}
コード例 #56
0
 public abstract StringBuilder VisitDoWhileStatement(DoWhileStatement doWhileStatement, int data);
コード例 #57
0
ファイル: CSharpParser.cs プロジェクト: 0xb1dd1e/NRefactory
			public override object Visit(Do doStatement)
			{
				var result = new DoWhileStatement();
				var location = LocationsBag.GetLocations(doStatement);
				result.AddChild(new CSharpTokenNode(Convert(doStatement.loc), DoWhileStatement.DoKeywordRole), DoWhileStatement.DoKeywordRole);
				if (doStatement.Statement != null)
					result.AddChild((Statement)doStatement.Statement.Accept(this), Roles.EmbeddedStatement);
				if (location != null)
					result.AddChild(new CSharpTokenNode(Convert(location [0]), DoWhileStatement.WhileKeywordRole), DoWhileStatement.WhileKeywordRole);
				if (location != null && location.Count > 1)
					result.AddChild(new CSharpTokenNode(Convert(location [1]), Roles.LPar), Roles.LPar);
				if (doStatement.expr != null)
					result.AddChild((Expression)doStatement.expr.Accept(this), Roles.Condition);
				if (location != null && location.Count > 2) {
					result.AddChild(new CSharpTokenNode(Convert(location [2]), Roles.RPar), Roles.RPar);
					if (location.Count > 3)
						result.AddChild(new CSharpTokenNode(Convert(location [3]), Roles.Semicolon), Roles.Semicolon);
				}
				
				return result;
			}
コード例 #58
0
ファイル: DoWhileBlock.cs プロジェクト: yindongfei/bridge.lua
 public DoWhileBlock(IEmitter emitter, DoWhileStatement doWhileStatement)
     : base(emitter, doWhileStatement)
 {
     this.Emitter = emitter;
     this.DoWhileStatement = doWhileStatement;
 }
コード例 #59
0
ファイル: CSharpOutputVisitor.cs プロジェクト: x-strong/ILSpy
		public void VisitDoWhileStatement(DoWhileStatement doWhileStatement)
		{
			StartNode(doWhileStatement);
			WriteKeyword(DoWhileStatement.DoKeywordRole);
			WriteEmbeddedStatement(doWhileStatement.EmbeddedStatement);
			WriteKeyword(DoWhileStatement.WhileKeywordRole);
			Space(policy.SpaceBeforeWhileParentheses);
			LPar();
			Space(policy.SpacesWithinWhileParentheses);
			doWhileStatement.Condition.AcceptVisitor(this);
			Space(policy.SpacesWithinWhileParentheses);
			RPar();
			Semicolon();
			EndNode(doWhileStatement);
		}
コード例 #60
0
        public override void VisitDoWhileStatement(DoWhileStatement doWhileStatement)
        {
            this.loopLevel++;

            doWhileStatement.EmbeddedStatement = GetLoopBlock (doWhileStatement.EmbeddedStatement);

            base.VisitDoWhileStatement (doWhileStatement);

            this.loopLevel--;
        }