home *** CD-ROM | disk | FTP | other *** search
- package sun.tools.java;
-
- import java.io.PrintStream;
- import java.util.Vector;
- import sun.tools.asm.Assembler;
- import sun.tools.tree.Context;
- import sun.tools.tree.Expression;
- import sun.tools.tree.Node;
- import sun.tools.tree.Statement;
- import sun.tools.tree.Vset;
-
- public class FieldDefinition implements Constants {
- protected int where;
- protected int modifiers;
- protected Type type;
- protected String documentation;
- protected IdentifierToken[] expIds;
- protected ClassDeclaration[] exp;
- protected Node value;
- protected ClassDefinition clazz;
- protected Identifier name;
- protected ClassDefinition innerClass;
- protected FieldDefinition nextField;
- protected FieldDefinition nextMatch;
- protected FieldDefinition accessPeer;
-
- public FieldDefinition(int var1, ClassDefinition var2, int var3, Type var4, Identifier var5, IdentifierToken[] var6, Node var7) {
- if (var6 == null) {
- var6 = new IdentifierToken[0];
- }
-
- this.where = var1;
- this.clazz = var2;
- this.modifiers = var3;
- this.type = var4;
- this.name = var5;
- this.expIds = var6;
- this.value = var7;
- }
-
- public FieldDefinition(ClassDefinition var1) {
- this(var1.getWhere(), var1.getOuterClass(), var1.getModifiers(), var1.getType(), var1.getName().getFlatName().getName(), (IdentifierToken[])null, (Node)null);
- this.innerClass = var1;
- }
-
- public final int getWhere() {
- return this.where;
- }
-
- public final ClassDeclaration getClassDeclaration() {
- return this.clazz.getClassDeclaration();
- }
-
- public void resolveTypeStructure(Environment var1) {
- }
-
- public ClassDeclaration getDefiningClassDeclaration() {
- return this.getClassDeclaration();
- }
-
- public final ClassDefinition getClassDefinition() {
- return this.clazz;
- }
-
- public final ClassDefinition getTopClass() {
- return this.clazz.getTopClass();
- }
-
- public final int getModifiers() {
- return this.modifiers;
- }
-
- public final void subModifiers(int var1) {
- this.modifiers &= ~var1;
- }
-
- public final void addModifiers(int var1) {
- this.modifiers |= var1;
- }
-
- public final Type getType() {
- return this.type;
- }
-
- public final Identifier getName() {
- return this.name;
- }
-
- public Vector getArguments() {
- return this.isMethod() ? new Vector() : null;
- }
-
- public ClassDeclaration[] getExceptions(Environment var1) {
- if (this.expIds != null && this.exp == null) {
- if (this.expIds.length != 0) {
- throw new CompilerError("getExceptions " + this);
- }
-
- this.exp = new ClassDeclaration[0];
- }
-
- return this.exp;
- }
-
- public final IdentifierToken[] getExceptionIds() {
- return this.expIds;
- }
-
- public ClassDefinition getInnerClass() {
- return this.innerClass;
- }
-
- public boolean isUplevelValue() {
- if (this.isSynthetic() && this.isVariable() && !this.isStatic()) {
- String var1 = this.name.toString();
- return var1.startsWith("val$") || var1.toString().startsWith("loc$") || var1.toString().startsWith("this$");
- } else {
- return false;
- }
- }
-
- public boolean isAccessMethod() {
- return this.isSynthetic() && this.isMethod() && this.name.toString().startsWith("access$");
- }
-
- public FieldDefinition getAccessMethodTarget() {
- if (this.isAccessMethod()) {
- for(FieldDefinition var1 = this.accessPeer; var1 != null; var1 = var1.accessPeer) {
- if (!var1.isAccessMethod()) {
- return var1;
- }
- }
- }
-
- return null;
- }
-
- public void setAccessMethodTarget(FieldDefinition var1) {
- if (this.getAccessMethodTarget() != var1) {
- if (!this.isAccessMethod() || this.accessPeer != null || var1.accessPeer != null) {
- throw new CompilerError("accessPeer");
- }
-
- this.accessPeer = var1;
- }
-
- }
-
- public FieldDefinition getAccessUpdateField() {
- if (this.isAccessMethod()) {
- for(FieldDefinition var1 = this.accessPeer; var1 != null; var1 = var1.accessPeer) {
- if (var1.isAccessMethod()) {
- return var1;
- }
- }
- }
-
- return null;
- }
-
- public void setAccessUpdateField(FieldDefinition var1) {
- if (this.getAccessUpdateField() != var1) {
- if (!this.isAccessMethod() || var1.getAccessMethodTarget() != this.getAccessMethodTarget()) {
- throw new CompilerError("accessPeer");
- }
-
- var1.accessPeer = this.accessPeer;
- this.accessPeer = var1;
- }
-
- }
-
- public final boolean isBlankFinal() {
- return this.isFinal() && !this.isSynthetic() && this.getValue() == null;
- }
-
- public boolean isNeverNull() {
- if (this.isUplevelValue()) {
- return !this.name.toString().startsWith("val$");
- } else {
- return false;
- }
- }
-
- public Node getValue(Environment var1) throws ClassNotFound {
- return this.value;
- }
-
- public final Node getValue() {
- return this.value;
- }
-
- public final void setValue(Node var1) {
- this.value = var1;
- }
-
- public Object getInitialValue() {
- return null;
- }
-
- public final FieldDefinition getNextField() {
- return this.nextField;
- }
-
- public final FieldDefinition getNextMatch() {
- return this.nextMatch;
- }
-
- public String getDocumentation() {
- return this.documentation;
- }
-
- public void check(Environment var1) throws ClassNotFound {
- }
-
- public Vset check(Environment var1, Context var2, Vset var3) throws ClassNotFound {
- return var3;
- }
-
- public void code(Environment var1, Assembler var2) throws ClassNotFound {
- throw new CompilerError("code");
- }
-
- public void codeInit(Environment var1, Context var2, Assembler var3) throws ClassNotFound {
- throw new CompilerError("codeInit");
- }
-
- public boolean reportDeprecated(Environment var1) {
- return this.isDeprecated() || this.clazz.reportDeprecated(var1);
- }
-
- public final boolean canReach(Environment var1, FieldDefinition var2) {
- if (!var2.isLocal() && var2.isVariable() && (this.isVariable() || this.isInitializer())) {
- if (this.getClassDeclaration().equals(var2.getClassDeclaration()) && this.isStatic() == var2.isStatic()) {
- while((var2 = var2.getNextField()) != null && var2 != this) {
- }
-
- return var2 != null;
- } else {
- return true;
- }
- } else {
- return true;
- }
- }
-
- public final boolean isPublic() {
- return (this.modifiers & 1) != 0;
- }
-
- public final boolean isPrivate() {
- return (this.modifiers & 2) != 0;
- }
-
- public final boolean isProtected() {
- return (this.modifiers & 4) != 0;
- }
-
- public final boolean isFinal() {
- return (this.modifiers & 16) != 0;
- }
-
- public final boolean isStatic() {
- return (this.modifiers & 8) != 0;
- }
-
- public final boolean isSynchronized() {
- return (this.modifiers & 32) != 0;
- }
-
- public final boolean isAbstract() {
- return (this.modifiers & 1024) != 0;
- }
-
- public final boolean isNative() {
- return (this.modifiers & 256) != 0;
- }
-
- public final boolean isVolatile() {
- return (this.modifiers & 64) != 0;
- }
-
- public final boolean isTransient() {
- return (this.modifiers & 128) != 0;
- }
-
- public final boolean isMethod() {
- return this.type.isType(12);
- }
-
- public final boolean isVariable() {
- return !this.type.isType(12) && this.innerClass == null;
- }
-
- public final boolean isSynthetic() {
- return (this.modifiers & 524288) != 0;
- }
-
- public final boolean isDeprecated() {
- return (this.modifiers & 262144) != 0;
- }
-
- public final boolean isInnerClass() {
- return this.innerClass != null;
- }
-
- public final boolean isInitializer() {
- return this.getName().equals(Constants.idClassInit);
- }
-
- public final boolean isConstructor() {
- return this.getName().equals(Constants.idInit);
- }
-
- public boolean isLocal() {
- return false;
- }
-
- public boolean isInlineable(Environment var1, boolean var2) throws ClassNotFound {
- return (this.isStatic() || this.isPrivate() || this.isFinal() || this.isConstructor() || var2) && !this.isSynchronized() && !this.isNative();
- }
-
- public boolean isConstant() {
- if (this.isFinal() && this.isVariable() && this.value != null) {
- boolean var1;
- try {
- this.modifiers &= -17;
- var1 = ((Expression)this.value).isConstant();
- } finally {
- this.modifiers |= 16;
- }
-
- return var1;
- } else {
- return false;
- }
- }
-
- public String toString() {
- Identifier var1 = this.getClassDefinition().getName();
- if (this.isInitializer()) {
- return this.isStatic() ? "static {}" : "instance {}";
- } else if (this.isConstructor()) {
- StringBuffer var2 = new StringBuffer();
- var2.append(var1);
- var2.append('(');
- Type[] var3 = this.getType().getArgumentTypes();
-
- for(int var4 = 0; var4 < var3.length; ++var4) {
- if (var4 > 0) {
- var2.append(',');
- }
-
- var2.append(var3[var4].toString());
- }
-
- var2.append(')');
- return var2.toString();
- } else {
- return this.isInnerClass() ? this.getInnerClass().toString() : this.type.typeString(this.getName().toString());
- }
- }
-
- public void print(PrintStream var1) {
- if (this.isPublic()) {
- var1.print("public ");
- }
-
- if (this.isPrivate()) {
- var1.print("private ");
- }
-
- if (this.isProtected()) {
- var1.print("protected ");
- }
-
- if (this.isFinal()) {
- var1.print("final ");
- }
-
- if (this.isStatic()) {
- var1.print("static ");
- }
-
- if (this.isSynchronized()) {
- var1.print("synchronized ");
- }
-
- if (this.isAbstract()) {
- var1.print("abstract ");
- }
-
- if (this.isNative()) {
- var1.print("native ");
- }
-
- if (this.isVolatile()) {
- var1.print("volatile ");
- }
-
- if (this.isTransient()) {
- var1.print("transient ");
- }
-
- var1.println(this.toString() + ";");
- }
-
- public void cleanup(Environment var1) {
- this.documentation = null;
- if (this.isMethod() && this.value != null) {
- int var2 = 0;
- if (!this.isPrivate() && !this.isInitializer()) {
- if ((var2 = ((Statement)this.value).costInline(30, (Environment)null, (Context)null)) >= 30) {
- this.value = Statement.empty;
- } else {
- try {
- if (!this.isInlineable((Environment)null, true)) {
- this.value = Statement.empty;
- }
- } catch (ClassNotFound var3) {
- }
- }
- } else {
- this.value = Statement.empty;
- }
-
- if (this.value != Statement.empty && var1.dump()) {
- var1.output("[after cleanup of " + this.getName() + ", " + var2 + " expression cost units remain]");
- return;
- }
- } else if (this.isVariable() && (this.isPrivate() || !this.isFinal() || this.type.isType(9))) {
- this.value = null;
- }
-
- }
- }
-