示例#1
0
		public virtual object VisitDoLoopStatement(DoLoopStatement doLoopStatement, object data) {
			Debug.Assert((doLoopStatement != null));
			Debug.Assert((doLoopStatement.Condition != null));
			Debug.Assert((doLoopStatement.EmbeddedStatement != null));
			doLoopStatement.Condition.AcceptVisitor(this, data);
			return doLoopStatement.EmbeddedStatement.AcceptVisitor(this, data);
		}
		public virtual object VisitDoLoopStatement(DoLoopStatement doLoopStatement, object data) {
			Debug.Assert((doLoopStatement != null));
			Debug.Assert((doLoopStatement.Condition != null));
			Debug.Assert((doLoopStatement.EmbeddedStatement != null));
			nodeStack.Push(doLoopStatement.Condition);
			doLoopStatement.Condition.AcceptVisitor(this, data);
			doLoopStatement.Condition = ((Expression)(nodeStack.Pop()));
			nodeStack.Push(doLoopStatement.EmbeddedStatement);
			doLoopStatement.EmbeddedStatement.AcceptVisitor(this, data);
			doLoopStatement.EmbeddedStatement = ((Statement)(nodeStack.Pop()));
			return null;
		}
		public virtual object VisitDoLoopStatement(DoLoopStatement doLoopStatement, object data) {
			throw new global::System.NotImplementedException("DoLoopStatement");
		}
示例#4
0
	void DoLoopStatement(out Statement statement) {
		Expression expr = null; Statement embeddedStatement; statement = null;
		Expect(108);
		ConditionType conditionType = ConditionType.None;
		if (la.kind == 224 || la.kind == 231) {
			WhileOrUntil(out conditionType);
			Expr(out expr);
			EndOfStmt();
			Block(out embeddedStatement);
			Expect(152);
			statement = new DoLoopStatement(expr, 
				                                embeddedStatement, 
				                                conditionType == ConditionType.While ? ConditionType.DoWhile : conditionType, 
				                                ConditionPosition.Start);

		} else if (la.kind == 1 || la.kind == 21) {
			EndOfStmt();
			Block(out embeddedStatement);
			Expect(152);
			if (la.kind == 224 || la.kind == 231) {
				WhileOrUntil(out conditionType);
				Expr(out expr);
			}
			statement = new DoLoopStatement(expr, embeddedStatement, conditionType, ConditionPosition.End);
		} else SynErr(308);
	}
示例#5
0
	void WhileStatement(out Statement statement) {
		Expression expr = null; Statement embeddedStatement;
		Expect(231);
		Expr(out expr);
		EndOfStmt();
		Block(out embeddedStatement);
		Expect(113);
		Expect(231);
		statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.Start);
	}
		public virtual object TrackedVisitDoLoopStatement(DoLoopStatement doLoopStatement, object data) {
			return base.VisitDoLoopStatement(doLoopStatement, data);
		}
		public sealed override object VisitDoLoopStatement(DoLoopStatement doLoopStatement, object data) {
			this.BeginVisit(doLoopStatement);
			object result = this.TrackedVisitDoLoopStatement(doLoopStatement, data);
			this.EndVisit(doLoopStatement);
			return result;
		}
		// RG:
		public override object VisitDoLoopStatement(DoLoopStatement doLoopStatement, object data)
		{
			CodeIterationStatement forLoop = new CodeIterationStatement();
			breakableStack.Push(new Breakable());

			codeStack.Push(NullStmtCollection);

			if (doLoopStatement.ConditionPosition == ConditionPosition.End)
			{
				// do { } while (expr);
				//
				// emulate with:
				//  for (bool _do = true; _do; _do = expr) {}
				//
				doId++;
				string name = "_do" + doId;

				forLoop.InitStatement = new CodeVariableDeclarationStatement(typeof(System.Boolean), name, new CodePrimitiveExpression(true));
				forLoop.TestExpression = new CodeVariableReferenceExpression(name);

				forLoop.IncrementStatement = new CodeAssignStatement(new CodeVariableReferenceExpression(name),
				                                                     doLoopStatement.Condition == null ? new CodePrimitiveExpression(true) : (CodeExpression)doLoopStatement.Condition.AcceptVisitor(this, data));
			}
			else
			{
				// while (expr) {}
				//
				// emulate with:
				//  for (; expr;) {}
				//

				// Empty Init and Increment Statements
				forLoop.InitStatement = new CodeExpressionStatement(new CodeSnippetExpression());
				forLoop.IncrementStatement = new CodeExpressionStatement(new CodeSnippetExpression());

				if (doLoopStatement.Condition == null)
				{
					forLoop.TestExpression = new CodePrimitiveExpression(true);
				}
				else
				{
					forLoop.TestExpression = (CodeExpression)doLoopStatement.Condition.AcceptVisitor(this, data);
				}
			}

			codeStack.Pop();

			codeStack.Push(forLoop.Statements);
			doLoopStatement.EmbeddedStatement.AcceptVisitor(this, data);
			codeStack.Pop();

			if (forLoop.Statements.Count == 0)
			{
				forLoop.Statements.Add(new CodeSnippetStatement());
			}

			Breakable breakable = breakableStack.Pop();

			if (breakable.IsContinue)
			{
				forLoop.Statements.Add(new CodeSnippetStatement());
				forLoop.Statements.Add(new CodeLabeledStatement("continue" + breakable.Id, new CodeExpressionStatement(new CodeSnippetExpression())));
			}

			AddStmt(forLoop);

			if (breakable.IsBreak)
			{
				AddStmt(new CodeLabeledStatement("break" + breakable.Id, new CodeExpressionStatement(new CodeSnippetExpression())));
			}

			return forLoop;
		}