< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java

Print this page

        

*** 32,41 **** --- 32,42 ---- import com.sun.source.tree.CaseTree.CaseKind; import com.sun.tools.javac.code.*; import com.sun.tools.javac.code.Kinds.KindSelector; import com.sun.tools.javac.code.Scope.WriteableScope; + import com.sun.tools.javac.code.Source.Feature; import com.sun.tools.javac.jvm.*; import com.sun.tools.javac.main.Option.PkgInfo; import com.sun.tools.javac.resources.CompilerProperties.Fragments; import com.sun.tools.javac.tree.*; import com.sun.tools.javac.util.*;
*** 879,888 **** --- 880,892 ---- if (enclOp == null) return AccessCode.DEREF.code; else if (enclOp.hasTag(ASSIGN) && tree == TreeInfo.skipParens(((JCAssign) enclOp).lhs)) return AccessCode.ASSIGN.code; + else if (enclOp.hasTag(WITHFIELD) && + tree == TreeInfo.skipParens(((JCWithField) enclOp).field)) + return AccessCode.WITHFIELD.code; else if ((enclOp.getTag().isIncOrDecUnaryOp() || enclOp.getTag().isAssignop()) && tree == TreeInfo.skipParens(((JCOperatorExpression) enclOp).getOperand(LEFT))) return (((JCOperatorExpression) enclOp).operator).getAccessCode(enclOp.getTag()); else return AccessCode.DEREF.code;
*** 989,1003 **** OperatorSymbol operator = binaryAccessOperator(acode, enclOp.getTag()); if (operator.opcode == string_add) argtypes = List.of(syms.objectType); else argtypes = operator.type.getParameterTypes().tail; ! } else if (acode == AccessCode.ASSIGN.code) argtypes = List.of(vsym.erasure(types)); else argtypes = List.nil(); ! restype = vsym.erasure(types); thrown = List.nil(); break; case MTH: acode = AccessCode.DEREF.code; argtypes = vsym.erasure(types).getParameterTypes(); --- 993,1007 ---- OperatorSymbol operator = binaryAccessOperator(acode, enclOp.getTag()); if (operator.opcode == string_add) argtypes = List.of(syms.objectType); else argtypes = operator.type.getParameterTypes().tail; ! } else if (acode == AccessCode.ASSIGN.code || acode == AccessCode.WITHFIELD.code) argtypes = List.of(vsym.erasure(types)); else argtypes = List.nil(); ! restype = acode == AccessCode.WITHFIELD.code ? vsym.owner.erasure(types) : vsym.erasure(types); thrown = List.nil(); break; case MTH: acode = AccessCode.DEREF.code; argtypes = vsym.erasure(types).getParameterTypes();
*** 1362,1377 **** expr = make.Assign(ref, args.head); break; case PREINC: case POSTINC: case PREDEC: case POSTDEC: expr = makeUnary(aCode.tag, ref); break; default: expr = make.Assignop( treeTag(binaryAccessOperator(acode1, JCTree.Tag.NO_TAG)), ref, args.head); ((JCAssignOp) expr).operator = binaryAccessOperator(acode1, JCTree.Tag.NO_TAG); } ! stat = make.Return(expr.setType(sym.type)); } else { stat = make.Call(make.App(ref, args)); } md.body = make.Block(0, List.of(stat)); --- 1366,1384 ---- expr = make.Assign(ref, args.head); break; case PREINC: case POSTINC: case PREDEC: case POSTDEC: expr = makeUnary(aCode.tag, ref); break; + case WITHFIELD: + expr = make.WithField(ref, args.head); + break; default: expr = make.Assignop( treeTag(binaryAccessOperator(acode1, JCTree.Tag.NO_TAG)), ref, args.head); ((JCAssignOp) expr).operator = binaryAccessOperator(acode1, JCTree.Tag.NO_TAG); } ! stat = make.Return(expr.setType(aCode == AccessCode.WITHFIELD ? sym.owner.type : sym.type)); } else { stat = make.Call(make.App(ref, args)); } md.body = make.Block(0, List.of(stat));
*** 1461,1472 **** int index = 0; Name proxyName; do { proxyName = proxyName(v.name, index++); } while (!proxyNames.add(proxyName)); VarSymbol proxy = new VarSymbol( ! flags, proxyName, v.erasure(types), owner); proxies.put(v, proxy); JCVariableDecl vd = make.at(pos).VarDef(proxy, null); vd.vartype = access(vd.vartype); defs = defs.prepend(vd); } --- 1468,1480 ---- int index = 0; Name proxyName; do { proxyName = proxyName(v.name, index++); } while (!proxyNames.add(proxyName)); + final Type type = v.erasure(types); VarSymbol proxy = new VarSymbol( ! flags, proxyName, type, owner); proxies.put(v, proxy); JCVariableDecl vd = make.at(pos).VarDef(proxy, null); vd.vartype = access(vd.vartype); defs = defs.prepend(vd); }
*** 1525,1535 **** /** Definition for this$n field. * @param pos The source code position of the definition. * @param owner The class in which the definition goes. */ JCVariableDecl outerThisDef(int pos, ClassSymbol owner) { ! VarSymbol outerThis = makeOuterThisVarSymbol(owner, FINAL | SYNTHETIC); return makeOuterThisVarDecl(pos, outerThis); } /** Return a list of trees that load the free variables in given list, * in reverse order. --- 1533,1545 ---- /** Definition for this$n field. * @param pos The source code position of the definition. * @param owner The class in which the definition goes. */ JCVariableDecl outerThisDef(int pos, ClassSymbol owner) { ! Type target = types.erasure(owner.enclClass().type.getEnclosingType()); ! long flags = FINAL | SYNTHETIC; ! VarSymbol outerThis = makeOuterThisVarSymbol(owner, flags); return makeOuterThisVarDecl(pos, outerThis); } /** Return a list of trees that load the free variables in given list, * in reverse order.
*** 3345,3354 **** --- 3355,3381 ---- tree.cond = translate(tree.cond, syms.booleanType); tree.body = translate(tree.body); result = tree; } + public void visitWithField(JCWithField tree) { + Type fieldType = tree.field.type; + tree.field = translate(tree.field, tree); + tree.value = translate(tree.value, fieldType); // important to use pre-translation type. + + // If translated field is an Apply, we are + // seeing an access method invocation. In this case, append + // right hand side as last argument of the access method. + if (tree.field.hasTag(APPLY)) { + JCMethodInvocation app = (JCMethodInvocation) tree.field; + app.args = List.of(tree.value).prependList(app.args); + result = app; + } else { + result = tree; + } + } + public void visitForLoop(JCForLoop tree) { tree.init = translate(tree.init); if (tree.cond != null) tree.cond = translate(tree.cond, syms.booleanType); tree.step = translate(tree.step);
< prev index next >