langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java
changeset 15720 e61b2f7a5148
parent 15712 fa256e8cfe33
child 16325 088a91896245
equal deleted inserted replaced
15719:6b64cf96346b 15720:e61b2f7a5148
  1443         while (owner.kind == TYP && ((ClassSymbol)owner).members().lookup(result).scope != null)
  1443         while (owner.kind == TYP && ((ClassSymbol)owner).members().lookup(result).scope != null)
  1444             result = names.fromString(result.toString() + target.syntheticNameChar());
  1444             result = names.fromString(result.toString() + target.syntheticNameChar());
  1445         return result;
  1445         return result;
  1446     }
  1446     }
  1447 
  1447 
  1448     /** Definition for this$n field.
  1448     private VarSymbol makeOuterThisVarSymbol(Symbol owner, long flags) {
  1449      *  @param pos        The source code position of the definition.
       
  1450      *  @param owner      The class in which the definition goes.
       
  1451      */
       
  1452     JCVariableDecl outerThisDef(int pos, Symbol owner) {
       
  1453         long flags = FINAL | SYNTHETIC;
       
  1454         if (owner.kind == TYP &&
  1449         if (owner.kind == TYP &&
  1455             target.usePrivateSyntheticFields())
  1450             target.usePrivateSyntheticFields())
  1456             flags |= PRIVATE;
  1451             flags |= PRIVATE;
  1457         Type target = types.erasure(owner.enclClass().type.getEnclosingType());
  1452         Type target = types.erasure(owner.enclClass().type.getEnclosingType());
  1458         VarSymbol outerThis = new VarSymbol(
  1453         VarSymbol outerThis =
  1459             flags, outerThisName(target, owner), target, owner);
  1454             new VarSymbol(flags, outerThisName(target, owner), target, owner);
  1460         outerThisStack = outerThisStack.prepend(outerThis);
  1455         outerThisStack = outerThisStack.prepend(outerThis);
  1461         JCVariableDecl vd = make.at(pos).VarDef(outerThis, null);
  1456         return outerThis;
       
  1457     }
       
  1458 
       
  1459     private JCVariableDecl makeOuterThisVarDecl(int pos, VarSymbol sym) {
       
  1460         JCVariableDecl vd = make.at(pos).VarDef(sym, null);
  1462         vd.vartype = access(vd.vartype);
  1461         vd.vartype = access(vd.vartype);
  1463         return vd;
  1462         return vd;
       
  1463     }
       
  1464 
       
  1465     /** Definition for this$n field.
       
  1466      *  @param pos        The source code position of the definition.
       
  1467      *  @param owner      The method in which the definition goes.
       
  1468      */
       
  1469     JCVariableDecl outerThisDef(int pos, MethodSymbol owner) {
       
  1470         ClassSymbol c = owner.enclClass();
       
  1471         boolean isMandated =
       
  1472             // Anonymous constructors
       
  1473             (owner.isConstructor() && owner.isAnonymous()) ||
       
  1474             // Constructors of non-private inner member classes
       
  1475             (owner.isConstructor() && c.isInner() &&
       
  1476              !c.isPrivate() && !c.isStatic());
       
  1477         long flags =
       
  1478             FINAL | (isMandated ? MANDATED : SYNTHETIC);
       
  1479         VarSymbol outerThis = makeOuterThisVarSymbol(owner, flags);
       
  1480         owner.extraParams = owner.extraParams.prepend(outerThis);
       
  1481         return makeOuterThisVarDecl(pos, outerThis);
       
  1482     }
       
  1483 
       
  1484     /** Definition for this$n field.
       
  1485      *  @param pos        The source code position of the definition.
       
  1486      *  @param owner      The class in which the definition goes.
       
  1487      */
       
  1488     JCVariableDecl outerThisDef(int pos, ClassSymbol owner) {
       
  1489         VarSymbol outerThis = makeOuterThisVarSymbol(owner, FINAL | SYNTHETIC);
       
  1490         return makeOuterThisVarDecl(pos, outerThis);
  1464     }
  1491     }
  1465 
  1492 
  1466     /** Return a list of trees that load the free variables in given list,
  1493     /** Return a list of trees that load the free variables in given list,
  1467      *  in reverse order.
  1494      *  in reverse order.
  1468      *  @param pos          The source code position to be used for the trees.
  1495      *  @param pos          The source code position to be used for the trees.
  2566             JCVariableDecl nameParam = make_at(tree.pos()).
  2593             JCVariableDecl nameParam = make_at(tree.pos()).
  2567                 Param(names.fromString(target.syntheticNameChar() +
  2594                 Param(names.fromString(target.syntheticNameChar() +
  2568                                        "enum" + target.syntheticNameChar() + "name"),
  2595                                        "enum" + target.syntheticNameChar() + "name"),
  2569                       syms.stringType, tree.sym);
  2596                       syms.stringType, tree.sym);
  2570             nameParam.mods.flags |= SYNTHETIC; nameParam.sym.flags_field |= SYNTHETIC;
  2597             nameParam.mods.flags |= SYNTHETIC; nameParam.sym.flags_field |= SYNTHETIC;
  2571 
       
  2572             JCVariableDecl ordParam = make.
  2598             JCVariableDecl ordParam = make.
  2573                 Param(names.fromString(target.syntheticNameChar() +
  2599                 Param(names.fromString(target.syntheticNameChar() +
  2574                                        "enum" + target.syntheticNameChar() +
  2600                                        "enum" + target.syntheticNameChar() +
  2575                                        "ordinal"),
  2601                                        "ordinal"),
  2576                       syms.intType, tree.sym);
  2602                       syms.intType, tree.sym);
  2577             ordParam.mods.flags |= SYNTHETIC; ordParam.sym.flags_field |= SYNTHETIC;
  2603             ordParam.mods.flags |= SYNTHETIC; ordParam.sym.flags_field |= SYNTHETIC;
  2578 
  2604 
  2579             tree.params = tree.params.prepend(ordParam).prepend(nameParam);
  2605             tree.params = tree.params.prepend(ordParam).prepend(nameParam);
  2580 
  2606 
  2581             MethodSymbol m = tree.sym;
  2607             MethodSymbol m = tree.sym;
       
  2608             m.extraParams = m.extraParams.prepend(ordParam.sym);
       
  2609             m.extraParams = m.extraParams.prepend(nameParam.sym);
  2582             Type olderasure = m.erasure(types);
  2610             Type olderasure = m.erasure(types);
  2583             m.erasure_field = new MethodType(
  2611             m.erasure_field = new MethodType(
  2584                 olderasure.getParameterTypes().prepend(syms.intType).prepend(syms.stringType),
  2612                 olderasure.getParameterTypes().prepend(syms.intType).prepend(syms.stringType),
  2585                 olderasure.getReturnType(),
  2613                 olderasure.getReturnType(),
  2586                 olderasure.getThrownTypes(),
  2614                 olderasure.getThrownTypes(),