public void Visit(SwitchStatement expression) { throw new System.NotImplementedException(); }
public void Visit(SwitchStatement statement) { CurrentStatement = statement.Expression; //statement.Expression.Accept(this); //JsInstance caseValue = Result; bool found = false; foreach (var clause in statement.CaseClauses) { CurrentStatement = clause.Expression; //clause.Expression.Accept(this); new BinaryExpression(BinaryExpressionType.Equal, (Expression)statement.Expression, clause.Expression).Accept(this); if (Result.ToBoolean()) { clause.Statements.Accept(this); found = true; break; } } if (!found) { statement.DefaultStatements.Accept(this); } }
public void Visit(SwitchStatement statement) { CurrentStatement = statement.Expression; bool found = false; if (statement.CaseClauses != null) { foreach (var clause in statement.CaseClauses) { CurrentStatement = clause.Expression; if (found) { // jumping from one case to the next one clause.Statements.Accept(this); if (exit) break; } else { new BinaryExpression(BinaryExpressionType.Equal, (Expression)statement.Expression, clause.Expression).Accept(this); if (Result.ToBoolean()) { clause.Statements.Accept(this); found = true; if (exit) break; } } if (breakStatement != null) { breakStatement = null; break; } } } if (!found && statement.DefaultStatements!= null) { statement.DefaultStatements.Accept(this); // handle break statements in default case by clearing it if (breakStatement != null) { breakStatement = null; } } }
void Analyze(SwitchStatement Stmt) { SetCurrentLineAndCharNos(Stmt); if (Stmt.CaseClauses != null) { for (int i = 0; i < Stmt.CaseClauses.Count; i++) { if (Stmt.CaseClauses[i] != null) Analyze(Stmt.CaseClauses[i]); } } if (Stmt.DefaultStatements != null) Analyze(Stmt.DefaultStatements); if (Stmt.Expression != null) Analyze(Stmt.Expression); }