1 /* |
1 /* |
2 * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
63 import com.sun.tools.javac.util.Name; |
63 import com.sun.tools.javac.util.Name; |
64 |
64 |
65 import static com.sun.tools.javac.code.Flags.*; |
65 import static com.sun.tools.javac.code.Flags.*; |
66 import static com.sun.tools.javac.code.Kinds.*; |
66 import static com.sun.tools.javac.code.Kinds.*; |
67 import static com.sun.tools.javac.code.Kinds.Kind.*; |
67 import static com.sun.tools.javac.code.Kinds.Kind.*; |
|
68 import com.sun.tools.javac.code.MissingInfoHandler; |
68 import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; |
69 import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; |
69 import com.sun.tools.javac.code.Scope.WriteableScope; |
70 import com.sun.tools.javac.code.Scope.WriteableScope; |
|
71 import com.sun.tools.javac.code.Symbol; |
70 import static com.sun.tools.javac.code.Symbol.OperatorSymbol.AccessCode.FIRSTASGOP; |
72 import static com.sun.tools.javac.code.Symbol.OperatorSymbol.AccessCode.FIRSTASGOP; |
|
73 import com.sun.tools.javac.code.Type; |
71 import static com.sun.tools.javac.code.TypeTag.CLASS; |
74 import static com.sun.tools.javac.code.TypeTag.CLASS; |
72 import static com.sun.tools.javac.code.TypeTag.FORALL; |
75 import static com.sun.tools.javac.code.TypeTag.FORALL; |
73 import static com.sun.tools.javac.code.TypeTag.TYPEVAR; |
76 import static com.sun.tools.javac.code.TypeTag.TYPEVAR; |
74 import static com.sun.tools.javac.jvm.ByteCodes.iadd; |
77 import static com.sun.tools.javac.jvm.ByteCodes.iadd; |
75 import static com.sun.tools.javac.jvm.ByteCodes.ishll; |
78 import static com.sun.tools.javac.jvm.ByteCodes.ishll; |
76 import static com.sun.tools.javac.jvm.ByteCodes.lushrl; |
79 import static com.sun.tools.javac.jvm.ByteCodes.lushrl; |
77 import static com.sun.tools.javac.jvm.ByteCodes.lxor; |
80 import static com.sun.tools.javac.jvm.ByteCodes.lxor; |
78 import static com.sun.tools.javac.jvm.ByteCodes.string_add; |
81 import static com.sun.tools.javac.jvm.ByteCodes.string_add; |
|
82 import com.sun.tools.javac.util.Name; |
79 |
83 |
80 /** Root class for Java symbols. It contains subclasses |
84 /** Root class for Java symbols. It contains subclasses |
81 * for specific sorts of symbols, such as variables, methods and operators, |
85 * for specific sorts of symbols, such as variables, methods and operators, |
82 * types, packages. Each subclass is represented as a static inner class |
86 * types, packages. Each subclass is represented as a static inner class |
83 * inside Symbol. |
87 * inside Symbol. |
1187 metadata = null; |
1191 metadata = null; |
1188 } |
1192 } |
1189 |
1193 |
1190 } |
1194 } |
1191 |
1195 |
|
1196 public static class RootPackageSymbol extends PackageSymbol { |
|
1197 public final MissingInfoHandler missingInfoHandler; |
|
1198 |
|
1199 public RootPackageSymbol(Name name, Symbol owner, MissingInfoHandler missingInfoHandler) { |
|
1200 super(name, owner); |
|
1201 this.missingInfoHandler = missingInfoHandler; |
|
1202 } |
|
1203 |
|
1204 } |
|
1205 |
1192 /** A class for class symbols |
1206 /** A class for class symbols |
1193 */ |
1207 */ |
1194 public static class ClassSymbol extends TypeSymbol implements TypeElement { |
1208 public static class ClassSymbol extends TypeSymbol implements TypeElement { |
1195 |
1209 |
1196 /** a scope for all class members; variables, methods and inner classes |
1210 /** a scope for all class members; variables, methods and inner classes |
1630 } |
1644 } |
1631 |
1645 |
1632 public <R, P> R accept(Symbol.Visitor<R, P> v, P p) { |
1646 public <R, P> R accept(Symbol.Visitor<R, P> v, P p) { |
1633 return v.visitVarSymbol(this, p); |
1647 return v.visitVarSymbol(this, p); |
1634 } |
1648 } |
|
1649 } |
|
1650 |
|
1651 public static class ParamSymbol extends VarSymbol { |
|
1652 public ParamSymbol(long flags, Name name, Type type, Symbol owner) { |
|
1653 super(flags, name, type, owner); |
|
1654 } |
|
1655 |
|
1656 @Override |
|
1657 public Name getSimpleName() { |
|
1658 if ((flags_field & NAME_FILLED) == 0) { |
|
1659 flags_field |= NAME_FILLED; |
|
1660 Symbol rootPack = this; |
|
1661 while (rootPack != null && !(rootPack instanceof RootPackageSymbol)) { |
|
1662 rootPack = rootPack.owner; |
|
1663 } |
|
1664 if (rootPack != null) { |
|
1665 Name inferredName = |
|
1666 ((RootPackageSymbol) rootPack).missingInfoHandler.getParameterName(this); |
|
1667 if (inferredName != null) { |
|
1668 this.name = inferredName; |
|
1669 } |
|
1670 } |
|
1671 } |
|
1672 return super.getSimpleName(); |
|
1673 } |
|
1674 |
1635 } |
1675 } |
1636 |
1676 |
1637 /** A class for method symbols. |
1677 /** A class for method symbols. |
1638 */ |
1678 */ |
1639 public static class MethodSymbol extends Symbol implements ExecutableElement { |
1679 public static class MethodSymbol extends Symbol implements ExecutableElement { |