Inheritance: Statement, IForStatement
Beispiel #1
0
        public void Visit(ForStatement statement)
        {
            if (statement.InitialisationStatement != null)
                statement.InitialisationStatement.Accept(this);

            if (statement.ConditionExpression != null)
                statement.ConditionExpression.Accept(this);
            else
                Result = Global.BooleanClass.New(true);

            EnsureIdentifierIsDefined(Result);

            while (Result.ToBoolean()) {
                statement.Statement.Accept(this);

                ResetContinueIfPresent(statement.Label);

                if (StopStatementFlow()) {
                    if (breakStatement != null && statement.Label == breakStatement.Label) {
                        breakStatement = null;
                    }

                    return;
                }

                // Goes back in the scopes so that the variables are accessible after the statement
                if (statement.IncrementExpression != null)
                    statement.IncrementExpression.Accept(this);

                if (statement.ConditionExpression != null)
                    statement.ConditionExpression.Accept(this);
                else
                    Result = Global.BooleanClass.New(true);

            }
        }
Beispiel #2
0
		public void Visit(ForStatement expression)
		{
			Builder.Append("for (");
			expression.InitialisationStatement.Accept(this);
			Builder.Append("; ");
			expression.ConditionExpression.Accept(this);
			Builder.Append("; ");
			expression.IncrementExpression.Accept(this);
			Builder.AppendLine(") {");
			indent++;
			Indent();
			expression.Statement.Accept(this);
			indent--;
			Indent();
			Builder.AppendLine("}");

		}
Beispiel #3
0
 void Analyze(ForStatement Stmt)
 {
     SetCurrentLineAndCharNos(Stmt);
     if (Stmt.ConditionExpression != null) Analyze(Stmt.ConditionExpression);
     if (Stmt.IncrementExpression != null) Analyze(Stmt.IncrementExpression);
     if (Stmt.InitialisationStatement != null) Analyze(Stmt.InitialisationStatement);
     if (Stmt.Statement != null) Analyze(Stmt.Statement);
 }