1447 //where |
1447 //where |
1448 JCExpression loadFreevar(DiagnosticPosition pos, VarSymbol v) { |
1448 JCExpression loadFreevar(DiagnosticPosition pos, VarSymbol v) { |
1449 return access(v, make.at(pos).Ident(v), null, false); |
1449 return access(v, make.at(pos).Ident(v), null, false); |
1450 } |
1450 } |
1451 |
1451 |
1452 /** Construct a tree simulating the expression <C.this>. |
1452 /** Construct a tree simulating the expression {@code C.this}. |
1453 * @param pos The source code position to be used for the tree. |
1453 * @param pos The source code position to be used for the tree. |
1454 * @param c The qualifier class. |
1454 * @param c The qualifier class. |
1455 */ |
1455 */ |
1456 JCExpression makeThis(DiagnosticPosition pos, TypeSymbol c) { |
1456 JCExpression makeThis(DiagnosticPosition pos, TypeSymbol c) { |
1457 if (currentClass == c) { |
1457 if (currentClass == c) { |
1621 private JCExpression makeNonNullCheck(JCExpression expression) { |
1621 private JCExpression makeNonNullCheck(JCExpression expression) { |
1622 return makeBinary(NE, expression, makeNull()); |
1622 return makeBinary(NE, expression, makeNull()); |
1623 } |
1623 } |
1624 |
1624 |
1625 /** Construct a tree that represents the outer instance |
1625 /** Construct a tree that represents the outer instance |
1626 * <C.this>. Never pick the current `this'. |
1626 * {@code C.this}. Never pick the current `this'. |
1627 * @param pos The source code position to be used for the tree. |
1627 * @param pos The source code position to be used for the tree. |
1628 * @param c The qualifier class. |
1628 * @param c The qualifier class. |
1629 */ |
1629 */ |
1630 JCExpression makeOuterThis(DiagnosticPosition pos, TypeSymbol c) { |
1630 JCExpression makeOuterThis(DiagnosticPosition pos, TypeSymbol c) { |
1631 List<VarSymbol> ots = outerThisStack; |
1631 List<VarSymbol> ots = outerThisStack; |
1659 } |
1659 } |
1660 return tree; |
1660 return tree; |
1661 } |
1661 } |
1662 |
1662 |
1663 /** Construct a tree that represents the closest outer instance |
1663 /** Construct a tree that represents the closest outer instance |
1664 * <C.this> such that the given symbol is a member of C. |
1664 * {@code C.this} such that the given symbol is a member of C. |
1665 * @param pos The source code position to be used for the tree. |
1665 * @param pos The source code position to be used for the tree. |
1666 * @param sym The accessed symbol. |
1666 * @param sym The accessed symbol. |
1667 * @param preciseMatch should we accept a type that is a subtype of |
1667 * @param preciseMatch should we accept a type that is a subtype of |
1668 * sym's owner, even if it doesn't contain sym |
1668 * sym's owner, even if it doesn't contain sym |
1669 * due to hiding, overriding, or non-inheritance |
1669 * due to hiding, overriding, or non-inheritance |
1711 otc = ot.type.tsym; |
1711 otc = ot.type.tsym; |
1712 } |
1712 } |
1713 return tree; |
1713 return tree; |
1714 } |
1714 } |
1715 |
1715 |
1716 /** Return tree simulating the assignment <this.name = name>, where |
1716 /** Return tree simulating the assignment {@code this.name = name}, where |
1717 * name is the name of a free variable. |
1717 * name is the name of a free variable. |
1718 */ |
1718 */ |
1719 JCStatement initField(int pos, Name name) { |
1719 JCStatement initField(int pos, Name name) { |
1720 Scope.Entry e = proxies.lookup(name); |
1720 Scope.Entry e = proxies.lookup(name); |
1721 Symbol rhs = e.sym; |
1721 Symbol rhs = e.sym; |
1728 make.Assign( |
1728 make.Assign( |
1729 make.Select(make.This(lhs.owner.erasure(types)), lhs), |
1729 make.Select(make.This(lhs.owner.erasure(types)), lhs), |
1730 make.Ident(rhs)).setType(lhs.erasure(types))); |
1730 make.Ident(rhs)).setType(lhs.erasure(types))); |
1731 } |
1731 } |
1732 |
1732 |
1733 /** Return tree simulating the assignment <this.this$n = this$n>. |
1733 /** Return tree simulating the assignment {@code this.this$n = this$n}. |
1734 */ |
1734 */ |
1735 JCStatement initOuterThis(int pos) { |
1735 JCStatement initOuterThis(int pos) { |
1736 VarSymbol rhs = outerThisStack.head; |
1736 VarSymbol rhs = outerThisStack.head; |
1737 Assert.check(rhs.owner.kind == MTH); |
1737 Assert.check(rhs.owner.kind == MTH); |
1738 VarSymbol lhs = outerThisStack.tail.head; |
1738 VarSymbol lhs = outerThisStack.tail.head; |
3192 * for ( T v : arrayexpr ) stmt; |
3192 * for ( T v : arrayexpr ) stmt; |
3193 * </pre> |
3193 * </pre> |
3194 * |
3194 * |
3195 * (where arrayexpr is of an array type) gets translated to |
3195 * (where arrayexpr is of an array type) gets translated to |
3196 * |
3196 * |
3197 * <pre> |
3197 * <pre>{@code |
3198 * for ( { arraytype #arr = arrayexpr; |
3198 * for ( { arraytype #arr = arrayexpr; |
3199 * int #len = array.length; |
3199 * int #len = array.length; |
3200 * int #i = 0; }; |
3200 * int #i = 0; }; |
3201 * #i < #len; i$++ ) { |
3201 * #i < #len; i$++ ) { |
3202 * T v = arr$[#i]; |
3202 * T v = arr$[#i]; |
3203 * stmt; |
3203 * stmt; |
3204 * } |
3204 * } |
3205 * </pre> |
3205 * }</pre> |
3206 * |
3206 * |
3207 * where #arr, #len, and #i are freshly named synthetic local variables. |
3207 * where #arr, #len, and #i are freshly named synthetic local variables. |
3208 */ |
3208 */ |
3209 private void visitArrayForeachLoop(JCEnhancedForLoop tree) { |
3209 private void visitArrayForeachLoop(JCEnhancedForLoop tree) { |
3210 make_at(tree.expr.pos()); |
3210 make_at(tree.expr.pos()); |
3270 * |
3270 * |
3271 * <pre> |
3271 * <pre> |
3272 * for ( T v : coll ) stmt ; |
3272 * for ( T v : coll ) stmt ; |
3273 * </pre> |
3273 * </pre> |
3274 * |
3274 * |
3275 * (where coll implements Iterable<? extends T>) gets translated to |
3275 * (where coll implements {@code Iterable<? extends T>}) gets translated to |
3276 * |
3276 * |
3277 * <pre> |
3277 * <pre>{@code |
3278 * for ( Iterator<? extends T> #i = coll.iterator(); #i.hasNext(); ) { |
3278 * for ( Iterator<? extends T> #i = coll.iterator(); #i.hasNext(); ) { |
3279 * T v = (T) #i.next(); |
3279 * T v = (T) #i.next(); |
3280 * stmt; |
3280 * stmt; |
3281 * } |
3281 * } |
3282 * </pre> |
3282 * }</pre> |
3283 * |
3283 * |
3284 * where #i is a freshly named synthetic local variable. |
3284 * where #i is a freshly named synthetic local variable. |
3285 */ |
3285 */ |
3286 private void visitIterableForeachLoop(JCEnhancedForLoop tree) { |
3286 private void visitIterableForeachLoop(JCEnhancedForLoop tree) { |
3287 make_at(tree.expr.pos()); |
3287 make_at(tree.expr.pos()); |