Skip to content

Commit

Permalink
Replace "yield for" with "yield all". The former phraseology seems to…
Browse files Browse the repository at this point in the history
… derive exclusively from an odd choice made by the implementors of Traceur. "Yield all" is much less confusing.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=162662164
  • Loading branch information
shicks authored and blickly committed Jul 21, 2017
1 parent 7359160 commit fac78d5
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/com/google/javascript/jscomp/CodeGenerator.java
Expand Up @@ -872,7 +872,7 @@ protected void add(Node n, Context context) {


case YIELD: case YIELD:
add("yield"); add("yield");
if (n.isYieldFor()) { if (n.isYieldAll()) {
checkNotNull(first); checkNotNull(first);
add("*"); add("*");
} }
Expand Down
6 changes: 3 additions & 3 deletions src/com/google/javascript/jscomp/Es6RewriteGenerators.java
Expand Up @@ -133,8 +133,8 @@ public void visit(NodeTraversal t, Node n, Node parent) {
} }
break; break;
case YIELD: case YIELD:
if (n.isYieldFor()) { if (n.isYieldAll()) {
visitYieldFor(t, n, parent); visitYieldAll(t, n, parent);
} else if (!parent.isExprResult()) { } else if (!parent.isExprResult()) {
visitYieldExpr(t, n, parent); visitYieldExpr(t, n, parent);
} else { } else {
Expand Down Expand Up @@ -176,7 +176,7 @@ private void visitYieldThrows(NodeTraversal t, Node n, Node parent) {
* var i = $jscomp$generator$yield$entry.value; * var i = $jscomp$generator$yield$entry.value;
* </pre> * </pre>
*/ */
private void visitYieldFor(NodeTraversal t, Node n, Node parent) { private void visitYieldAll(NodeTraversal t, Node n, Node parent) {
Node enclosingStatement = NodeUtil.getEnclosingStatement(n); Node enclosingStatement = NodeUtil.getEnclosingStatement(n);
Node generator = IR.var( Node generator = IR.var(
IR.name(GENERATOR_YIELD_ALL_NAME), IR.name(GENERATOR_YIELD_ALL_NAME),
Expand Down
2 changes: 1 addition & 1 deletion src/com/google/javascript/jscomp/parsing/IRFactory.java
Expand Up @@ -2192,7 +2192,7 @@ Node processYield(YieldExpressionTree tree) {
if (tree.expression != null) { if (tree.expression != null) {
yield.addChildToBack(transform(tree.expression)); yield.addChildToBack(transform(tree.expression));
} }
yield.setYieldFor(tree.isYieldFor); yield.setYieldAll(tree.isYieldAll);
return yield; return yield;
} }


Expand Down
8 changes: 4 additions & 4 deletions src/com/google/javascript/jscomp/parsing/parser/Parser.java
Expand Up @@ -3048,18 +3048,18 @@ private boolean inGeneratorContext() {
private ParseTree parseYield(Expression expressionIn) { private ParseTree parseYield(Expression expressionIn) {
SourcePosition start = getTreeStartLocation(); SourcePosition start = getTreeStartLocation();
eat(TokenType.YIELD); eat(TokenType.YIELD);
boolean isYieldFor = false; boolean isYieldAll = false;
ParseTree expression = null; ParseTree expression = null;
if (!peekImplicitSemiColon()) { if (!peekImplicitSemiColon()) {
isYieldFor = eatOpt(TokenType.STAR) != null; isYieldAll = eatOpt(TokenType.STAR) != null;
if (peekAssignmentExpression()) { if (peekAssignmentExpression()) {
expression = parseAssignment(expressionIn); expression = parseAssignment(expressionIn);
} else if (isYieldFor) { } else if (isYieldAll) {
reportError("yield* requires an expression"); reportError("yield* requires an expression");
} }
} }
return new YieldExpressionTree( return new YieldExpressionTree(
getTreeLocation(start), isYieldFor, expression); getTreeLocation(start), isYieldAll, expression);
} }


// 11.12 Conditional Expression // 11.12 Conditional Expression
Expand Down
Expand Up @@ -21,12 +21,12 @@
public class YieldExpressionTree extends ParseTree { public class YieldExpressionTree extends ParseTree {


public final ParseTree expression; public final ParseTree expression;
public final boolean isYieldFor; public final boolean isYieldAll;


public YieldExpressionTree( public YieldExpressionTree(
SourceRange location, boolean isYieldFor, ParseTree expression) { SourceRange location, boolean isYieldAll, ParseTree expression) {
super(ParseTreeType.YIELD_EXPRESSION, location); super(ParseTreeType.YIELD_EXPRESSION, location);
this.isYieldFor = isYieldFor; this.isYieldAll = isYieldAll;
this.expression = expression; this.expression = expression;
} }
} }
12 changes: 6 additions & 6 deletions src/com/google/javascript/rhino/Node.java
Expand Up @@ -108,7 +108,7 @@ public class Node implements Serializable {
// member method. // member method.
ARROW_FN = 60, ARROW_FN = 60,
ASYNC_FN = 61, // http://tc39.github.io/ecmascript-asyncawait/ ASYNC_FN = 61, // http://tc39.github.io/ecmascript-asyncawait/
YIELD_FOR = 62, // Set if a yield is a "yield all" YIELD_ALL = 62, // Set if a yield is a "yield all"
EXPORT_DEFAULT = 63, // Set if a export is a "default" export EXPORT_DEFAULT = 63, // Set if a export is a "default" export
EXPORT_ALL_FROM = 64, // Set if an export is a "*" EXPORT_ALL_FROM = 64, // Set if an export is a "*"
IS_CONSTANT_VAR = 65, // A lexical variable is inferred const IS_CONSTANT_VAR = 65, // A lexical variable is inferred const
Expand Down Expand Up @@ -191,7 +191,7 @@ private static final String propToString(byte propType) {
case GENERATOR_FN: return "generator_fn"; case GENERATOR_FN: return "generator_fn";
case ARROW_FN: return "arrow_fn"; case ARROW_FN: return "arrow_fn";
case ASYNC_FN: return "async_fn"; case ASYNC_FN: return "async_fn";
case YIELD_FOR: return "yield_for"; case YIELD_ALL: return "yield_all";
case EXPORT_DEFAULT: return "export_default"; case EXPORT_DEFAULT: return "export_default";
case EXPORT_ALL_FROM: return "export_all_from"; case EXPORT_ALL_FROM: return "export_all_from";
case IS_CONSTANT_VAR: return "is_constant_var"; case IS_CONSTANT_VAR: return "is_constant_var";
Expand Down Expand Up @@ -2607,17 +2607,17 @@ public boolean isAsyncFunction() {
* method is meaningful only on {@link Token#FUNCTION} or * method is meaningful only on {@link Token#FUNCTION} or
* {@link Token#MEMBER_FUNCTION_DEF} nodes. * {@link Token#MEMBER_FUNCTION_DEF} nodes.
*/ */
public void setYieldFor(boolean isGenerator) { public void setYieldAll(boolean isGenerator) {
putBooleanProp(YIELD_FOR, isGenerator); putBooleanProp(YIELD_ALL, isGenerator);
} }


/** /**
* Returns whether this node is a generator node. This * Returns whether this node is a generator node. This
* method is meaningful only on {@link Token#FUNCTION} or * method is meaningful only on {@link Token#FUNCTION} or
* {@link Token#MEMBER_FUNCTION_DEF} nodes. * {@link Token#MEMBER_FUNCTION_DEF} nodes.
*/ */
public boolean isYieldFor() { public boolean isYieldAll() {
return getBooleanProp(YIELD_FOR); return getBooleanProp(YIELD_ALL);
} }


// There are four values of interest: // There are four values of interest:
Expand Down

0 comments on commit fac78d5

Please sign in to comment.