--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java Sun Jun 09 15:48:57 2019 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java Mon Jun 10 05:09:52 2019 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -187,6 +187,10 @@
*/
BREAK,
+ /** Yield statements, of type Yield.
+ */
+ YIELD,
+
/** Continue statements, of type Continue.
*/
CONTINUE,
@@ -1551,10 +1555,10 @@
* A break from a loop or switch.
*/
public static class JCBreak extends JCStatement implements BreakTree {
- public JCExpression value;
+ public Name label;
public JCTree target;
- protected JCBreak(JCExpression value, JCTree target) {
- this.value = value;
+ protected JCBreak(Name label, JCTree target) {
+ this.label = label;
this.target = target;
}
@Override
@@ -1567,11 +1571,8 @@
public Kind getKind() { return Kind.BREAK; }
@DefinedBy(Api.COMPILER_TREE)
public Name getLabel() {
- return value != null && value.getKind() == Kind.IDENTIFIER ? ((JCIdent) value).getName() : null;
+ return label;
}
- @DefinedBy(Api.COMPILER_TREE)
- @SuppressWarnings("removal")
- public JCExpression getValue() { return value; }
@Override @DefinedBy(Api.COMPILER_TREE)
public <R,D> R accept(TreeVisitor<R,D> v, D d) {
return v.visitBreak(this, d);
@@ -1583,6 +1584,33 @@
}
/**
+ * A break-with from a switch expression.
+ */
+ @SuppressWarnings("removal")
+ public static class JCYield extends JCStatement implements YieldTree {
+ public JCExpression value;
+ public JCTree target;
+ protected JCYield(JCExpression value, JCTree target) {
+ this.value = value;
+ this.target = target;
+ }
+ @Override
+ public void accept(Visitor v) { v.visitYield(this); }
+ @DefinedBy(Api.COMPILER_TREE)
+ public Kind getKind() { return Kind.YIELD; }
+ @DefinedBy(Api.COMPILER_TREE)
+ public JCExpression getValue() { return value; }
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public <R,D> R accept(TreeVisitor<R,D> v, D d) {
+ return v.visitYield(this, d);
+ }
+ @Override
+ public Tag getTag() {
+ return YIELD;
+ }
+ }
+
+ /**
* A continue of a loop.
*/
public static class JCContinue extends JCStatement implements ContinueTree {
@@ -3091,7 +3119,8 @@
JCExpression elsepart);
JCIf If(JCExpression cond, JCStatement thenpart, JCStatement elsepart);
JCExpressionStatement Exec(JCExpression expr);
- JCBreak Break(JCExpression value);
+ JCBreak Break(Name label);
+ JCYield Yield(JCExpression value);
JCContinue Continue(Name label);
JCReturn Return(JCExpression expr);
JCThrow Throw(JCExpression expr);
@@ -3162,6 +3191,7 @@
public void visitIf(JCIf that) { visitTree(that); }
public void visitExec(JCExpressionStatement that) { visitTree(that); }
public void visitBreak(JCBreak that) { visitTree(that); }
+ public void visitYield(JCYield that) { visitTree(that); }
public void visitContinue(JCContinue that) { visitTree(that); }
public void visitReturn(JCReturn that) { visitTree(that); }
public void visitThrow(JCThrow that) { visitTree(that); }