Package com.google.minijoe.compiler.ast

Examples of com.google.minijoe.compiler.ast.CaseStatement


          && nextToken != Token.OPERATOR_CLOSEBRACE) {
        caseStatements.addElement(parseStatement());
      }

      caseClauseVector.addElement(
          new CaseStatement(caseExpression, Util.vectorToStatementArray(caseStatements)));
    }

    readToken(Token.OPERATOR_CLOSEBRACE);

    CaseStatement[] caseClauseArray = new CaseStatement[caseClauseVector.size()];
View Full Code Here


    currentBreakStatement = statement;

    String defaultLabel = "break";

    for (int i = 0; i < statement.clauses.length; i++) {
      CaseStatement cs = statement.clauses[i];
      if (cs.expression == null) {
        defaultLabel = "case" + i;
      } else {
        writeOp(JsFunction.OP_DUP);
        cs.expression.visitExpression(this);
View Full Code Here

    );
    assertParserOutput(
        new SwitchStatement(
            new Identifier("something"),
            new CaseStatement[] {
              new CaseStatement(
                  null,
                  new Statement[] {
                      new ExpressionStatement(
                          new Identifier("foo")
                      )
                  }
              )
            }
        ),
        "switch (something) {default: foo;}"
    );
    assertParserOutput(
        new SwitchStatement(
            new Identifier("something"),
            new CaseStatement[] {
              new CaseStatement(
                  new NumberLiteral(0),
                  new Statement[] {
                    new ExpressionStatement(
                        new Identifier("bar")
                    )
                  }
              )
            }
        ),
        "switch (something) {case 0: bar;}"
    );
    assertParserOutput(
        new SwitchStatement(
            new Identifier("something"),
            new CaseStatement[] {
              new CaseStatement(
                  new NumberLiteral(0),
                  new Statement[] {
                    new ExpressionStatement(
                        new Identifier("bar")
                    )
                  }
              ),
              new CaseStatement(
                  new NumberLiteral(1),
                  new Statement[] {
                    new ExpressionStatement(
                        new Identifier("baz")
                    )
                  }
              )
            }
        ),
        "switch (something) {case 0: bar; case 1: baz;}"
    );
    assertParserOutput(
        new SwitchStatement(
            new Identifier("something"),
            new CaseStatement[] {
              new CaseStatement(
                  null,
                  new Statement[] {
                      new ExpressionStatement(
                          new Identifier("foo")
                      )
                  }
              ),
              new CaseStatement(
                  new NumberLiteral(0),
                  new Statement[] {
                    new ExpressionStatement(
                        new Identifier("bar")
                    )
                  }
              ),
              new CaseStatement(
                  new NumberLiteral(1),
                  new Statement[] {
                    new ExpressionStatement(
                        new Identifier("baz")
                    )
                  }
              )
            }
        ),
        "switch (something) {default: foo; case 0: bar; case 1: baz;}"
    );
    assertParserOutput(
        new SwitchStatement(
            new Identifier("something"),
            new CaseStatement[] {
              new CaseStatement(
                  new NumberLiteral(0),
                  new Statement[] {
                    new ExpressionStatement(
                        new Identifier("bar")
                    )
                  }
              ),
              new CaseStatement(
                  null,
                  new Statement[] {
                      new ExpressionStatement(
                          new Identifier("foo")
                      )
                  }
              ),
              new CaseStatement(
                  new NumberLiteral(1),
                  new Statement[] {
                    new ExpressionStatement(
                        new Identifier("baz")
                    )
                  }
              )
            }
        ),
        "switch (something) {case 0: bar; default: foo; case 1: baz;}"
    );
    assertParserOutput(
        new SwitchStatement(
            new Identifier("something"),
            new CaseStatement[] {
              new CaseStatement(
                  new NumberLiteral(0),
                  new Statement[] {
                    new ExpressionStatement(
                        new Identifier("bar")
                    )
                  }
              ),
              new CaseStatement(
                  new NumberLiteral(1),
                  new Statement[] {
                    new ExpressionStatement(
                        new Identifier("baz")
                    )
                  }
              ),
              new CaseStatement(
                  null,
                  new Statement[] {
                      new ExpressionStatement(
                          new Identifier("foo")
                      )
View Full Code Here

TOP

Related Classes of com.google.minijoe.compiler.ast.CaseStatement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.