diff options
Diffstat (limited to 'third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute')
111 files changed, 10890 insertions, 0 deletions
diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/Attribute.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/Attribute.java new file mode 100644 index 0000000000..4a475a02a6 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/Attribute.java @@ -0,0 +1,143 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute; + +import proguard.classfile.*; +import proguard.classfile.attribute.visitor.AttributeVisitor; + +/** + * This abstract class represents an attribute that is attached to a class, + * a class member, or a code attribute. Specific types of attributes are + * subclassed from it. + * + * @author Eric Lafortune + * @noinspection AbstractClassWithoutAbstractMethods + */ +public abstract class Attribute implements VisitorAccepter +{ + public int u2attributeNameIndex; + //public int u4attributeLength; + //public byte info[]; + + /** + * An extra field in which visitors can store information. + */ + public Object visitorInfo; + + + /** + * Create an uninitialized Attribute. + */ + protected Attribute() + { + } + + + /** + * Create an initialized Attribute. + */ + protected Attribute(int u2attributeNameIndex) + { + this.u2attributeNameIndex = u2attributeNameIndex; + } + + + /** + * Returns the String name of the attribute. + */ + public String getAttributeName(Clazz clazz) + { + return clazz.getString(u2attributeNameIndex); + } + + + // Methods to be implemented by extensions, if applicable. + + /** + * Accepts the given visitor. + */ + public void accept(Clazz clazz, AttributeVisitor attributeVisitor) + { + throw new UnsupportedOperationException("Method must be overridden in ["+this.getClass().getName()+"] if ever called"); + } + + /** + * Accepts the given visitor in the context of the given field. + */ + public void accept(Clazz clazz, Field field, AttributeVisitor attributeVisitor) + { + // Delegate to the default invocation if the field is null anyway. + if (field == null) + { + accept(clazz, attributeVisitor); + } + else + { + throw new UnsupportedOperationException("Method must be overridden in ["+this.getClass().getName()+"] if ever called"); + } + } + + /** + * Accepts the given visitor in the context of the given method. + */ + public void accept(Clazz clazz, Method method, AttributeVisitor attributeVisitor) + { + // Delegate to the default invocation if the method is null anyway. + if (method == null) + { + accept(clazz, (Field)null, attributeVisitor); + } + else + { + throw new UnsupportedOperationException("Method must be overridden in ["+this.getClass().getName()+"] if ever called"); + } + } + + /** + * Accepts the given visitor in the context of the given code attribute. + */ + public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, AttributeVisitor attributeVisitor) + { + // Delegate to the default invocation if the code attribute is null + // anyway. + if (codeAttribute == null) + { + accept(clazz, method, attributeVisitor); + } + else + { + throw new UnsupportedOperationException("Method must be overridden in ["+this.getClass().getName()+"] if ever called"); + } + } + + + // Implementations for VisitorAccepter. + + public Object getVisitorInfo() + { + return visitorInfo; + } + + public void setVisitorInfo(Object visitorInfo) + { + this.visitorInfo = visitorInfo; + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/BootstrapMethodInfo.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/BootstrapMethodInfo.java new file mode 100755 index 0000000000..62902571a1 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/BootstrapMethodInfo.java @@ -0,0 +1,89 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute; + +import proguard.classfile.*; +import proguard.classfile.constant.visitor.ConstantVisitor; + +/** + * Representation of a bootstrap method. + * + * @author Eric Lafortune + */ +public class BootstrapMethodInfo implements VisitorAccepter +{ + public int u2methodHandleIndex; + public int u2methodArgumentCount; + public int[] u2methodArguments; + + /** + * An extra field in which visitors can store information. + */ + public Object visitorInfo; + + + /** + * Creates an uninitialized BootstrapMethodInfo. + */ + public BootstrapMethodInfo() + { + } + + + /** + * Creates an initialized BootstrapMethodInfo. + */ + public BootstrapMethodInfo(int u2methodHandleIndex, + int u2methodArgumentCount, + int[] u2methodArguments) + { + this.u2methodHandleIndex = u2methodHandleIndex; + this.u2methodArgumentCount = u2methodArgumentCount; + this.u2methodArguments = u2methodArguments; + } + + + /** + * Applies the given constant pool visitor to the argument constants of the + * bootstrap method. + */ + public void methodArgumentsAccept(Clazz clazz, ConstantVisitor constantVisitor) + { + for (int index = 0; index < u2methodArgumentCount; index++) + { + clazz.constantPoolEntryAccept(u2methodArguments[index], + constantVisitor); + } + } + + + // Implementations for VisitorAccepter. + + public Object getVisitorInfo() + { + return visitorInfo; + } + + public void setVisitorInfo(Object visitorInfo) + { + this.visitorInfo = visitorInfo; + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/BootstrapMethodsAttribute.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/BootstrapMethodsAttribute.java new file mode 100755 index 0000000000..08970e1d05 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/BootstrapMethodsAttribute.java @@ -0,0 +1,93 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute; + +import proguard.classfile.Clazz; +import proguard.classfile.attribute.visitor.*; + +/** + * This Attribute represents a bootstrap methods attribute. + * + * @author Eric Lafortune + */ +public class BootstrapMethodsAttribute extends Attribute +{ + public int u2bootstrapMethodsCount; + public BootstrapMethodInfo[] bootstrapMethods; + + + /** + * Creates an uninitialized BootstrapMethodsAttribute. + */ + public BootstrapMethodsAttribute() + { + } + + + /** + * Creates an initialized BootstrapMethodsAttribute. + */ + public BootstrapMethodsAttribute(int u2attributeNameIndex, + int u2bootstrapMethodsCount, + BootstrapMethodInfo[] bootstrapMethods) + { + super(u2attributeNameIndex); + + this.u2bootstrapMethodsCount = u2bootstrapMethodsCount; + this.bootstrapMethods = bootstrapMethods; + } + + + // Implementations for Attribute. + + public void accept(Clazz clazz, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitBootstrapMethodsAttribute(clazz, this); + } + + + /** + * Applies the given visitor to all bootstrap method info entries. + */ + public void bootstrapMethodEntriesAccept(Clazz clazz, BootstrapMethodInfoVisitor bootstrapMethodInfoVisitor) + { + for (int index = 0; index < u2bootstrapMethodsCount; index++) + { + // We don't need double dispatching here, since there is only one + // type of BootstrapMethodInfo. + bootstrapMethodInfoVisitor.visitBootstrapMethodInfo(clazz, bootstrapMethods[index]); + } + } + + + /** + * Applies the given visitor to the specified bootstrap method info + * entry. + */ + public void bootstrapMethodEntryAccept(Clazz clazz, + int bootstrapMethodIndex, + BootstrapMethodInfoVisitor bootstrapMethodInfoVisitor) + { + // We don't need double dispatching here, since there is only one + // type of BootstrapMethodInfo. + bootstrapMethodInfoVisitor.visitBootstrapMethodInfo(clazz, bootstrapMethods[bootstrapMethodIndex]); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/CodeAttribute.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/CodeAttribute.java new file mode 100644 index 0000000000..0afd5dcbf2 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/CodeAttribute.java @@ -0,0 +1,202 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute; + +import proguard.classfile.*; +import proguard.classfile.attribute.visitor.*; +import proguard.classfile.instruction.*; +import proguard.classfile.instruction.visitor.InstructionVisitor; + +/** + * This Attribute represents a code attribute. + * + * @author Eric Lafortune + */ +public class CodeAttribute extends Attribute +{ + public int u2maxStack; + public int u2maxLocals; + public int u4codeLength; + public byte[] code; + public int u2exceptionTableLength; + public ExceptionInfo[] exceptionTable; + public int u2attributesCount; + public Attribute[] attributes; + + + /** + * Creates an uninitialized CodeAttribute. + */ + public CodeAttribute() + { + } + + + /** + * Creates an initialized CodeAttribute. + */ + public CodeAttribute(int u2attributeNameIndex, + int u2maxStack, + int u2maxLocals, + int u4codeLength, + byte[] code, + int u2exceptionTableLength, + ExceptionInfo[] exceptionTable, + int u2attributesCount, + Attribute[] attributes) + { + super(u2attributeNameIndex); + + this.u2maxStack = u2maxStack; + this.u2maxLocals = u2maxLocals; + this.u4codeLength = u4codeLength; + this.code = code; + this.u2exceptionTableLength = u2exceptionTableLength; + this.exceptionTable = exceptionTable; + this.u2attributesCount = u2attributesCount; + this.attributes = attributes; + } + + + /** + * Returns the (first) attribute with the given name. + */ + public Attribute getAttribute(Clazz clazz, String name) + { + for (int index = 0; index < u2attributesCount; index++) + { + Attribute attribute = attributes[index]; + if (attribute.getAttributeName(clazz).equals(name)) + { + return attribute; + } + } + + return null; + } + + + // Implementations for Attribute. + + public void accept(Clazz clazz, Method method, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitCodeAttribute(clazz, method, this); + } + + + /** + * Applies the given instruction visitor to all instructions. + */ + public void instructionsAccept(Clazz clazz, Method method, InstructionVisitor instructionVisitor) + { + instructionsAccept(clazz, method, 0, u4codeLength, instructionVisitor); + } + + + /** + * Applies the given instruction visitor to the instruction at the specified + * offset. + */ + public void instructionAccept(Clazz clazz, Method method, int offset, InstructionVisitor instructionVisitor) + { + Instruction instruction = InstructionFactory.create(code, offset); + instruction.accept(clazz, method, this, offset, instructionVisitor); + } + + + /** + * Applies the given instruction visitor to all instructions in the + * specified range of offsets. + */ + public void instructionsAccept(Clazz clazz, Method method, int startOffset, int endOffset, InstructionVisitor instructionVisitor) + { + int offset = startOffset; + + while (offset < endOffset) + { + // Note that the instruction is only volatile. + Instruction instruction = InstructionFactory.create(code, offset); + int instructionLength = instruction.length(offset); + instruction.accept(clazz, method, this, offset, instructionVisitor); + offset += instructionLength; + } + } + + + /** + * Applies the given exception visitor to all exceptions. + */ + public void exceptionsAccept(Clazz clazz, Method method, ExceptionInfoVisitor exceptionInfoVisitor) + { + for (int index = 0; index < u2exceptionTableLength; index++) + { + // We don't need double dispatching here, since there is only one + // type of ExceptionInfo. + exceptionInfoVisitor.visitExceptionInfo(clazz, method, this, exceptionTable[index]); + } + } + + + /** + * Applies the given exception visitor to all exceptions that are applicable + * to the instruction at the specified offset. + */ + public void exceptionsAccept(Clazz clazz, Method method, int offset, ExceptionInfoVisitor exceptionInfoVisitor) + { + for (int index = 0; index < u2exceptionTableLength; index++) + { + ExceptionInfo exceptionInfo = exceptionTable[index]; + if (exceptionInfo.isApplicable(offset)) + { + exceptionInfoVisitor.visitExceptionInfo(clazz, method, this, exceptionInfo); + } + } + } + + + /** + * Applies the given exception visitor to all exceptions that are applicable + * to any of the instructions in the specified range of offsets. + */ + public void exceptionsAccept(Clazz clazz, Method method, int startOffset, int endOffset, ExceptionInfoVisitor exceptionInfoVisitor) + { + for (int index = 0; index < u2exceptionTableLength; index++) + { + ExceptionInfo exceptionInfo = exceptionTable[index]; + if (exceptionInfo.isApplicable(startOffset, endOffset)) + { + exceptionInfoVisitor.visitExceptionInfo(clazz, method, this, exceptionInfo); + } + } + } + + + /** + * Applies the given attribute visitor to all attributes. + */ + public void attributesAccept(Clazz clazz, Method method, AttributeVisitor attributeVisitor) + { + for (int index = 0; index < u2attributesCount; index++) + { + attributes[index].accept(clazz, method, this, attributeVisitor); + } + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/ConstantValueAttribute.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/ConstantValueAttribute.java new file mode 100644 index 0000000000..c4d9d808b9 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/ConstantValueAttribute.java @@ -0,0 +1,62 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute; + +import proguard.classfile.*; +import proguard.classfile.attribute.visitor.AttributeVisitor; + +/** + * This Attribute represents a constant value attribute. + * + * @author Eric Lafortune + */ +public class ConstantValueAttribute extends Attribute +{ + public int u2constantValueIndex; + + + /** + * Creates an uninitialized ConstantValueAttribute. + */ + public ConstantValueAttribute() + { + } + + + /** + * Creates an initialized ConstantValueAttribute. + */ + public ConstantValueAttribute(int u2attributeNameIndex, + int u2constantValueIndex) + { + super(u2attributeNameIndex); + + this.u2constantValueIndex = u2constantValueIndex; + } + + + // Implementations for Attribute. + + public void accept(Clazz clazz, Field field, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitConstantValueAttribute(clazz, field, this); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/DeprecatedAttribute.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/DeprecatedAttribute.java new file mode 100644 index 0000000000..ad3ac4be91 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/DeprecatedAttribute.java @@ -0,0 +1,66 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute; + +import proguard.classfile.*; +import proguard.classfile.attribute.visitor.AttributeVisitor; + +/** + * This Attribute represents a deprecated attribute. + * + * @author Eric Lafortune + */ +public class DeprecatedAttribute extends Attribute +{ + /** + * Creates an uninitialized DeprecatedAttribute. + */ + public DeprecatedAttribute() + { + } + + + /** + * Creates an initialized DeprecatedAttribute. + */ + public DeprecatedAttribute(int u2attributeNameIndex) + { + super(u2attributeNameIndex); + } + + + // Implementations for Attribute. + + public void accept(Clazz clazz, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitDeprecatedAttribute(clazz, this); + } + + public void accept(Clazz clazz, Field field, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitDeprecatedAttribute(clazz, field, this); + } + + public void accept(Clazz clazz, Method method, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitDeprecatedAttribute(clazz, method, this); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/EnclosingMethodAttribute.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/EnclosingMethodAttribute.java new file mode 100644 index 0000000000..a01fc5a7ad --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/EnclosingMethodAttribute.java @@ -0,0 +1,132 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute; + +import proguard.classfile.*; +import proguard.classfile.attribute.visitor.AttributeVisitor; +import proguard.classfile.visitor.*; + +/** + * This Attribute represents an enclosing method attribute. + * + * @author Eric Lafortune + */ +public class EnclosingMethodAttribute extends Attribute +{ + public int u2classIndex; + public int u2nameAndTypeIndex; + + /** + * An extra field pointing to the referenced Clazz object. + * This field is typically filled out by the <code>{@link + * proguard.classfile.util.ClassReferenceInitializer + * ClassReferenceInitializer}</code>. + */ + public Clazz referencedClass; + + /** + * An extra field optionally pointing to the referenced Method object. + * This field is typically filled out by the <code>{@link + * proguard.classfile.util.ClassReferenceInitializer + * ClassReferenceInitializer}</code>. + */ + public Method referencedMethod; + + + /** + * Creates an uninitialized EnclosingMethodAttribute. + */ + public EnclosingMethodAttribute() + { + } + + + /** + * Creates an initialized EnclosingMethodAttribute. + */ + public EnclosingMethodAttribute(int u2attributeNameIndex, + int u2classIndex, + int u2nameAndTypeIndex) + { + super(u2attributeNameIndex); + + this.u2classIndex = u2classIndex; + this.u2nameAndTypeIndex = u2nameAndTypeIndex; + } + + + /** + * Returns the class name. + */ + public String getClassName(Clazz clazz) + { + return clazz.getClassName(u2classIndex); + } + + /** + * Returns the method/field name. + */ + public String getName(Clazz clazz) + { + return clazz.getName(u2nameAndTypeIndex); + } + + /** + * Returns the type. + */ + public String getType(Clazz clazz) + { + return clazz.getType(u2nameAndTypeIndex); + } + + + /** + * Lets the referenced class accept the given visitor. + */ + public void referencedClassAccept(ClassVisitor classVisitor) + { + if (referencedClass != null) + { + referencedClass.accept(classVisitor); + } + } + + + /** + * Lets the referenced class member accept the given visitor. + */ + public void referencedMethodAccept(MemberVisitor memberVisitor) + { + if (referencedMethod != null) + { + referencedMethod.accept(referencedClass, + memberVisitor); + } + } + + + // Implementations for Attribute. + + public void accept(Clazz clazz, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitEnclosingMethodAttribute(clazz, this); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/ExceptionInfo.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/ExceptionInfo.java new file mode 100644 index 0000000000..5c35e6f12f --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/ExceptionInfo.java @@ -0,0 +1,100 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute; + +import proguard.classfile.VisitorAccepter; + +/** + * Representation of an Exception table entry. + * + * @author Eric Lafortune + */ +public class ExceptionInfo implements VisitorAccepter +{ + public int u2startPC; + public int u2endPC; + public int u2handlerPC; + public int u2catchType; + + /** + * An extra field in which visitors can store information. + */ + public Object visitorInfo; + + + /** + * Creates an uninitialized ExceptionInfo. + */ + public ExceptionInfo() + { + this(0, 0, 0, 0); + } + + + /** + * Creates an ExceptionInfo with the given properties. + */ + public ExceptionInfo(int u2startPC, + int u2endPC, + int u2handlerPC, + int u2catchType) + { + this.u2startPC = u2startPC; + this.u2endPC = u2endPC; + this.u2handlerPC = u2handlerPC; + this.u2catchType = u2catchType; + } + + + /** + * Returns whether the exception's try block contains the instruction at the + * given offset. + */ + public boolean isApplicable(int instructionOffset) + { + return instructionOffset >= u2startPC && + instructionOffset < u2endPC; + } + + + /** + * Returns whether the exception's try block overlaps with the specified + * block of instructions. + */ + public boolean isApplicable(int startOffset, int endOffset) + { + return u2startPC < endOffset && + u2endPC > startOffset; + } + + + // Implementations for VisitorAccepter. + + public Object getVisitorInfo() + { + return visitorInfo; + } + + public void setVisitorInfo(Object visitorInfo) + { + this.visitorInfo = visitorInfo; + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/ExceptionsAttribute.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/ExceptionsAttribute.java new file mode 100644 index 0000000000..a47fc57e38 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/ExceptionsAttribute.java @@ -0,0 +1,80 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute; + +import proguard.classfile.*; +import proguard.classfile.attribute.visitor.AttributeVisitor; +import proguard.classfile.constant.visitor.ConstantVisitor; + +/** + * This Attribute represents an exceptions attribute. + * + * @author Eric Lafortune + */ +public class ExceptionsAttribute extends Attribute +{ + public int u2exceptionIndexTableLength; + public int[] u2exceptionIndexTable; + + + /** + * Creates an uninitialized ExceptionsAttribute. + */ + public ExceptionsAttribute() + { + } + + + /** + * Creates an initialized ExceptionsAttribute. + */ + public ExceptionsAttribute(int u2attributeNameIndex, + int u2exceptionIndexTableLength, + int[] u2exceptionIndexTable) + { + super(u2attributeNameIndex); + + this.u2exceptionIndexTableLength = u2exceptionIndexTableLength; + this.u2exceptionIndexTable = u2exceptionIndexTable; + } + + + // Implementations for Attribute. + + public void accept(Clazz clazz, Method method, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitExceptionsAttribute(clazz, method, this); + } + + + /** + * Applies the given constant pool visitor to all exception class pool info + * entries. + */ + public void exceptionEntriesAccept(Clazz clazz, ConstantVisitor constantVisitor) + { + for (int index = 0; index < u2exceptionIndexTableLength; index++) + { + clazz.constantPoolEntryAccept(u2exceptionIndexTable[index], + constantVisitor); + } + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/ExtendedLineNumberInfo.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/ExtendedLineNumberInfo.java new file mode 100644 index 0000000000..8f910bdb87 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/ExtendedLineNumberInfo.java @@ -0,0 +1,63 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute; + +/** + * This line number table entry contains additional information about its + * source. This information can not be represented in class files, but it + * can be used internally to represent lines in inlined or merged code. + * + * @author Eric Lafortune + */ +public class ExtendedLineNumberInfo +extends LineNumberInfo +{ + public String source; + + + /** + * Creates an uninitialized ExtendedLineNumberInfo. + */ + public ExtendedLineNumberInfo() + { + } + + + /** + * Creates an initialized ExtendedLineNumberInfo. + */ + public ExtendedLineNumberInfo(int u2startPC, + int u2lineNumber, + String source) + { + super(u2startPC, u2lineNumber); + + this.source = source; + } + + + // Implementations for LineNumberInfo. + + public String getSource() + { + return source; + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/InnerClassesAttribute.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/InnerClassesAttribute.java new file mode 100644 index 0000000000..bb81ece462 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/InnerClassesAttribute.java @@ -0,0 +1,80 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute; + +import proguard.classfile.Clazz; +import proguard.classfile.attribute.visitor.*; + +/** + * This Attribute represents an inner classes attribute. + * + * @author Eric Lafortune + */ +public class InnerClassesAttribute extends Attribute +{ + public int u2classesCount; + public InnerClassesInfo[] classes; + + + /** + * Creates an uninitialized InnerClassesAttribute. + */ + public InnerClassesAttribute() + { + } + + + /** + * Creates an initialized InnerClassesAttribute. + */ + public InnerClassesAttribute(int u2attributeNameIndex, + int u2classesCount, + InnerClassesInfo[] classes) + { + super(u2attributeNameIndex); + + this.u2classesCount = u2classesCount; + this.classes = classes; + } + + // + + // Implementations for Attribute. + + public void accept(Clazz clazz, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitInnerClassesAttribute(clazz, this); + } + + + /** + * Applies the given visitor to all inner classes. + */ + public void innerClassEntriesAccept(Clazz clazz, InnerClassesInfoVisitor innerClassesInfoVisitor) + { + for (int index = 0; index < u2classesCount; index++) + { + // We don't need double dispatching here, since there is only one + // type of InnerClassesInfo. + innerClassesInfoVisitor.visitInnerClassesInfo(clazz, classes[index]); + } + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/InnerClassesInfo.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/InnerClassesInfo.java new file mode 100644 index 0000000000..21938ea292 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/InnerClassesInfo.java @@ -0,0 +1,119 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute; + +import proguard.classfile.*; +import proguard.classfile.constant.visitor.ConstantVisitor; + +/** + * Representation of an Inner Classes table entry. + * + * @author Eric Lafortune + */ +public class InnerClassesInfo implements VisitorAccepter +{ + public int u2innerClassIndex; + public int u2outerClassIndex; + public int u2innerNameIndex; + public int u2innerClassAccessFlags; + + /** + * An extra field in which visitors can store information. + */ + public Object visitorInfo; + + + /** + * Returns the inner class index. + */ + protected int getInnerClassIndex() + { + return u2innerClassIndex; + } + + /** + * Returns the name index. + */ + protected int getInnerNameIndex() + { + return u2innerNameIndex; + } + + /** + * Sets the name index. + */ + protected void setInnerNameIndex(int index) + { + u2innerNameIndex = index; + } + + + /** + * Applies the given constant pool visitor to the class constant of the + * inner class, if any. + */ + public void innerClassConstantAccept(Clazz clazz, ConstantVisitor constantVisitor) + { + if (u2innerClassIndex != 0) + { + clazz.constantPoolEntryAccept(u2innerClassIndex, constantVisitor); + } + } + + + /** + * Applies the given constant pool visitor to the class constant of the + * outer class, if any. + */ + public void outerClassConstantAccept(Clazz clazz, ConstantVisitor constantVisitor) + { + if (u2outerClassIndex != 0) + { + clazz.constantPoolEntryAccept(u2outerClassIndex, constantVisitor); + } + } + + + /** + * Applies the given constant pool visitor to the Utf8 constant of the + * inner name, if any. + */ + public void innerNameConstantAccept(Clazz clazz, ConstantVisitor constantVisitor) + { + if (u2innerNameIndex != 0) + { + clazz.constantPoolEntryAccept(u2innerNameIndex, constantVisitor); + } + } + + + // Implementations for VisitorAccepter. + + public Object getVisitorInfo() + { + return visitorInfo; + } + + public void setVisitorInfo(Object visitorInfo) + { + this.visitorInfo = visitorInfo; + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/LineNumberInfo.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/LineNumberInfo.java new file mode 100644 index 0000000000..ab0ee32f0d --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/LineNumberInfo.java @@ -0,0 +1,61 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute; + +/** + * Representation of an Line Number table entry. + * + * @author Eric Lafortune + */ +public class LineNumberInfo +{ + public int u2startPC; + public int u2lineNumber; + + + /** + * Creates an uninitialized LineNumberInfo. + */ + public LineNumberInfo() + { + } + + + /** + * Creates an initialized LineNumberInfo. + */ + public LineNumberInfo(int u2startPC, int u2lineNumber) + { + this.u2startPC = u2startPC; + this.u2lineNumber = u2lineNumber; + } + + + /** + * Returns a description of the source of the line, if known, or null + * otherwise. Standard line number entries don't contain information + * about their source; it is assumed to be the same source file. + */ + public String getSource() + { + return null; + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/LineNumberTableAttribute.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/LineNumberTableAttribute.java new file mode 100644 index 0000000000..bc9dd4d60a --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/LineNumberTableAttribute.java @@ -0,0 +1,174 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute; + +import proguard.classfile.*; +import proguard.classfile.attribute.visitor.*; + +/** + * This Attribute represents a line number table attribute. + * + * @author Eric Lafortune + */ +public class LineNumberTableAttribute extends Attribute +{ + public int u2lineNumberTableLength; + public LineNumberInfo[] lineNumberTable; + + + /** + * Creates an uninitialized LineNumberTableAttribute. + */ + public LineNumberTableAttribute() + { + } + + + /** + * Creates an initialized LineNumberTableAttribute. + */ + public LineNumberTableAttribute(int u2attributeNameIndex, + int u2lineNumberTableLength, + LineNumberInfo[] lineNumberTable) + { + super(u2attributeNameIndex); + + this.u2lineNumberTableLength = u2lineNumberTableLength; + this.lineNumberTable = lineNumberTable; + } + + + /** + * Returns the line number corresponding to the given byte code program + * counter. + */ + public int getLineNumber(int pc) + { + LineNumberInfo info = getLineNumberInfo(pc); + + return info == null ? 0 : info.u2lineNumber; + } + + + /** + * Returns the source corresponding to the given byte code program + * counter. + */ + public String getSource(int pc) + { + LineNumberInfo info = getLineNumberInfo(pc); + + return info == null ? null : info.getSource(); + } + + + /** + * Returns the line number info corresponding to the given byte code + * program counter. + */ + public LineNumberInfo getLineNumberInfo(int pc) + { + for (int index = u2lineNumberTableLength-1; index >= 0; index--) + { + LineNumberInfo info = lineNumberTable[index]; + if (pc >= info.u2startPC) + { + return info; + } + } + + return u2lineNumberTableLength > 0 ? + lineNumberTable[0] : + null; + } + + + /** + * Returns the lowest line number with the default null source, + * or 0 if there aren't any such line numbers. + */ + public int getLowestLineNumber() + { + int lowestLineNumber = Integer.MAX_VALUE; + + for (int index = 0; index < u2lineNumberTableLength; index++) + { + LineNumberInfo info = lineNumberTable[index]; + if (info.getSource() == null) + { + int lineNumber = info.u2lineNumber; + if (lineNumber < lowestLineNumber) + { + lowestLineNumber = lineNumber; + } + } + } + + return lowestLineNumber == Integer.MAX_VALUE ? 0 : lowestLineNumber; + } + + + /** + * Returns the highest line number with the default null source, + * or 0 if there aren't any such line numbers. + */ + public int getHighestLineNumber() + { + int highestLineNumber = 0; + + for (int index = 0; index < u2lineNumberTableLength; index++) + { + LineNumberInfo info = lineNumberTable[index]; + if (info.getSource() == null) + { + int lineNumber = info.u2lineNumber; + if (lineNumber > highestLineNumber) + { + highestLineNumber = lineNumber; + } + } + } + + return highestLineNumber; + } + + + // Implementations for Attribute. + + public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitLineNumberTableAttribute(clazz, method, codeAttribute, this); + } + + + /** + * Applies the given visitor to all line numbers. + */ + public void lineNumbersAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, LineNumberInfoVisitor lineNumberInfoVisitor) + { + for (int index = 0; index < u2lineNumberTableLength; index++) + { + // We don't need double dispatching here, since there is only one + // type of LineNumberInfo. + lineNumberInfoVisitor.visitLineNumberInfo(clazz, method, codeAttribute, lineNumberTable[index]); + } + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/LocalVariableInfo.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/LocalVariableInfo.java new file mode 100644 index 0000000000..3cdc66ed9c --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/LocalVariableInfo.java @@ -0,0 +1,135 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute; + +import proguard.classfile.*; +import proguard.classfile.visitor.ClassVisitor; + +/** + * Representation of an Local Variable table entry. + * + * @author Eric Lafortune + */ +public class LocalVariableInfo implements VisitorAccepter, Comparable +{ + public int u2startPC; + public int u2length; + public int u2nameIndex; + public int u2descriptorIndex; + public int u2index; + + /** + * An extra field pointing to the referenced Clazz object. + * This field is typically filled out by the <code>{@link + * proguard.classfile.util.ClassReferenceInitializer + * ClassReferenceInitializer}</code>. + */ + public Clazz referencedClass; + + /** + * An extra field in which visitors can store information. + */ + public Object visitorInfo; + + + /** + * Creates an uninitialized LocalVariableInfo. + */ + public LocalVariableInfo() + { + } + + + /** + * Creates an initialized LocalVariableInfo. + */ + public LocalVariableInfo(int u2startPC, + int u2length, + int u2nameIndex, + int u2descriptorIndex, + int u2index) + { + this.u2startPC = u2startPC; + this.u2length = u2length; + this.u2nameIndex = u2nameIndex; + this.u2descriptorIndex = u2descriptorIndex; + this.u2index = u2index; + } + + + /** + * Returns the name. + */ + public String getName(Clazz clazz) + { + return clazz.getString(u2nameIndex); + } + + + /** + * Returns the descriptor. + */ + public String getDescriptor(Clazz clazz) + { + return clazz.getString(u2descriptorIndex); + } + + + /** + * Lets the referenced class accept the given visitor. + */ + public void referencedClassAccept(ClassVisitor classVisitor) + { + if (referencedClass != null) + { + referencedClass.accept(classVisitor); + } + } + + + // Implementations for VisitorAccepter. + + public Object getVisitorInfo() + { + return visitorInfo; + } + + public void setVisitorInfo(Object visitorInfo) + { + this.visitorInfo = visitorInfo; + } + + + // Implementations for Comparable. + + public int compareTo(Object object) + { + LocalVariableInfo other = (LocalVariableInfo)object; + + return + this.u2startPC < other.u2startPC ? -1 : this.u2startPC > other.u2startPC ? 1 : + this.u2index < other.u2index ? -1 : this.u2index > other.u2index ? 1 : + this.u2length < other.u2length ? -1 : this.u2length > other.u2length ? 1 : + this.u2descriptorIndex < other.u2descriptorIndex ? -1 : this.u2descriptorIndex > other.u2descriptorIndex ? 1 : + this.u2nameIndex < other.u2nameIndex ? -1 : this.u2nameIndex > other.u2nameIndex ? 1 : + 0; + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/LocalVariableTableAttribute.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/LocalVariableTableAttribute.java new file mode 100644 index 0000000000..67fe03120c --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/LocalVariableTableAttribute.java @@ -0,0 +1,79 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute; + +import proguard.classfile.*; +import proguard.classfile.attribute.visitor.*; + +/** + * This Attribute represents a local variable table attribute. + * + * @author Eric Lafortune + */ +public class LocalVariableTableAttribute extends Attribute +{ + public int u2localVariableTableLength; + public LocalVariableInfo[] localVariableTable; + + + /** + * Creates an uninitialized LocalVariableTableAttribute. + */ + public LocalVariableTableAttribute() + { + } + + + /** + * Creates an initialized LocalVariableTableAttribute. + */ + public LocalVariableTableAttribute(int u2attributeNameIndex, + int u2localVariableTableLength, + LocalVariableInfo[] localVariableTable) + { + super(u2attributeNameIndex); + + this.u2localVariableTableLength = u2localVariableTableLength; + this.localVariableTable = localVariableTable; + } + + + // Implementations for Attribute. + + public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitLocalVariableTableAttribute(clazz, method, codeAttribute, this); + } + + + /** + * Applies the given visitor to all local variables. + */ + public void localVariablesAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, LocalVariableInfoVisitor localVariableInfoVisitor) + { + for (int index = 0; index < u2localVariableTableLength; index++) + { + // We don't need double dispatching here, since there is only one + // type of LocalVariableInfo. + localVariableInfoVisitor.visitLocalVariableInfo(clazz, method, codeAttribute, localVariableTable[index]); + } + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/LocalVariableTypeInfo.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/LocalVariableTypeInfo.java new file mode 100644 index 0000000000..918d0991bb --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/LocalVariableTypeInfo.java @@ -0,0 +1,143 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute; + +import proguard.classfile.*; +import proguard.classfile.visitor.ClassVisitor; + +/** + * Representation of an Local Variable table entry. + * + * @author Eric Lafortune + */ +public class LocalVariableTypeInfo implements VisitorAccepter, Comparable +{ + public int u2startPC; + public int u2length; + public int u2nameIndex; + public int u2signatureIndex; + public int u2index; + + /** + * An extra field pointing to the Clazz objects referenced in the + * type string. This field is typically filled out by the <code>{@link + * proguard.classfile.util.ClassReferenceInitializer + * ClassReferenceInitializer}</code>. + * References to primitive types are ignored. + */ + public Clazz[] referencedClasses; + + /** + * An extra field in which visitors can store information. + */ + public Object visitorInfo; + + + /** + * Creates an uninitialized LocalVariableTypeInfo. + */ + public LocalVariableTypeInfo() + { + } + + + /** + * Creates an initialized LocalVariableTypeInfo. + */ + public LocalVariableTypeInfo(int u2startPC, + int u2length, + int u2nameIndex, + int u2signatureIndex, + int u2index) + { + this.u2startPC = u2startPC; + this.u2length = u2length; + this.u2nameIndex = u2nameIndex; + this.u2signatureIndex = u2signatureIndex; + this.u2index = u2index; + } + + + /** + * Returns the name. + */ + public String getName(Clazz clazz) + { + return clazz.getString(u2nameIndex); + } + + + /** + * Returns the signature. + */ + public String getSignature(Clazz clazz) + { + return clazz.getString(u2signatureIndex); + } + + + /** + * Applies the given visitor to all referenced classes. + */ + public void referencedClassesAccept(ClassVisitor classVisitor) + { + if (referencedClasses != null) + { + for (int index = 0; index < referencedClasses.length; index++) + { + Clazz referencedClass = referencedClasses[index]; + if (referencedClass != null) + { + referencedClass.accept(classVisitor); + } + } + } + } + + + // Implementations for VisitorAccepter. + + public Object getVisitorInfo() + { + return visitorInfo; + } + + public void setVisitorInfo(Object visitorInfo) + { + this.visitorInfo = visitorInfo; + } + + + // Implementations for Comparable. + + public int compareTo(Object object) + { + LocalVariableTypeInfo other = (LocalVariableTypeInfo)object; + + return + this.u2startPC < other.u2startPC ? -1 : this.u2startPC > other.u2startPC ? 1 : + this.u2length < other.u2length ? -1 : this.u2length > other.u2length ? 1 : + this.u2index < other.u2index ? -1 : this.u2index > other.u2index ? 1 : + this.u2signatureIndex < other.u2signatureIndex ? -1 : this.u2signatureIndex > other.u2signatureIndex ? 1 : + this.u2nameIndex < other.u2nameIndex ? -1 : this.u2nameIndex > other.u2nameIndex ? 1 : + 0; + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/LocalVariableTypeTableAttribute.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/LocalVariableTypeTableAttribute.java new file mode 100644 index 0000000000..1c644347aa --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/LocalVariableTypeTableAttribute.java @@ -0,0 +1,79 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute; + +import proguard.classfile.*; +import proguard.classfile.attribute.visitor.*; + +/** + * This Attribute represents a local variable table type attribute. + * + * @author Eric Lafortune + */ +public class LocalVariableTypeTableAttribute extends Attribute +{ + public int u2localVariableTypeTableLength; + public LocalVariableTypeInfo[] localVariableTypeTable; + + + /** + * Creates an uninitialized LocalVariableTypeTableAttribute. + */ + public LocalVariableTypeTableAttribute() + { + } + + + /** + * Creates an initialized LocalVariableTypeTableAttribute. + */ + public LocalVariableTypeTableAttribute(int u2attributeNameIndex, + int u2localVariableTypeTableLength, + LocalVariableTypeInfo[] localVariableTypeTable) + { + super(u2attributeNameIndex); + + this.u2localVariableTypeTableLength = u2localVariableTypeTableLength; + this.localVariableTypeTable = localVariableTypeTable; + } + + + // Implementations for Attribute. + + public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitLocalVariableTypeTableAttribute(clazz, method, codeAttribute, this); + } + + + /** + * Applies the given visitor to all local variable types. + */ + public void localVariablesAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, LocalVariableTypeInfoVisitor localVariableTypeInfoVisitor) + { + for (int index = 0; index < u2localVariableTypeTableLength; index++) + { + // We don't need double dispatching here, since there is only one + // type of LocalVariableTypeInfo. + localVariableTypeInfoVisitor.visitLocalVariableTypeInfo(clazz, method, codeAttribute, localVariableTypeTable[index]); + } + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/MethodParametersAttribute.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/MethodParametersAttribute.java new file mode 100644 index 0000000000..30086ae740 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/MethodParametersAttribute.java @@ -0,0 +1,80 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute; + +import proguard.classfile.*; +import proguard.classfile.attribute.visitor.*; + +/** + * This Attribute represents a method parameters attribute. + * + * @author Eric Lafortune + */ +public class MethodParametersAttribute extends Attribute +{ + public int u1parametersCount; + public ParameterInfo[] parameters; + + + /** + * Creates an uninitialized MethodParametersAttribute. + */ + public MethodParametersAttribute() + { + } + + + /** + * Creates an initialized MethodParametersAttribute. + */ + public MethodParametersAttribute(int u2attributeNameIndex, + int u1parametersCount, + ParameterInfo[] parameters) + { + super(u2attributeNameIndex); + + this.u1parametersCount = u1parametersCount; + this.parameters = parameters; + } + + + // Implementations for Attribute. + + public void accept(Clazz clazz, Method method, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitMethodParametersAttribute(clazz, method, this); + } + + + /** + * Applies the given visitor to all parameters. + */ + public void parametersAccept(Clazz clazz, Method method, ParameterInfoVisitor parameterInfoVisitor) + { + // Loop over all parameters. + for (int index = 0; index < u1parametersCount; index++) + { + // We don't need double dispatching here, since there is only one + // type of ParameterInfo. + parameterInfoVisitor.visitParameterInfo(clazz, method, index, parameters[index]); + } + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/ParameterInfo.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/ParameterInfo.java new file mode 100644 index 0000000000..e0a8f32b54 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/ParameterInfo.java @@ -0,0 +1,81 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute; + +import proguard.classfile.*; + +/** + * Representation of a parameter, as defined in a method parameters + * attribute. + * + * @author Eric Lafortune + */ +public class ParameterInfo implements VisitorAccepter +{ + public int u2nameIndex; + public int u2accessFlags; + + /** + * An extra field in which visitors can store information. + */ + public Object visitorInfo; + + + /** + * Creates an uninitialized ParameterInfo. + */ + public ParameterInfo() + { + } + + + /** + * Creates an initialized ParameterInfo. + */ + public ParameterInfo(int u2nameIndex, + int u2accessFlags) + { + this.u2nameIndex = u2nameIndex; + this.u2accessFlags = u2accessFlags; + } + + + /** + * Returns the parameter name. + */ + public String getName(Clazz clazz) + { + return clazz.getString(u2nameIndex); + } + + + // Implementations for VisitorAccepter. + + public Object getVisitorInfo() + { + return visitorInfo; + } + + public void setVisitorInfo(Object visitorInfo) + { + this.visitorInfo = visitorInfo; + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/SignatureAttribute.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/SignatureAttribute.java new file mode 100644 index 0000000000..943056ff98 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/SignatureAttribute.java @@ -0,0 +1,111 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute; + +import proguard.classfile.*; +import proguard.classfile.attribute.visitor.AttributeVisitor; +import proguard.classfile.visitor.ClassVisitor; + +/** + * This Attribute represents a signature attribute. + * + * @author Eric Lafortune + */ +public class SignatureAttribute extends Attribute +{ + public int u2signatureIndex; + + /** + * An extra field containing all the classes referenced in the + * signature string. This field is filled out by the {@link + * proguard.classfile.util.ClassReferenceInitializer ClassReferenceInitializer}. + * The size of the array is the number of classes in the signature. + * Primitive types and arrays of primitive types are ignored. + * Unknown classes are represented as null values. + */ + public Clazz[] referencedClasses; + + + /** + * Creates an uninitialized SignatureAttribute. + */ + public SignatureAttribute() + { + } + + + /** + * Creates an initialized SignatureAttribute. + */ + public SignatureAttribute(int u2attributeNameIndex, + int u2signatureIndex) + { + super(u2attributeNameIndex); + + this.u2signatureIndex = u2signatureIndex; + } + + + /** + * Returns the signature. + */ + public String getSignature(Clazz clazz) + { + return clazz.getString(u2signatureIndex); + } + + + /** + * Lets the Clazz objects referenced in the signature string accept the + * given visitor. + */ + public void referencedClassesAccept(ClassVisitor classVisitor) + { + if (referencedClasses != null) + { + for (int index = 0; index < referencedClasses.length; index++) + { + if (referencedClasses[index] != null) + { + referencedClasses[index].accept(classVisitor); + } + } + } + } + + + // Implementations for Attribute. + + public void accept(Clazz clazz, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitSignatureAttribute(clazz, this); + } + + public void accept(Clazz clazz, Field field, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitSignatureAttribute(clazz, field, this); + } + + public void accept(Clazz clazz, Method method, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitSignatureAttribute(clazz, method, this); + } + } diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/SourceDirAttribute.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/SourceDirAttribute.java new file mode 100644 index 0000000000..10328cf92e --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/SourceDirAttribute.java @@ -0,0 +1,62 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute; + +import proguard.classfile.Clazz; +import proguard.classfile.attribute.visitor.AttributeVisitor; + +/** + * This Attribute represents a source directory attribute. + * + * @author Eric Lafortune + */ +public class SourceDirAttribute extends Attribute +{ + public int u2sourceDirIndex; + + + /** + * Creates an uninitialized SourceDirAttribute. + */ + public SourceDirAttribute() + { + } + + + /** + * Creates an initialized SourceDirAttribute. + */ + public SourceDirAttribute(int u2attributeNameIndex, + int u2sourceDirIndex) + { + super(u2attributeNameIndex); + + this.u2sourceDirIndex = u2sourceDirIndex; + } + + + // Implementations for Attribute. + + public void accept(Clazz clazz, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitSourceDirAttribute(clazz, this); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/SourceFileAttribute.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/SourceFileAttribute.java new file mode 100644 index 0000000000..86535b4b30 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/SourceFileAttribute.java @@ -0,0 +1,62 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute; + +import proguard.classfile.Clazz; +import proguard.classfile.attribute.visitor.AttributeVisitor; + +/** + * This Attribute represents a source file attribute. + * + * @author Eric Lafortune + */ +public class SourceFileAttribute extends Attribute +{ + public int u2sourceFileIndex; + + + /** + * Creates an uninitialized SourceFileAttribute. + */ + public SourceFileAttribute() + { + } + + + /** + * Creates an initialized SourceFileAttribute. + */ + public SourceFileAttribute(int u2attributeNameIndex, + int u2sourceFileIndex) + { + super(u2attributeNameIndex); + + this.u2sourceFileIndex = u2sourceFileIndex; + } + + + // Implementations for Attribute. + + public void accept(Clazz clazz, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitSourceFileAttribute(clazz, this); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/SyntheticAttribute.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/SyntheticAttribute.java new file mode 100644 index 0000000000..b3120db198 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/SyntheticAttribute.java @@ -0,0 +1,66 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute; + +import proguard.classfile.*; +import proguard.classfile.attribute.visitor.AttributeVisitor; + +/** + * This Attribute represents a synthetic attribute. + * + * @author Eric Lafortune + */ +public class SyntheticAttribute extends Attribute +{ + /** + * Creates an uninitialized SyntheticAttribute. + */ + public SyntheticAttribute() + { + } + + + /** + * Creates an initialized SyntheticAttribute. + */ + public SyntheticAttribute(int u2attributeNameIndex) + { + super(u2attributeNameIndex); + } + + + // Implementations for Attribute. + + public void accept(Clazz clazz, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitSyntheticAttribute(clazz, this); + } + + public void accept(Clazz clazz, Field field, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitSyntheticAttribute(clazz, field, this); + } + + public void accept(Clazz clazz, Method method, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitSyntheticAttribute(clazz, method, this); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/UnknownAttribute.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/UnknownAttribute.java new file mode 100644 index 0000000000..6654bf6f43 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/UnknownAttribute.java @@ -0,0 +1,84 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute; + + +import proguard.classfile.*; +import proguard.classfile.attribute.visitor.AttributeVisitor; + +/** + * This Attribute represents an unknown attribute. + * + * @author Eric Lafortune + */ +public class UnknownAttribute extends Attribute +{ + public final int u4attributeLength; + public byte[] info; + + + /** + * Creates an uninitialized UnknownAttribute with the specified name and + * length. + */ + public UnknownAttribute(int u2attributeNameIndex, + int attributeLength) + { + this(u2attributeNameIndex, attributeLength, null); + } + + + /** + * Creates an initialized UnknownAttribute. + */ + public UnknownAttribute(int u2attributeNameIndex, + int u4attributeLength, + byte[] info) + { + super(u2attributeNameIndex); + + this.u4attributeLength = u4attributeLength; + this.info = info; + } + + + // Implementations for Attribute. + + public void accept(Clazz clazz, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitUnknownAttribute(clazz, this); + } + + public void accept(Clazz clazz, Field field, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitUnknownAttribute(clazz, this); + } + + public void accept(Clazz clazz, Method method, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitUnknownAttribute(clazz, this); + } + + public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitUnknownAttribute(clazz, this); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/Annotation.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/Annotation.java new file mode 100644 index 0000000000..1b02799e8b --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/Annotation.java @@ -0,0 +1,143 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation; + +import proguard.classfile.*; +import proguard.classfile.attribute.annotation.visitor.ElementValueVisitor; +import proguard.classfile.visitor.ClassVisitor; + +/** + * Representation of an annotation. + * + * @author Eric Lafortune + */ +public class Annotation implements VisitorAccepter +{ + public int u2typeIndex; + public int u2elementValuesCount; + public ElementValue[] elementValues; + + /** + * An extra field pointing to the Clazz objects referenced in the + * type string. This field is typically filled out by the <code>{@link + * proguard.classfile.util.ClassReferenceInitializer + * ClassReferenceInitializer}</code>. + * References to primitive types are ignored. + */ + public Clazz[] referencedClasses; + + /** + * An extra field in which visitors can store information. + */ + public Object visitorInfo; + + + /** + * Creates an uninitialized Annotation. + */ + public Annotation() + { + } + + + /** + * Creates an initialized Annotation. + */ + public Annotation(int u2typeIndex, + int u2elementValuesCount, + ElementValue[] elementValues) + { + this.u2typeIndex = u2typeIndex; + this.u2elementValuesCount = u2elementValuesCount; + this.elementValues = elementValues; + } + + + /** + * Returns the type. + */ + public String getType(Clazz clazz) + { + return clazz.getString(u2typeIndex); + } + + + + /** + * Applies the given visitor to the first referenced class. This is the + * main annotation class. + */ + public void referencedClassAccept(ClassVisitor classVisitor) + { + if (referencedClasses != null) + { + Clazz referencedClass = referencedClasses[0]; + if (referencedClass != null) + { + referencedClass.accept(classVisitor); + } + } + } + + + /** + * Applies the given visitor to all referenced classes. + */ + public void referencedClassesAccept(ClassVisitor classVisitor) + { + if (referencedClasses != null) + { + for (int index = 0; index < referencedClasses.length; index++) + { + Clazz referencedClass = referencedClasses[index]; + if (referencedClass != null) + { + referencedClass.accept(classVisitor); + } + } + } + } + + + /** + * Applies the given visitor to all element value pairs. + */ + public void elementValuesAccept(Clazz clazz, ElementValueVisitor elementValueVisitor) + { + for (int index = 0; index < u2elementValuesCount; index++) + { + elementValues[index].accept(clazz, this, elementValueVisitor); + } + } + + + // Implementations for VisitorAccepter. + + public Object getVisitorInfo() + { + return visitorInfo; + } + + public void setVisitorInfo(Object visitorInfo) + { + this.visitorInfo = visitorInfo; + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/AnnotationDefaultAttribute.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/AnnotationDefaultAttribute.java new file mode 100644 index 0000000000..85fc79250e --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/AnnotationDefaultAttribute.java @@ -0,0 +1,73 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation; + +import proguard.classfile.*; +import proguard.classfile.attribute.Attribute; +import proguard.classfile.attribute.annotation.visitor.ElementValueVisitor; +import proguard.classfile.attribute.visitor.AttributeVisitor; + +/** + * This Attribute represents an annotation default attribute. + * + * @author Eric Lafortune + */ +public class AnnotationDefaultAttribute extends Attribute +{ + public ElementValue defaultValue; + + + /** + * Creates an uninitialized AnnotationDefaultAttribute. + */ + public AnnotationDefaultAttribute() + { + } + + + /** + * Creates an initialized AnnotationDefaultAttribute. + */ + public AnnotationDefaultAttribute(int u2attributeNameIndex, + ElementValue defaultValue) + { + super(u2attributeNameIndex); + + this.defaultValue = defaultValue; + } + + + /** + * Applies the given visitor to the default element value. + */ + public void defaultValueAccept(Clazz clazz, ElementValueVisitor elementValueVisitor) + { + defaultValue.accept(clazz, null, elementValueVisitor); + } + + + // Implementations for Attribute. + + public void accept(Clazz clazz, Method method, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitAnnotationDefaultAttribute(clazz, method, this); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/AnnotationElementValue.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/AnnotationElementValue.java new file mode 100644 index 0000000000..b957f82f55 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/AnnotationElementValue.java @@ -0,0 +1,76 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation; + +import proguard.classfile.*; +import proguard.classfile.attribute.annotation.visitor.*; + +/** + * This ElementValue represents an annotation element value. + * + * @author Eric Lafortune + */ +public class AnnotationElementValue extends ElementValue +{ + public Annotation annotationValue; + + + /** + * Creates an uninitialized AnnotationElementValue. + */ + public AnnotationElementValue() + { + } + + + /** + * Creates an initialized AnnotationElementValue. + */ + public AnnotationElementValue(int u2elementNameIndex, + Annotation annotationValue) + { + super(u2elementNameIndex); + + this.annotationValue = annotationValue; + } + + + /** + * Applies the given visitor to the annotation. + */ + public void annotationAccept(Clazz clazz, AnnotationVisitor annotationVisitor) + { + annotationVisitor.visitAnnotation(clazz, annotationValue); + } + + + // Implementations for ElementValue. + + public char getTag() + { + return ClassConstants.ELEMENT_VALUE_ANNOTATION; + } + + public void accept(Clazz clazz, Annotation annotation, ElementValueVisitor elementValueVisitor) + { + elementValueVisitor.visitAnnotationElementValue(clazz, annotation, this); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/AnnotationsAttribute.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/AnnotationsAttribute.java new file mode 100644 index 0000000000..167710e01f --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/AnnotationsAttribute.java @@ -0,0 +1,114 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation; + +import proguard.classfile.*; +import proguard.classfile.attribute.*; +import proguard.classfile.attribute.annotation.visitor.AnnotationVisitor; + +/** + * This Attribute represents an annotations attribute. + * + * @author Eric Lafortune + */ +public abstract class AnnotationsAttribute extends Attribute +{ + public int u2annotationsCount; + public Annotation[] annotations; + + + /** + * Creates an uninitialized AnnotationsAttribute. + */ + protected AnnotationsAttribute() + { + } + + + /** + * Creates an initialized AnnotationsAttribute. + */ + protected AnnotationsAttribute(int u2attributeNameIndex, + int u2annotationsCount, + Annotation[] annotations) + { + super(u2attributeNameIndex); + + this.u2annotationsCount = u2annotationsCount; + this.annotations = annotations; + } + + + /** + * Applies the given visitor to all class annotations. + */ + public void annotationsAccept(Clazz clazz, AnnotationVisitor annotationVisitor) + { + for (int index = 0; index < u2annotationsCount; index++) + { + // We don't need double dispatching here, since there is only one + // type of Annotation. + annotationVisitor.visitAnnotation(clazz, annotations[index]); + } + } + + + /** + * Applies the given visitor to all field annotations. + */ + public void annotationsAccept(Clazz clazz, Field field, AnnotationVisitor annotationVisitor) + { + for (int index = 0; index < u2annotationsCount; index++) + { + // We don't need double dispatching here, since there is only one + // type of Annotation. + annotationVisitor.visitAnnotation(clazz, field, annotations[index]); + } + } + + + /** + * Applies the given visitor to all method annotations. + */ + public void annotationsAccept(Clazz clazz, Method method, AnnotationVisitor annotationVisitor) + { + for (int index = 0; index < u2annotationsCount; index++) + { + // We don't need double dispatching here, since there is only one + // type of Annotation. + annotationVisitor.visitAnnotation(clazz, method, annotations[index]); + } + } + + + /** + * Applies the given visitor to all code attribute annotations. + */ + public void annotationsAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, AnnotationVisitor annotationVisitor) + { + for (int index = 0; index < u2annotationsCount; index++) + { + // We don't need double dispatching here, since there is only one + // type of Annotation. + annotationVisitor.visitAnnotation(clazz, method, codeAttribute, annotations[index]); + } + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/ArrayElementValue.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/ArrayElementValue.java new file mode 100644 index 0000000000..06c84177ea --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/ArrayElementValue.java @@ -0,0 +1,82 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation; + +import proguard.classfile.*; +import proguard.classfile.attribute.annotation.visitor.ElementValueVisitor; + +/** + * This ElementValue represents an array element value. + * + * @author Eric Lafortune + */ +public class ArrayElementValue extends ElementValue +{ + public int u2elementValuesCount; + public ElementValue[] elementValues; + + + /** + * Creates an uninitialized ArrayElementValue. + */ + public ArrayElementValue() + { + } + + + /** + * Creates an initialized ArrayElementValue. + */ + public ArrayElementValue(int u2elementNameIndex, + int u2elementValuesCount, + ElementValue[] elementValues) + { + super(u2elementNameIndex); + + this.u2elementValuesCount = u2elementValuesCount; + this.elementValues = elementValues; + } + + + // Implementations for ElementValue. + + public char getTag() + { + return ClassConstants.ELEMENT_VALUE_ARRAY; + } + + public void accept(Clazz clazz, Annotation annotation, ElementValueVisitor elementValueVisitor) + { + elementValueVisitor.visitArrayElementValue(clazz, annotation, this); + } + + + /** + * Applies the given visitor to all nested element values. + */ + public void elementValuesAccept(Clazz clazz, Annotation annotation, ElementValueVisitor elementValueVisitor) + { + for (int index = 0; index < u2elementValuesCount; index++) + { + elementValues[index].accept(clazz, annotation, elementValueVisitor); + } + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/ClassElementValue.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/ClassElementValue.java new file mode 100644 index 0000000000..945d280a27 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/ClassElementValue.java @@ -0,0 +1,104 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation; + +import proguard.classfile.*; +import proguard.classfile.attribute.annotation.visitor.ElementValueVisitor; +import proguard.classfile.visitor.ClassVisitor; + +/** + * This ElementValue represents a class element value. + * + * @author Eric Lafortune + */ +public class ClassElementValue extends ElementValue +{ + public int u2classInfoIndex; + + /** + * An extra field pointing to the Clazz objects referenced in the + * type name string. This field is filled out by the <code>{@link + * proguard.classfile.util.ClassReferenceInitializer ClassReferenceInitializer}</code>. + * References to primitive types are ignored. + */ + public Clazz[] referencedClasses; + + + /** + * Creates an uninitialized ClassElementValue. + */ + public ClassElementValue() + { + } + + + /** + * Creates an initialized ClassElementValue. + */ + public ClassElementValue(int u2elementNameIndex, + int u2classInfoIndex) + { + super(u2elementNameIndex); + + this.u2classInfoIndex = u2classInfoIndex; + } + + + /** + * Returns the class info name. + */ + public String getClassName(Clazz clazz) + { + return clazz.getString(u2classInfoIndex); + } + + + /** + * Applies the given visitor to all referenced classes. + */ + public void referencedClassesAccept(ClassVisitor classVisitor) + { + if (referencedClasses != null) + { + for (int index = 0; index < referencedClasses.length; index++) + { + Clazz referencedClass = referencedClasses[index]; + if (referencedClass != null) + { + referencedClass.accept(classVisitor); + } + } + } + } + + + // Implementations for ElementValue. + + public char getTag() + { + return ClassConstants.ELEMENT_VALUE_CLASS; + } + + public void accept(Clazz clazz, Annotation annotation, ElementValueVisitor elementValueVisitor) + { + elementValueVisitor.visitClassElementValue(clazz, annotation, this); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/ConstantElementValue.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/ConstantElementValue.java new file mode 100644 index 0000000000..0e7a4b6ff9 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/ConstantElementValue.java @@ -0,0 +1,71 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation; + +import proguard.classfile.Clazz; +import proguard.classfile.attribute.annotation.visitor.ElementValueVisitor; + +/** + * This ElementValue represents a constant element value. + * + * @author Eric Lafortune + */ +public class ConstantElementValue extends ElementValue +{ + public final char u1tag; + public int u2constantValueIndex; + + + /** + * Creates an uninitialized ConstantElementValue. + */ + public ConstantElementValue(char u1tag) + { + this.u1tag = u1tag; + } + + + /** + * Creates an initialized ConstantElementValue. + */ + public ConstantElementValue(char u1tag, + int u2elementNameIndex, + int u2constantValueIndex) + { + super(u2elementNameIndex); + + this.u1tag = u1tag; + this.u2constantValueIndex = u2constantValueIndex; + } + + + // Implementations for ElementValue. + + public char getTag() + { + return u1tag; + } + + public void accept(Clazz clazz, Annotation annotation, ElementValueVisitor elementValueVisitor) + { + elementValueVisitor.visitConstantElementValue(clazz, annotation, this); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/ElementValue.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/ElementValue.java new file mode 100644 index 0000000000..8d18c1f5ef --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/ElementValue.java @@ -0,0 +1,126 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation; + +import proguard.classfile.*; +import proguard.classfile.attribute.annotation.visitor.ElementValueVisitor; +import proguard.classfile.visitor.MemberVisitor; + +/** + * This abstract class represents an element value that is attached to an + * annotation or an annotation default. Specific types of element values are + * subclassed from it. + * + * @author Eric Lafortune + */ +public abstract class ElementValue implements VisitorAccepter +{ + /** + * An extra field for the optional element name. It is used in element value + * pairs of annotations. Otherwise, it is 0. + */ + public int u2elementNameIndex; + + /** + * An extra field pointing to the referenced <code>Clazz</code> + * object, if applicable. This field is typically filled out by the + * <code>{@link proguard.classfile.util.ClassReferenceInitializer}</code>. + */ + public Clazz referencedClass; + + /** + * An extra field pointing to the referenced <code>Method</code> + * object, if applicable. This field is typically filled out by the + * <code>{@link proguard.classfile.util.ClassReferenceInitializer}</code>. + */ + public Method referencedMethod; + + /** + * An extra field in which visitors can store information. + */ + public Object visitorInfo; + + + /** + * Creates an uninitialized ElementValue. + */ + protected ElementValue() + { + } + + + /** + * Creates an initialized ElementValue. + */ + protected ElementValue(int u2elementNameIndex) + { + this.u2elementNameIndex = u2elementNameIndex; + } + + + /** + * Returns the element name. + */ + public String getMethodName(Clazz clazz) + { + return clazz.getString(u2elementNameIndex); + } + + + // Abstract methods to be implemented by extensions. + + /** + * Returns the tag of this element value. + */ + public abstract char getTag(); + + + /** + * Accepts the given visitor. + */ + public abstract void accept(Clazz clazz, Annotation annotation, ElementValueVisitor elementValueVisitor); + + + + /** + * Applies the given visitor to the referenced method. + */ + public void referencedMethodAccept(MemberVisitor memberVisitor) + { + if (referencedMethod != null) + { + referencedMethod.accept(referencedClass, memberVisitor); + } + } + + + // Implementations for VisitorAccepter. + + public Object getVisitorInfo() + { + return visitorInfo; + } + + public void setVisitorInfo(Object visitorInfo) + { + this.visitorInfo = visitorInfo; + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/EnumConstantElementValue.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/EnumConstantElementValue.java new file mode 100644 index 0000000000..8a82cd79a6 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/EnumConstantElementValue.java @@ -0,0 +1,138 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation; + +import proguard.classfile.*; +import proguard.classfile.attribute.annotation.visitor.ElementValueVisitor; +import proguard.classfile.visitor.*; + +/** + * This ElementValue represents an enumeration constant element value. + * + * @author Eric Lafortune + */ +public class EnumConstantElementValue extends ElementValue +{ + public int u2typeNameIndex; + public int u2constantNameIndex; + + /** + * An extra field pointing to the Clazz objects referenced in the + * type name string. This field is typically filled out by the <code>{@link + * proguard.classfile.util.ClassReferenceInitializer + * ClassReferenceInitializer}</code>. + * References to primitive types are ignored. + */ + public Clazz[] referencedClasses; + + /** + * An extra field optionally pointing to the referenced enum Field object. + * This field is typically filled out by the <code>{@link + * proguard.classfile.util.ClassReferenceInitializer + * ClassReferenceInitializer}</code>. + */ + public Field referencedField; + + + /** + * Creates an uninitialized EnumConstantElementValue. + */ + public EnumConstantElementValue() + { + } + + + /** + * Creates an initialized EnumConstantElementValue. + */ + public EnumConstantElementValue(int u2elementNameIndex, + int u2typeNameIndex, + int u2constantNameIndex) + { + super(u2elementNameIndex); + + this.u2typeNameIndex = u2typeNameIndex; + this.u2constantNameIndex = u2constantNameIndex; + } + + + /** + * Returns the enumeration type name. + */ + public String getTypeName(Clazz clazz) + { + return clazz.getString(u2typeNameIndex); + } + + + /** + * Returns the constant name. + */ + public String getConstantName(Clazz clazz) + { + return clazz.getString(u2constantNameIndex); + } + + + /** + * Applies the given visitor to all referenced classes. + */ + public void referencedClassesAccept(ClassVisitor classVisitor) + { + if (referencedClasses != null) + { + for (int index = 0; index < referencedClasses.length; index++) + { + Clazz referencedClass = referencedClasses[index]; + if (referencedClass != null) + { + referencedClass.accept(classVisitor); + } + } + } + } + + + /** + * Applies the given visitor to the referenced field. + */ + public void referencedFieldAccept(MemberVisitor memberVisitor) + { + if (referencedField != null) + { + referencedField.accept(referencedClasses[0], + memberVisitor); + } + } + + + // Implementations for ElementValue. + + public char getTag() + { + return ClassConstants.ELEMENT_VALUE_ENUM_CONSTANT; + } + + public void accept(Clazz clazz, Annotation annotation, ElementValueVisitor elementValueVisitor) + { + elementValueVisitor.visitEnumConstantElementValue(clazz, annotation, this); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/ParameterAnnotationsAttribute.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/ParameterAnnotationsAttribute.java new file mode 100644 index 0000000000..666762f4a6 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/ParameterAnnotationsAttribute.java @@ -0,0 +1,83 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation; + +import proguard.classfile.*; +import proguard.classfile.attribute.Attribute; +import proguard.classfile.attribute.annotation.visitor.AnnotationVisitor; + +/** + * This Attribute represents a parameter annotations attribute. + * + * @author Eric Lafortune + */ +public abstract class ParameterAnnotationsAttribute extends Attribute +{ + public int u1parametersCount; + public int[] u2parameterAnnotationsCount; + public Annotation[][] parameterAnnotations; + + + /** + * Creates an uninitialized ParameterAnnotationsAttribute. + */ + protected ParameterAnnotationsAttribute() + { + } + + + /** + * Creates an initialized ParameterAnnotationsAttribute. + */ + protected ParameterAnnotationsAttribute(int u2attributeNameIndex, + int u1parametersCount, + int[] u2parameterAnnotationsCount, + Annotation[][] parameterAnnotations) + { + super(u2attributeNameIndex); + + this.u1parametersCount = u1parametersCount; + this.u2parameterAnnotationsCount = u2parameterAnnotationsCount; + this.parameterAnnotations = parameterAnnotations; + } + + + /** + * Applies the given visitor to all annotations. + */ + public void annotationsAccept(Clazz clazz, Method method, AnnotationVisitor annotationVisitor) + { + // Loop over all parameters. + for (int parameterIndex = 0; parameterIndex < u1parametersCount; parameterIndex++) + { + int annotationsCount = u2parameterAnnotationsCount[parameterIndex]; + Annotation[] annotations = parameterAnnotations[parameterIndex]; + + // Loop over all parameter annotations. + for (int index = 0; index < annotationsCount; index++) + { + // We don't need double dispatching here, since there is only one + // type of Annotation. + annotationVisitor.visitAnnotation(clazz, method, parameterIndex, annotations[index]); + } + } + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/RuntimeInvisibleAnnotationsAttribute.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/RuntimeInvisibleAnnotationsAttribute.java new file mode 100644 index 0000000000..6e2a416d88 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/RuntimeInvisibleAnnotationsAttribute.java @@ -0,0 +1,70 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation; + +import proguard.classfile.*; +import proguard.classfile.attribute.visitor.AttributeVisitor; + +/** + * This Attribute represents a runtime invisible annotations attribute. + * + * @author Eric Lafortune + */ +public class RuntimeInvisibleAnnotationsAttribute extends AnnotationsAttribute +{ + /** + * Creates an uninitialized RuntimeInvisibleAnnotationsAttribute. + */ + public RuntimeInvisibleAnnotationsAttribute() + { + } + + + /** + * Creates an initialized RuntimeInvisibleAnnotationsAttribute. + */ + public RuntimeInvisibleAnnotationsAttribute(int u2attributeNameIndex, + int u2annotationsCount, + Annotation[] annotations) + { + super(u2attributeNameIndex, u2annotationsCount, annotations); + } + + +// Implementations for Attribute. + + public void accept(Clazz clazz, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitRuntimeInvisibleAnnotationsAttribute(clazz, this); + } + + + public void accept(Clazz clazz, Field field, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitRuntimeInvisibleAnnotationsAttribute(clazz, field, this); + } + + + public void accept(Clazz clazz, Method method, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitRuntimeInvisibleAnnotationsAttribute(clazz, method, this); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/RuntimeInvisibleParameterAnnotationsAttribute.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/RuntimeInvisibleParameterAnnotationsAttribute.java new file mode 100644 index 0000000000..b9772bd225 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/RuntimeInvisibleParameterAnnotationsAttribute.java @@ -0,0 +1,62 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation; + +import proguard.classfile.*; +import proguard.classfile.attribute.visitor.AttributeVisitor; + +/** + * This Attribute represents a runtime invisible parameter annotations attribute. + * + * @author Eric Lafortune + */ +public class RuntimeInvisibleParameterAnnotationsAttribute extends ParameterAnnotationsAttribute +{ + /** + * Creates an uninitialized RuntimeInvisibleParameterAnnotationsAttribute. + */ + public RuntimeInvisibleParameterAnnotationsAttribute() + { + } + + + /** + * Creates an initialized RuntimeInvisibleParameterAnnotationsAttribute. + */ + public RuntimeInvisibleParameterAnnotationsAttribute(int u2attributeNameIndex, + int u1parametersCount, + int[] u2parameterAnnotationsCount, + Annotation[][] parameterAnnotations) + { + super(u2attributeNameIndex, + u1parametersCount, + u2parameterAnnotationsCount, + parameterAnnotations); + } + + + // Implementations for Attribute. + + public void accept(Clazz clazz, Method method, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitRuntimeInvisibleParameterAnnotationsAttribute(clazz, method, this); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/RuntimeInvisibleTypeAnnotationsAttribute.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/RuntimeInvisibleTypeAnnotationsAttribute.java new file mode 100644 index 0000000000..6addf96dc7 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/RuntimeInvisibleTypeAnnotationsAttribute.java @@ -0,0 +1,77 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.visitor.AttributeVisitor; + +/** + * This Attribute represents a runtime invisible type annotations attribute. + * + * @author Eric Lafortune + */ +public class RuntimeInvisibleTypeAnnotationsAttribute extends TypeAnnotationsAttribute +{ + /** + * Creates an uninitialized RuntimeInvisibleTypeAnnotationsAttribute. + */ + public RuntimeInvisibleTypeAnnotationsAttribute() + { + } + + + /** + * Creates an initialized RuntimeInvisibleTypeAnnotationsAttribute. + */ + public RuntimeInvisibleTypeAnnotationsAttribute(int u2attributeNameIndex, + int u2annotationsCount, + TypeAnnotation[] annotations) + { + super(u2attributeNameIndex, u2annotationsCount, annotations); + } + + + // Implementations for Attribute. + + public void accept(Clazz clazz, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitRuntimeInvisibleTypeAnnotationsAttribute(clazz, this); + } + + + public void accept(Clazz clazz, Field field, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitRuntimeInvisibleTypeAnnotationsAttribute(clazz, field, this); + } + + + public void accept(Clazz clazz, Method method, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitRuntimeInvisibleTypeAnnotationsAttribute(clazz, method, this); + } + + + public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitRuntimeInvisibleTypeAnnotationsAttribute(clazz, method, codeAttribute, this); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/RuntimeVisibleAnnotationsAttribute.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/RuntimeVisibleAnnotationsAttribute.java new file mode 100644 index 0000000000..7b5ff00304 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/RuntimeVisibleAnnotationsAttribute.java @@ -0,0 +1,70 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation; + +import proguard.classfile.*; +import proguard.classfile.attribute.visitor.AttributeVisitor; + +/** + * This Attribute represents a runtime visible annotations attribute. + * + * @author Eric Lafortune + */ +public class RuntimeVisibleAnnotationsAttribute extends AnnotationsAttribute +{ + /** + * Creates an uninitialized RuntimeVisibleAnnotationsAttribute. + */ + public RuntimeVisibleAnnotationsAttribute() + { + } + + + /** + * Creates an initialized RuntimeVisibleAnnotationsAttribute. + */ + public RuntimeVisibleAnnotationsAttribute(int u2attributeNameIndex, + int u2annotationsCount, + Annotation[] annotations) + { + super(u2attributeNameIndex, u2annotationsCount, annotations); + } + + + // Implementations for Attribute. + + public void accept(Clazz clazz, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitRuntimeVisibleAnnotationsAttribute(clazz, this); + } + + + public void accept(Clazz clazz, Field field, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitRuntimeVisibleAnnotationsAttribute(clazz, field, this); + } + + + public void accept(Clazz clazz, Method method, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitRuntimeVisibleAnnotationsAttribute(clazz, method, this); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/RuntimeVisibleParameterAnnotationsAttribute.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/RuntimeVisibleParameterAnnotationsAttribute.java new file mode 100644 index 0000000000..a1a2e1abaf --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/RuntimeVisibleParameterAnnotationsAttribute.java @@ -0,0 +1,62 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation; + +import proguard.classfile.*; +import proguard.classfile.attribute.visitor.AttributeVisitor; + +/** + * This Attribute represents a runtime visible parameter annotations attribute. + * + * @author Eric Lafortune + */ +public class RuntimeVisibleParameterAnnotationsAttribute extends ParameterAnnotationsAttribute +{ + /** + * Creates an uninitialized RuntimeVisibleParameterAnnotationsAttribute. + */ + public RuntimeVisibleParameterAnnotationsAttribute() + { + } + + + /** + * Creates an initialized RuntimeVisibleParameterAnnotationsAttribute. + */ + public RuntimeVisibleParameterAnnotationsAttribute(int u2attributeNameIndex, + int u1parametersCount, + int[] u2parameterAnnotationsCount, + Annotation[][] parameterAnnotations) + { + super(u2attributeNameIndex, + u1parametersCount, + u2parameterAnnotationsCount, + parameterAnnotations); + } + + + // Implementations for Attribute. + + public void accept(Clazz clazz, Method method, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitRuntimeVisibleParameterAnnotationsAttribute(clazz, method, this); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/RuntimeVisibleTypeAnnotationsAttribute.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/RuntimeVisibleTypeAnnotationsAttribute.java new file mode 100644 index 0000000000..2652a1f6d4 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/RuntimeVisibleTypeAnnotationsAttribute.java @@ -0,0 +1,77 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.visitor.AttributeVisitor; + +/** + * This Attribute represents a runtime visible type annotations attribute. + * + * @author Eric Lafortune + */ +public class RuntimeVisibleTypeAnnotationsAttribute extends TypeAnnotationsAttribute +{ + /** + * Creates an uninitialized RuntimeVisibleTypeAnnotationsAttribute. + */ + public RuntimeVisibleTypeAnnotationsAttribute() + { + } + + + /** + * Creates an initialized RuntimeVisibleTypeAnnotationsAttribute. + */ + public RuntimeVisibleTypeAnnotationsAttribute(int u2attributeNameIndex, + int u2annotationsCount, + TypeAnnotation[] annotations) + { + super(u2attributeNameIndex, u2annotationsCount, annotations); + } + + + // Implementations for Attribute. + + public void accept(Clazz clazz, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitRuntimeVisibleTypeAnnotationsAttribute(clazz, this); + } + + + public void accept(Clazz clazz, Field field, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitRuntimeVisibleTypeAnnotationsAttribute(clazz, field, this); + } + + + public void accept(Clazz clazz, Method method, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitRuntimeVisibleTypeAnnotationsAttribute(clazz, method, this); + } + + + public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitRuntimeVisibleTypeAnnotationsAttribute(clazz, method, codeAttribute, this); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/TypeAnnotation.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/TypeAnnotation.java new file mode 100644 index 0000000000..1246dfa63b --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/TypeAnnotation.java @@ -0,0 +1,162 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.annotation.target.TargetInfo; +import proguard.classfile.attribute.annotation.target.visitor.TargetInfoVisitor; +import proguard.classfile.attribute.annotation.visitor.*; + +/** + * Representation of a type annotation. + * + * @author Eric Lafortune + */ +public class TypeAnnotation extends Annotation +{ + public TargetInfo targetInfo; + public TypePathInfo[] typePath; + + + /** + * Creates an uninitialized TypeAnnotation. + */ + public TypeAnnotation() + { + } + + + /** + * Creates an initialized TypeAnnotation. + */ + public TypeAnnotation(int u2typeIndex, + int u2elementValuesCount, + ElementValue[] elementValues, + TargetInfo targetInfo, + TypePathInfo[] typePath) + { + super(u2typeIndex, u2elementValuesCount, elementValues); + + this.targetInfo = targetInfo; + this.typePath = typePath; + } + + + /** + * Applies the given visitor to the target info. + */ + public void targetInfoAccept(Clazz clazz, TargetInfoVisitor targetInfoVisitor) + { + // We don't need double dispatching here, since there is only one + // type of TypePathInfo. + targetInfo.accept(clazz, this, targetInfoVisitor); + } + + + /** + * Applies the given visitor to the target info. + */ + public void targetInfoAccept(Clazz clazz, Field field, TargetInfoVisitor targetInfoVisitor) + { + // We don't need double dispatching here, since there is only one + // type of TypePathInfo. + targetInfo.accept(clazz, field, this, targetInfoVisitor); + } + + + /** + * Applies the given visitor to the target info. + */ + public void targetInfoAccept(Clazz clazz, Method method, TargetInfoVisitor targetInfoVisitor) + { + // We don't need double dispatching here, since there is only one + // type of TypePathInfo. + targetInfo.accept(clazz, method, this, targetInfoVisitor); + } + + + /** + * Applies the given visitor to the target info. + */ + public void targetInfoAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, TargetInfoVisitor targetInfoVisitor) + { + // We don't need double dispatching here, since there is only one + // type of TypePathInfo. + targetInfo.accept(clazz, method, codeAttribute, this, targetInfoVisitor); + } + + + /** + * Applies the given visitor to all type path elements. + */ + public void typePathInfosAccept(Clazz clazz, TypePathInfoVisitor typePathVisitor) + { + for (int index = 0; index < typePath.length; index++) + { + // We don't need double dispatching here, since there is only one + // type of TypePathInfo. + typePathVisitor.visitTypePathInfo(clazz, this, typePath[index]); + } + } + + + /** + * Applies the given visitor to all type path elements. + */ + public void typePathInfosAccept(Clazz clazz, Field field, TypePathInfoVisitor typePathVisitor) + { + for (int index = 0; index < typePath.length; index++) + { + // We don't need double dispatching here, since there is only one + // type of TypePathInfo. + typePathVisitor.visitTypePathInfo(clazz, field, this, typePath[index]); + } + } + + + /** + * Applies the given visitor to all type path elements. + */ + public void typePathInfosAccept(Clazz clazz, Method method, TypePathInfoVisitor typePathVisitor) + { + for (int index = 0; index < typePath.length; index++) + { + // We don't need double dispatching here, since there is only one + // type of TypePathInfo. + typePathVisitor.visitTypePathInfo(clazz, method, this, typePath[index]); + } + } + + + /** + * Applies the given visitor to all type path elements. + */ + public void typePathInfosAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, TypeAnnotation typeAnnotation, TypePathInfoVisitor typePathVisitor) + { + for (int index = 0; index < typePath.length; index++) + { + // We don't need double dispatching here, since there is only one + // type of TypePathInfo. + typePathVisitor.visitTypePathInfo(clazz, method, codeAttribute, typeAnnotation, typePath[index]); + } + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/TypeAnnotationsAttribute.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/TypeAnnotationsAttribute.java new file mode 100644 index 0000000000..644d04548b --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/TypeAnnotationsAttribute.java @@ -0,0 +1,98 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation; + +import proguard.classfile.*; +import proguard.classfile.attribute.annotation.visitor.*; + +/** + * This Attribute represents a type annotations attribute. + * + * @author Eric Lafortune + */ +public abstract class TypeAnnotationsAttribute extends AnnotationsAttribute +{ + /** + * Creates an uninitialized TypeAnnotationsAttribute. + */ + protected TypeAnnotationsAttribute() + { + } + + + /** + * Creates an initialized TypeAnnotationsAttribute. + */ + protected TypeAnnotationsAttribute(int u2attributeNameIndex, + int u2annotationsCount, + TypeAnnotation[] annotations) + { + super(u2attributeNameIndex, u2annotationsCount, annotations); + } + + + /** + * Applies the given visitor to all class annotations. + */ + public void typeAnnotationsAccept(Clazz clazz, TypeAnnotationVisitor typeAnnotationVisitor) + { + TypeAnnotation[] annotations = (TypeAnnotation[])this.annotations; + + for (int index = 0; index < u2annotationsCount; index++) + { + // We don't need double dispatching here, since there is only one + // type of Annotation. + typeAnnotationVisitor.visitTypeAnnotation(clazz, annotations[index]); + } + } + + + /** + * Applies the given visitor to all field annotations. + */ + public void typeAnnotationsAccept(Clazz clazz, Field field, TypeAnnotationVisitor typeAnnotationVisitor) + { + TypeAnnotation[] annotations = (TypeAnnotation[])this.annotations; + + for (int index = 0; index < u2annotationsCount; index++) + { + // We don't need double dispatching here, since there is only one + // type of Annotation. + typeAnnotationVisitor.visitTypeAnnotation(clazz, field, annotations[index]); + } + } + + + /** + * Applies the given visitor to all method annotations. + */ + public void typeAnnotationsAccept(Clazz clazz, Method method, TypeAnnotationVisitor typeAnnotationVisitor) + { + TypeAnnotation[] annotations = (TypeAnnotation[])this.annotations; + + for (int index = 0; index < u2annotationsCount; index++) + { + // We don't need double dispatching here, since there is only one + // type of Annotation. + typeAnnotationVisitor.visitTypeAnnotation(clazz, method, annotations[index]); + } + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/TypePathInfo.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/TypePathInfo.java new file mode 100644 index 0000000000..1aa91f2666 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/TypePathInfo.java @@ -0,0 +1,50 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation; + +/** + * Representation of a path element in a type annotation. + * + * @author Eric Lafortune + */ +public class TypePathInfo +{ + public int u1typePathKind; + public int u1typeArgumentIndex; + + + /** + * Creates an uninitialized TypePathInfo. + */ + public TypePathInfo() + { + } + + + /** + * Creates an initialized TypePathInfo. + */ + public TypePathInfo(int u1typePathKind, int u1typeArgumentIndex) + { + this.u1typePathKind = u1typePathKind; + this.u1typeArgumentIndex = u1typeArgumentIndex; + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/package.html b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/package.html new file mode 100644 index 0000000000..6aacff3e2f --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/package.html @@ -0,0 +1,4 @@ +<body> +This package contains classes to represent the annotation attributes inside +class files. +</body> diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/CatchTargetInfo.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/CatchTargetInfo.java new file mode 100644 index 0000000000..81c709d6bd --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/CatchTargetInfo.java @@ -0,0 +1,82 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation.target; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.annotation.TypeAnnotation; +import proguard.classfile.attribute.annotation.target.visitor.TargetInfoVisitor; + +/** + * Representation of a 'catch' annotation target. + * + * @author Eric Lafortune + */ +public class CatchTargetInfo extends TargetInfo +{ + public int u2exceptionTableIndex; + + + /** + * Creates an uninitialized CatchTargetInfo. + */ + public CatchTargetInfo() + { + } + + + /** + * Creates a partially initialized CatchTargetInfo. + */ + public CatchTargetInfo(byte u1targetType) + { + super(u1targetType); + } + + + /** + * Creates an initialized CatchTargetInfo. + */ + protected CatchTargetInfo(byte u1targetType, + int u2exceptionTableIndex) + { + super(u1targetType); + + this.u2exceptionTableIndex = u2exceptionTableIndex; + } + + + // Implementations for TargetInfo. + + /** + * Lets the visitor visit, with Method and CodeAttribute null. + */ + public void accept(Clazz clazz, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitCatchTargetInfo(clazz, null, null, typeAnnotation, this); + } + + + public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitCatchTargetInfo(clazz, method, codeAttribute, typeAnnotation, this); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/EmptyTargetInfo.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/EmptyTargetInfo.java new file mode 100644 index 0000000000..6b6a9c9b98 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/EmptyTargetInfo.java @@ -0,0 +1,72 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation.target; + +import proguard.classfile.*; +import proguard.classfile.attribute.annotation.TypeAnnotation; +import proguard.classfile.attribute.annotation.target.visitor.TargetInfoVisitor; + +/** + * Representation of an empty annotation target. + * + * @author Eric Lafortune + */ +public class EmptyTargetInfo extends TargetInfo +{ + /** + * Creates an uninitialized EmptyTargetInfo. + */ + public EmptyTargetInfo() + { + } + + + /** + * Creates an initialized EmptyTargetInfo. + */ + public EmptyTargetInfo(byte u1targetType) + { + super(u1targetType); + } + + + // Implementations for TargetInfo. + + /** + * Lets the visitor visit, with Field null. + */ + public void accept(Clazz clazz, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitEmptyTargetInfo(clazz, (Field)null, typeAnnotation, this); + } + + + public void accept(Clazz clazz, Field field, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitEmptyTargetInfo(clazz, field, typeAnnotation, this); + } + + + public void accept(Clazz clazz, Method method, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitEmptyTargetInfo(clazz, method, typeAnnotation, this); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/FormalParameterTargetInfo.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/FormalParameterTargetInfo.java new file mode 100644 index 0000000000..07906f5a2a --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/FormalParameterTargetInfo.java @@ -0,0 +1,81 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation.target; + +import proguard.classfile.*; +import proguard.classfile.attribute.annotation.TypeAnnotation; +import proguard.classfile.attribute.annotation.target.visitor.TargetInfoVisitor; + +/** + * Representation of a formal parameter annotation target. + * + * @author Eric Lafortune + */ +public class FormalParameterTargetInfo extends TargetInfo +{ + public int u1formalParameterIndex; + + + /** + * Creates an uninitialized FormalParameterTargetInfo. + */ + public FormalParameterTargetInfo() + { + } + + + /** + * Creates a partially initialized FormalParameterTargetInfo. + */ + public FormalParameterTargetInfo(byte u1targetType) + { + super(u1targetType); + } + + + /** + * Creates an initialized FormalParameterTargetInfo. + */ + public FormalParameterTargetInfo(byte u1targetType, + int u1formalParameterIndex) + { + super(u1targetType); + + this.u1formalParameterIndex = u1formalParameterIndex; + } + + + // Implementations for TargetInfo. + + /** + * Lets the visitor visit, with Method null. + */ + public void accept(Clazz clazz, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitFormalParameterTargetInfo(clazz, null, typeAnnotation, this); + } + + + public void accept(Clazz clazz, Method method, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitFormalParameterTargetInfo(clazz, method, typeAnnotation, this); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/LocalVariableTargetElement.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/LocalVariableTargetElement.java new file mode 100644 index 0000000000..85e3a689a6 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/LocalVariableTargetElement.java @@ -0,0 +1,53 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation.target; + +/** + * Representation of an local variable target table entry. + * + * @author Eric Lafortune + */ +public class LocalVariableTargetElement +{ + public int u2startPC; + public int u2length; + public int u2index; + + /** + * Creates an uninitialized LocalVariableTargetElement. + */ + public LocalVariableTargetElement() + { + } + + + /** + * Creates an initialized LocalVariableTargetElement. + */ + public LocalVariableTargetElement(int u2startPC, + int u2length, + int u2index) + { + this.u2startPC = u2startPC; + this.u2length = u2length; + this.u2index = u2index; + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/LocalVariableTargetInfo.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/LocalVariableTargetInfo.java new file mode 100644 index 0000000000..7e532fcd75 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/LocalVariableTargetInfo.java @@ -0,0 +1,99 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation.target; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.annotation.TypeAnnotation; +import proguard.classfile.attribute.annotation.target.visitor.*; + +/** + * Representation of a local variable annotation target. + * + * @author Eric Lafortune + */ +public class LocalVariableTargetInfo extends TargetInfo +{ + public int u2tableLength; + public LocalVariableTargetElement[] table; + + + /** + * Creates an uninitialized LocalVariableTargetInfo. + */ + public LocalVariableTargetInfo() + { + } + + + /** + * Creates a partially initialized LocalVariableTargetInfo. + */ + public LocalVariableTargetInfo(byte u1targetType) + { + super(u1targetType); + } + + + /** + * Creates an initialized LocalVariableTargetInfo. + */ + protected LocalVariableTargetInfo(byte u1targetType, + int u2tableLength, + LocalVariableTargetElement[] table) + { + super(u1targetType); + + this.u2tableLength = u2tableLength; + this.table = table; + } + + + /** + * Applies the given visitor to all target elements. + */ + public void targetElementsAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, TypeAnnotation typeAnnotation, LocalVariableTargetElementVisitor localVariableTargetElementVisitor) + { + for (int index = 0; index < u2tableLength; index++) + { + // We don't need double dispatching here, since there is only one + // type of TypePathInfo. + localVariableTargetElementVisitor.visitLocalVariableTargetElement(clazz, method, codeAttribute, typeAnnotation, this, table[index]); + } + } + + + // Implementations for TargetInfo. + + /** + * Lets the visitor visit, with Method and CodeAttribute null. + */ + public void accept(Clazz clazz, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitLocalVariableTargetInfo(clazz, null, null, typeAnnotation, this); + } + + + public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitLocalVariableTargetInfo(clazz, method, codeAttribute, typeAnnotation, this); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/OffsetTargetInfo.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/OffsetTargetInfo.java new file mode 100644 index 0000000000..6eb7e9807e --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/OffsetTargetInfo.java @@ -0,0 +1,82 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation.target; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.annotation.TypeAnnotation; +import proguard.classfile.attribute.annotation.target.visitor.TargetInfoVisitor; + +/** + * Representation of an offset annotation target. + * + * @author Eric Lafortune + */ +public class OffsetTargetInfo extends TargetInfo +{ + public int u2offset; + + + /** + * Creates an uninitialized OffsetTargetInfo. + */ + public OffsetTargetInfo() + { + } + + + /** + * Creates a partially initialized OffsetTargetInfo. + */ + public OffsetTargetInfo(byte u1targetType) + { + super(u1targetType); + } + + + /** + * Creates an initialized OffsetTargetInfo. + */ + protected OffsetTargetInfo(byte u1targetType, + int u2offset) + { + super(u1targetType); + + this.u2offset = u2offset; + } + + + // Implementations for TargetInfo. + + /** + * Lets the visitor visit, with Method and CodeAttribute null. + */ + public void accept(Clazz clazz, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitOffsetTargetInfo(clazz, null, null, typeAnnotation, this); + } + + + public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitOffsetTargetInfo(clazz, method, codeAttribute, typeAnnotation, this); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/SuperTypeTargetInfo.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/SuperTypeTargetInfo.java new file mode 100644 index 0000000000..6bb82f0137 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/SuperTypeTargetInfo.java @@ -0,0 +1,72 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation.target; + +import proguard.classfile.Clazz; +import proguard.classfile.attribute.annotation.TypeAnnotation; +import proguard.classfile.attribute.annotation.target.visitor.TargetInfoVisitor; + +/** + * Representation of a super type annotation target. + * + * @author Eric Lafortune + */ +public class SuperTypeTargetInfo extends TargetInfo +{ + public int u2superTypeIndex; + + + /** + * Creates an uninitialized SuperTypeTargetInfo. + */ + public SuperTypeTargetInfo() + { + } + + + /** + * Creates a partially initialized SuperTypeTargetInfo. + */ + public SuperTypeTargetInfo(byte u1targetType) + { + super(u1targetType); + } + + + /** + * Creates an initialized SuperTypeTargetInfo. + */ + public SuperTypeTargetInfo(byte u1targetType, + int u2superTypeIndex) + { + super(u1targetType); + + this.u2superTypeIndex = u2superTypeIndex; + } + + + // Implementations for TargetInfo. + + public void accept(Clazz clazz, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitSuperTypeTargetInfo(clazz, typeAnnotation, this); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/TargetInfo.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/TargetInfo.java new file mode 100644 index 0000000000..138942fc20 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/TargetInfo.java @@ -0,0 +1,97 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation.target; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.annotation.TypeAnnotation; +import proguard.classfile.attribute.annotation.target.visitor.TargetInfoVisitor; + +/** + * Representation of an annotation target. + * + * @author Eric Lafortune + */ +public abstract class TargetInfo +{ + public byte u1targetType; + + + /** + * Creates an uninitialized TargetInfo. + */ + protected TargetInfo() + { + } + + + /** + * Creates an initialized TargetInfo. + */ + protected TargetInfo(byte u1targetType) + { + this.u1targetType = u1targetType; + } + + + /** + * Returns the type of the target. + */ + public byte getTargetType() + { + return u1targetType; + } + + + // Methods to be implemented by extensions. + + /** + * Accepts the given visitor, in the context of a type annotation on a class. + */ + public void accept(Clazz clazz, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + throw new UnsupportedOperationException("Unsupported type annotation [0x"+Integer.toHexString(u1targetType)+"] on a class"); + } + + /** + * Accepts the given visitor, in the context of a type annotation on a field. + */ + public void accept(Clazz clazz, Field field, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + throw new UnsupportedOperationException("Unsupported type annotation [0x"+Integer.toHexString(u1targetType)+"] on a field"); + } + + /** + * Accepts the given visitor, in the context of a type annotation on a method. + */ + public void accept(Clazz clazz, Method method, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + throw new UnsupportedOperationException("Unsupported type annotation [0x"+Integer.toHexString(u1targetType)+"] on a method"); + } + + /** + * Accepts the given visitor, in the context of a type annotation code. + */ + public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + throw new UnsupportedOperationException("Unsupported type annotation [0x"+Integer.toHexString(u1targetType)+"] on code"); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/ThrowsTargetInfo.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/ThrowsTargetInfo.java new file mode 100644 index 0000000000..c42a45b0d8 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/ThrowsTargetInfo.java @@ -0,0 +1,81 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation.target; + +import proguard.classfile.*; +import proguard.classfile.attribute.annotation.TypeAnnotation; +import proguard.classfile.attribute.annotation.target.visitor.TargetInfoVisitor; + +/** + * Representation of a 'throws' annotation target. + * + * @author Eric Lafortune + */ +public class ThrowsTargetInfo extends TargetInfo +{ + public int u2throwsTypeIndex; + + + /** + * Creates an uninitialized ThrowsTargetInfo. + */ + public ThrowsTargetInfo() + { + } + + + /** + * Creates a partially initialized ThrowsTargetInfo. + */ + public ThrowsTargetInfo(byte u1targetType) + { + super(u1targetType); + } + + + /** + * Creates an initialized ThrowsTargetInfo. + */ + public ThrowsTargetInfo(byte u1targetType, + int u2throwsTypeIndex) + { + super(u1targetType); + + this.u2throwsTypeIndex = u2throwsTypeIndex; + } + + + // Implementations for TargetInfo. + + /** + * Lets the visitor visit, with Method null. + */ + public void accept(Clazz clazz, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitThrowsTargetInfo(clazz, null, typeAnnotation, this); + } + + + public void accept(Clazz clazz, Method method, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitThrowsTargetInfo(clazz, method, typeAnnotation, this); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/TypeArgumentTargetInfo.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/TypeArgumentTargetInfo.java new file mode 100644 index 0000000000..deb6eaabe8 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/TypeArgumentTargetInfo.java @@ -0,0 +1,85 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation.target; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.annotation.TypeAnnotation; +import proguard.classfile.attribute.annotation.target.visitor.TargetInfoVisitor; + +/** + * Representation of an offset annotation target. + * + * @author Eric Lafortune + */ +public class TypeArgumentTargetInfo extends TargetInfo +{ + public int u2offset; + public int u1typeArgumentIndex; + + + /** + * Creates an uninitialized TypeArgumentTargetInfo. + */ + public TypeArgumentTargetInfo() + { + } + + + /** + * Creates a partially initialized TypeArgumentTargetInfo. + */ + public TypeArgumentTargetInfo(byte u1targetType) + { + super(u1targetType); + } + + + /** + * Creates an initialized TypeArgumentTargetInfo. + */ + protected TypeArgumentTargetInfo(byte u1targetType, + int u2offset, + int u1typeArgumentIndex) + { + super(u1targetType); + + this.u2offset = u2offset; + this.u1typeArgumentIndex = u1typeArgumentIndex; + } + + + // Implementations for TargetInfo. + + /** + * Lets the visitor visit, with Method and CodeAttribute null. + */ + public void accept(Clazz clazz, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitTypeArgumentTargetInfo(clazz, null, null, typeAnnotation, this); + } + + + public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitTypeArgumentTargetInfo(clazz, method, codeAttribute, typeAnnotation, this); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/TypeParameterBoundTargetInfo.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/TypeParameterBoundTargetInfo.java new file mode 100644 index 0000000000..6c628adeb0 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/TypeParameterBoundTargetInfo.java @@ -0,0 +1,87 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation.target; + +import proguard.classfile.*; +import proguard.classfile.attribute.annotation.TypeAnnotation; +import proguard.classfile.attribute.annotation.target.visitor.TargetInfoVisitor; + +/** + * Representation of a type parameter bound annotation target. + * + * @author Eric Lafortune + */ +public class TypeParameterBoundTargetInfo extends TargetInfo +{ + public int u1typeParameterIndex; + public int u1boundIndex; + + + /** + * Creates an uninitialized TypeParameterBoundTargetInfo. + */ + public TypeParameterBoundTargetInfo() + { + } + + + /** + * Creates a partially initialized TypeParameterBoundTargetInfo. + */ + public TypeParameterBoundTargetInfo(byte u1targetType) + { + super(u1targetType); + } + + + /** + * Creates an initialized TypeParameterBoundTargetInfo. + */ + public TypeParameterBoundTargetInfo(byte u1targetType, + int u1typeParameterIndex, + int u1boundIndex) + { + super(u1targetType); + + this.u1typeParameterIndex = u1typeParameterIndex; + this.u1boundIndex = u1boundIndex; + } + + + // Implementations for TargetInfo. + + public void accept(Clazz clazz, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitTypeParameterBoundTargetInfo(clazz, typeAnnotation, this); + } + + + public void accept(Clazz clazz, Field field, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitTypeParameterBoundTargetInfo(clazz, field, typeAnnotation, this); + } + + + public void accept(Clazz clazz, Method method, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitTypeParameterBoundTargetInfo(clazz, method, typeAnnotation, this); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/TypeParameterTargetInfo.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/TypeParameterTargetInfo.java new file mode 100644 index 0000000000..06f2b57bcf --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/TypeParameterTargetInfo.java @@ -0,0 +1,79 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation.target; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.annotation.TypeAnnotation; +import proguard.classfile.attribute.annotation.target.visitor.TargetInfoVisitor; + +/** + * Representation of a type parameter annotation target. + * + * @author Eric Lafortune + */ +public class TypeParameterTargetInfo extends TargetInfo +{ + public int u1typeParameterIndex; + + + /** + * Creates an uninitialized TypeParameterTargetInfo. + */ + public TypeParameterTargetInfo() + { + } + + + /** + * Creates a partially initialized TypeParameterTargetInfo. + */ + public TypeParameterTargetInfo(byte u1targetType) + { + super(u1targetType); + } + + + /** + * Creates an initialized TypeParameterTargetInfo. + */ + public TypeParameterTargetInfo(byte u1targetType, + int u1typeParameterIndex) + { + super(u1targetType); + + this.u1typeParameterIndex = u1typeParameterIndex; + } + + + // Implementations for TargetInfo. + + public void accept(Clazz clazz, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitTypeParameterTargetInfo(clazz, typeAnnotation, this); + } + + + public void accept(Clazz clazz, Method method, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitTypeParameterTargetInfo(clazz, method, typeAnnotation, this); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/visitor/LocalVariableTargetElementVisitor.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/visitor/LocalVariableTargetElementVisitor.java new file mode 100644 index 0000000000..659a0ff8b2 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/visitor/LocalVariableTargetElementVisitor.java @@ -0,0 +1,37 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation.target.visitor; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.annotation.TypeAnnotation; +import proguard.classfile.attribute.annotation.target.*; + +/** + * This interface specifies the methods for a visitor of LocalVariableTargetElement + * instances. + * + * @author Eric Lafortune + */ +public interface LocalVariableTargetElementVisitor +{ + public void visitLocalVariableTargetElement(Clazz clazz, Method method, CodeAttribute codeAttribute, TypeAnnotation typeAnnotation, LocalVariableTargetInfo localVariableTargetInfo, LocalVariableTargetElement localVariableTargetElement); +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/visitor/TargetInfoVisitor.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/visitor/TargetInfoVisitor.java new file mode 100644 index 0000000000..fef99f172e --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/target/visitor/TargetInfoVisitor.java @@ -0,0 +1,50 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation.target.visitor; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.annotation.*; +import proguard.classfile.attribute.annotation.target.*; + +/** + * This interface specifies the methods for a visitor of <code>TargetInfo</code> + * objects. + * + * @author Eric Lafortune + */ +public interface TargetInfoVisitor +{ + public void visitTypeParameterTargetInfo( Clazz clazz, TypeAnnotation typeAnnotation, TypeParameterTargetInfo typeParameterTargetInfo); + public void visitTypeParameterTargetInfo( Clazz clazz, Method method, TypeAnnotation typeAnnotation, TypeParameterTargetInfo typeParameterTargetInfo); + public void visitSuperTypeTargetInfo( Clazz clazz, TypeAnnotation typeAnnotation, SuperTypeTargetInfo superTypeTargetInfo); + public void visitTypeParameterBoundTargetInfo(Clazz clazz, TypeAnnotation typeAnnotation, TypeParameterBoundTargetInfo typeParameterBoundTargetInfo); + public void visitTypeParameterBoundTargetInfo(Clazz clazz, Field field, TypeAnnotation typeAnnotation, TypeParameterBoundTargetInfo typeParameterBoundTargetInfo); + public void visitTypeParameterBoundTargetInfo(Clazz clazz, Method method, TypeAnnotation typeAnnotation, TypeParameterBoundTargetInfo typeParameterBoundTargetInfo); + public void visitEmptyTargetInfo( Clazz clazz, Field field, TypeAnnotation typeAnnotation, EmptyTargetInfo emptyTargetInfo); + public void visitEmptyTargetInfo( Clazz clazz, Method method, TypeAnnotation typeAnnotation, EmptyTargetInfo emptyTargetInfo); + public void visitFormalParameterTargetInfo( Clazz clazz, Method method, TypeAnnotation typeAnnotation, FormalParameterTargetInfo formalParameterTargetInfo); + public void visitThrowsTargetInfo( Clazz clazz, Method method, TypeAnnotation typeAnnotation, ThrowsTargetInfo throwsTargetInfo); + public void visitLocalVariableTargetInfo( Clazz clazz, Method method, CodeAttribute codeAttribute, TypeAnnotation typeAnnotation, LocalVariableTargetInfo localVariableTargetInfo); + public void visitCatchTargetInfo( Clazz clazz, Method method, CodeAttribute codeAttribute, TypeAnnotation typeAnnotation, CatchTargetInfo catchTargetInfo); + public void visitOffsetTargetInfo( Clazz clazz, Method method, CodeAttribute codeAttribute, TypeAnnotation typeAnnotation, OffsetTargetInfo offsetTargetInfo); + public void visitTypeArgumentTargetInfo( Clazz clazz, Method method, CodeAttribute codeAttribute, TypeAnnotation typeAnnotation, TypeArgumentTargetInfo typeArgumentTargetInfo); +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/visitor/AllAnnotationVisitor.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/visitor/AllAnnotationVisitor.java new file mode 100644 index 0000000000..cead20c1d8 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/visitor/AllAnnotationVisitor.java @@ -0,0 +1,161 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation.visitor; + +import proguard.classfile.*; +import proguard.classfile.attribute.*; +import proguard.classfile.attribute.annotation.*; +import proguard.classfile.attribute.visitor.AttributeVisitor; +import proguard.classfile.util.SimplifiedVisitor; + +/** + * This AttributeVisitor lets a given AnnotationVisitor visit all Annotation + * objects of the attributes it visits. + * + * @author Eric Lafortune + */ +public class AllAnnotationVisitor +extends SimplifiedVisitor +implements AttributeVisitor +{ + private final AnnotationVisitor annotationVisitor; + + + /** + * Creates a new AllAnnotationVisitor. + * @param annotationVisitor the AnnotationVisitor to which visits will be + * delegated. + */ + public AllAnnotationVisitor(AnnotationVisitor annotationVisitor) + { + this.annotationVisitor = annotationVisitor; + } + + + // Implementations for AttributeVisitor. + + public void visitAnyAttribute(Clazz clazz, Attribute attribute) {} + + + public void visitRuntimeVisibleAnnotationsAttribute(Clazz clazz, RuntimeVisibleAnnotationsAttribute runtimeVisibleAnnotationsAttribute) + { + // Visit the annotations. + runtimeVisibleAnnotationsAttribute.annotationsAccept(clazz, annotationVisitor); + } + + + public void visitRuntimeVisibleAnnotationsAttribute(Clazz clazz, Field field, RuntimeVisibleAnnotationsAttribute runtimeVisibleAnnotationsAttribute) + { + // Visit the annotations. + runtimeVisibleAnnotationsAttribute.annotationsAccept(clazz, field, annotationVisitor); + } + + + public void visitRuntimeVisibleAnnotationsAttribute(Clazz clazz, Method method, RuntimeVisibleAnnotationsAttribute runtimeVisibleAnnotationsAttribute) + { + // Visit the annotations. + runtimeVisibleAnnotationsAttribute.annotationsAccept(clazz, method, annotationVisitor); + } + + + public void visitRuntimeInvisibleAnnotationsAttribute(Clazz clazz, RuntimeInvisibleAnnotationsAttribute runtimeInvisibleAnnotationsAttribute) + { + // Visit the annotations. + runtimeInvisibleAnnotationsAttribute.annotationsAccept(clazz, annotationVisitor); + } + + + public void visitRuntimeInvisibleAnnotationsAttribute(Clazz clazz, Field field, RuntimeInvisibleAnnotationsAttribute runtimeInvisibleAnnotationsAttribute) + { + // Visit the annotations. + runtimeInvisibleAnnotationsAttribute.annotationsAccept(clazz, field, annotationVisitor); + } + + + public void visitRuntimeInvisibleAnnotationsAttribute(Clazz clazz, Method method, RuntimeInvisibleAnnotationsAttribute runtimeInvisibleAnnotationsAttribute) + { + // Visit the annotations. + runtimeInvisibleAnnotationsAttribute.annotationsAccept(clazz, method, annotationVisitor); + } + + + public void visitAnyParameterAnnotationsAttribute(Clazz clazz, Method method, ParameterAnnotationsAttribute parameterAnnotationsAttribute) + { + // Visit the annotations. + parameterAnnotationsAttribute.annotationsAccept(clazz, method, annotationVisitor); + } + + + public void visitRuntimeVisibleTypeAnnotationsAttribute(Clazz clazz, RuntimeVisibleTypeAnnotationsAttribute runtimeVisibleTypeAnnotationsAttribute) + { + // Visit the annotations. + runtimeVisibleTypeAnnotationsAttribute.annotationsAccept(clazz, annotationVisitor); + } + + + public void visitRuntimeVisibleTypeAnnotationsAttribute(Clazz clazz, Field field, RuntimeVisibleTypeAnnotationsAttribute runtimeVisibleTypeAnnotationsAttribute) + { + // Visit the annotations. + runtimeVisibleTypeAnnotationsAttribute.annotationsAccept(clazz, field, annotationVisitor); + } + + + public void visitRuntimeVisibleTypeAnnotationsAttribute(Clazz clazz, Method method, RuntimeVisibleTypeAnnotationsAttribute runtimeVisibleTypeAnnotationsAttribute) + { + // Visit the annotations. + runtimeVisibleTypeAnnotationsAttribute.annotationsAccept(clazz, method, annotationVisitor); + } + + + public void visitRuntimeVisibleTypeAnnotationsAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, RuntimeVisibleTypeAnnotationsAttribute runtimeVisibleTypeAnnotationsAttribute) + { + // Visit the annotations. + runtimeVisibleTypeAnnotationsAttribute.annotationsAccept(clazz, method, codeAttribute, annotationVisitor); + } + + + public void visitRuntimeInvisibleTypeAnnotationsAttribute(Clazz clazz, RuntimeInvisibleTypeAnnotationsAttribute runtimeInvisibleTypeAnnotationsAttribute) + { + // Visit the annotations. + runtimeInvisibleTypeAnnotationsAttribute.annotationsAccept(clazz, annotationVisitor); + } + + + public void visitRuntimeInvisibleTypeAnnotationsAttribute(Clazz clazz, Field field, RuntimeInvisibleTypeAnnotationsAttribute runtimeInvisibleTypeAnnotationsAttribute) + { + // Visit the annotations. + runtimeInvisibleTypeAnnotationsAttribute.annotationsAccept(clazz, field, annotationVisitor); + } + + + public void visitRuntimeInvisibleTypeAnnotationsAttribute(Clazz clazz, Method method, RuntimeInvisibleTypeAnnotationsAttribute runtimeInvisibleTypeAnnotationsAttribute) + { + // Visit the annotations. + runtimeInvisibleTypeAnnotationsAttribute.annotationsAccept(clazz, method, annotationVisitor); + } + + + public void visitRuntimeInvisibleTypeAnnotationsAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, RuntimeInvisibleTypeAnnotationsAttribute runtimeInvisibleTypeAnnotationsAttribute) + { + // Visit the annotations. + runtimeInvisibleTypeAnnotationsAttribute.annotationsAccept(clazz, method, codeAttribute, annotationVisitor); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/visitor/AllElementValueVisitor.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/visitor/AllElementValueVisitor.java new file mode 100644 index 0000000000..3e9bf0f811 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/visitor/AllElementValueVisitor.java @@ -0,0 +1,206 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation.visitor; + +import proguard.classfile.*; +import proguard.classfile.attribute.*; +import proguard.classfile.attribute.annotation.*; +import proguard.classfile.attribute.visitor.AttributeVisitor; +import proguard.classfile.util.SimplifiedVisitor; + +/** + * This AttributeVisitor and AnnotationVisitor lets a given ElementValueVisitor + * visit all ElementValue objects of the attributes or annotations that it + * visits. + * + * @author Eric Lafortune + */ +public class AllElementValueVisitor +extends SimplifiedVisitor +implements AttributeVisitor, + AnnotationVisitor, + ElementValueVisitor +{ + private final boolean deep; + private final ElementValueVisitor elementValueVisitor; + + + /** + * Creates a new AllElementValueVisitor. + * @param elementValueVisitor the AllElementValueVisitor to which visits + * will be delegated. + */ + public AllElementValueVisitor(ElementValueVisitor elementValueVisitor) + { + this(false, elementValueVisitor); + } + + + /** + * Creates a new AllElementValueVisitor. + * @param deep specifies whether the element values + * further down the hierarchy should be + * visited too. + * @param elementValueVisitor the AllElementValueVisitor to which visits + * will be delegated. + */ + public AllElementValueVisitor(boolean deep, + ElementValueVisitor elementValueVisitor) + { + this.deep = deep; + this.elementValueVisitor = elementValueVisitor; + } + + + // Implementations for AttributeVisitor. + + public void visitAnyAttribute(Clazz clazz, Attribute attribute) {} + + + public void visitRuntimeVisibleAnnotationsAttribute(Clazz clazz, RuntimeVisibleAnnotationsAttribute runtimeVisibleAnnotationsAttribute) + { + // Visit the annotations. + runtimeVisibleAnnotationsAttribute.annotationsAccept(clazz, this); + } + + + public void visitRuntimeVisibleAnnotationsAttribute(Clazz clazz, Field field, RuntimeVisibleAnnotationsAttribute runtimeVisibleAnnotationsAttribute) + { + // Visit the annotations. + runtimeVisibleAnnotationsAttribute.annotationsAccept(clazz, field, this); + } + + + public void visitRuntimeVisibleAnnotationsAttribute(Clazz clazz, Method method, RuntimeVisibleAnnotationsAttribute runtimeVisibleAnnotationsAttribute) + { + // Visit the annotations. + runtimeVisibleAnnotationsAttribute.annotationsAccept(clazz, method, this); + } + + + public void visitRuntimeInvisibleAnnotationsAttribute(Clazz clazz, RuntimeInvisibleAnnotationsAttribute runtimeInvisibleAnnotationsAttribute) + { + // Visit the annotations. + runtimeInvisibleAnnotationsAttribute.annotationsAccept(clazz, this); + } + + + public void visitRuntimeInvisibleAnnotationsAttribute(Clazz clazz, Field field, RuntimeInvisibleAnnotationsAttribute runtimeInvisibleAnnotationsAttribute) + { + // Visit the annotations. + runtimeInvisibleAnnotationsAttribute.annotationsAccept(clazz, field, this); + } + + + public void visitRuntimeInvisibleAnnotationsAttribute(Clazz clazz, Method method, RuntimeInvisibleAnnotationsAttribute runtimeInvisibleAnnotationsAttribute) + { + // Visit the annotations. + runtimeInvisibleAnnotationsAttribute.annotationsAccept(clazz, method, this); + } + + + public void visitAnyParameterAnnotationsAttribute(Clazz clazz, Method method, ParameterAnnotationsAttribute parameterAnnotationsAttribute) + { + // Visit the annotations. + parameterAnnotationsAttribute.annotationsAccept(clazz, method, this); + } + + + public void visitAnnotationDefaultAttribute(Clazz clazz, Method method, AnnotationDefaultAttribute annotationDefaultAttribute) + { + // Visit the default element value. + annotationDefaultAttribute.defaultValueAccept(clazz, this); + } + + + // Implementations for AnnotationVisitor. + + public void visitAnnotation(Clazz clazz, Annotation annotation) + { + annotation.elementValuesAccept(clazz, this); + } + + + public void visitAnnotation(Clazz clazz, Field field, Annotation annotation) + { + annotation.elementValuesAccept(clazz, this); + } + + + public void visitAnnotation(Clazz clazz, Method method, Annotation annotation) + { + annotation.elementValuesAccept(clazz, this); + } + + + public void visitAnnotation(Clazz clazz, Method method, int parameterIndex, Annotation annotation) + { + annotation.elementValuesAccept(clazz, this); + } + + + public void visitAnnotation(Clazz clazz, Method method, CodeAttribute codeAttribute, Annotation annotation) + { + annotation.elementValuesAccept(clazz, this); + } + + + // Implementations for ElementValueVisitor. + + public void visitConstantElementValue(Clazz clazz, Annotation annotation, ConstantElementValue constantElementValue) + { + elementValueVisitor.visitConstantElementValue(clazz, annotation, constantElementValue); + } + + + public void visitEnumConstantElementValue(Clazz clazz, Annotation annotation, EnumConstantElementValue enumConstantElementValue) + { + elementValueVisitor.visitEnumConstantElementValue(clazz, annotation, enumConstantElementValue); + } + + + public void visitClassElementValue(Clazz clazz, Annotation annotation, ClassElementValue classElementValue) + { + elementValueVisitor.visitClassElementValue(clazz, annotation, classElementValue); + } + + + public void visitAnnotationElementValue(Clazz clazz, Annotation annotation, AnnotationElementValue annotationElementValue) + { + elementValueVisitor.visitAnnotationElementValue(clazz, annotation, annotationElementValue); + + if (deep) + { + annotationElementValue.annotationAccept(clazz, this); + } + } + + + public void visitArrayElementValue(Clazz clazz, Annotation annotation, ArrayElementValue arrayElementValue) + { + elementValueVisitor.visitArrayElementValue(clazz, annotation, arrayElementValue); + + if (deep) + { + arrayElementValue.elementValuesAccept(clazz, annotation, elementValueVisitor); + } + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/visitor/AnnotatedClassVisitor.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/visitor/AnnotatedClassVisitor.java new file mode 100644 index 0000000000..646b5ab6b2 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/visitor/AnnotatedClassVisitor.java @@ -0,0 +1,62 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation.visitor; + +import proguard.classfile.Clazz; +import proguard.classfile.attribute.annotation.Annotation; +import proguard.classfile.util.SimplifiedVisitor; +import proguard.classfile.visitor.ClassVisitor; + + +/** + * This AnnotationVisitor delegates all visits to a given ClassVisitor. + * The latter visits the class of each visited annotation, although + * never twice in a row. + * + * @author Eric Lafortune + */ +public class AnnotatedClassVisitor +extends SimplifiedVisitor +implements AnnotationVisitor +{ + private final ClassVisitor classVisitor; + + private Clazz lastVisitedClass; + + + public AnnotatedClassVisitor(ClassVisitor classVisitor) + { + this.classVisitor = classVisitor; + } + + + // Implementations for AnnotationVisitor. + + public void visitAnnotation(Clazz clazz, Annotation annotation) + { + if (!clazz.equals(lastVisitedClass)) + { + clazz.accept(classVisitor); + + lastVisitedClass = clazz; + } + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/visitor/AnnotationToMemberVisitor.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/visitor/AnnotationToMemberVisitor.java new file mode 100644 index 0000000000..c21dcd6a5f --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/visitor/AnnotationToMemberVisitor.java @@ -0,0 +1,62 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation.visitor; + +import proguard.classfile.*; +import proguard.classfile.attribute.annotation.Annotation; +import proguard.classfile.util.SimplifiedVisitor; +import proguard.classfile.visitor.MemberVisitor; + + +/** + * This AnnotationVisitor delegates all visits to a given MemberVisitor. + * The latter visits the class member of each visited class member annotation + * or method parameter annotation, although never twice in a row. + * + * @author Eric Lafortune + */ +public class AnnotationToMemberVisitor +extends SimplifiedVisitor +implements AnnotationVisitor +{ + private final MemberVisitor memberVisitor; + + private Member lastVisitedMember; + + + public AnnotationToMemberVisitor(MemberVisitor memberVisitor) + { + this.memberVisitor = memberVisitor; + } + + + // Implementations for AnnotationVisitor. + + public void visitAnnotation(Clazz clazz, Member member, Annotation annotation) + { + if (!member.equals(lastVisitedMember)) + { + member.accept(clazz, memberVisitor); + + lastVisitedMember = member; + } + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/visitor/AnnotationTypeFilter.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/visitor/AnnotationTypeFilter.java new file mode 100644 index 0000000000..0d5a6e6118 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/visitor/AnnotationTypeFilter.java @@ -0,0 +1,110 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation.visitor; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.annotation.Annotation; +import proguard.util.*; + +/** + * This <code>AnnotationVisitor</code> delegates its visits to another given + * <code>AnnotationVisitor</code>, but only when the visited annotation has + * a type that matches a given regular expression. + * + * @author Eric Lafortune + */ +public class AnnotationTypeFilter +implements AnnotationVisitor +{ + private final StringMatcher regularExpressionMatcher; + private final AnnotationVisitor annotationVisitor; + + + /** + * Creates a new ClassNameFilter. + * @param regularExpression the regular expression against which annotation + * type names will be matched. + * @param annotationVisitor the <code>annotationVisitor</code> to which + * visits will be delegated. + */ + public AnnotationTypeFilter(String regularExpression, + AnnotationVisitor annotationVisitor) + { + this.regularExpressionMatcher = new ListParser(new ClassNameParser()).parse(regularExpression); + this.annotationVisitor = annotationVisitor; + } + + + // Implementations for AnnotationVisitor. + + public void visitAnnotation(Clazz clazz, Annotation annotation) + { + if (accepted(annotation.getType(clazz))) + { + annotationVisitor.visitAnnotation(clazz, annotation); + } + } + + + public void visitAnnotation(Clazz clazz, Field field, Annotation annotation) + { + if (accepted(annotation.getType(clazz))) + { + annotationVisitor.visitAnnotation(clazz, field, annotation); + } + } + + + public void visitAnnotation(Clazz clazz, Method method, Annotation annotation) + { + if (accepted(annotation.getType(clazz))) + { + annotationVisitor.visitAnnotation(clazz, method, annotation); + } + } + + + public void visitAnnotation(Clazz clazz, Method method, int parameterIndex, Annotation annotation) + { + if (accepted(annotation.getType(clazz))) + { + annotationVisitor.visitAnnotation(clazz, method, parameterIndex, annotation); + } + } + + + public void visitAnnotation(Clazz clazz, Method method, CodeAttribute codeAttribute, Annotation annotation) + { + if (accepted(annotation.getType(clazz))) + { + annotationVisitor.visitAnnotation(clazz, method, codeAttribute, annotation); + } + } + + + // Small utility methods. + + private boolean accepted(String name) + { + return regularExpressionMatcher.matches(name); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/visitor/AnnotationVisitor.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/visitor/AnnotationVisitor.java new file mode 100644 index 0000000000..b9c93e98bc --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/visitor/AnnotationVisitor.java @@ -0,0 +1,42 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation.visitor; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.annotation.Annotation; + +/** + * This interface specifies the methods for a visitor of + * <code>Annotation</code> objects. Note that there is only a single + * implementation of <code>Annotation</code>, such that this interface + * is not strictly necessary as a visitor. + * + * @author Eric Lafortune + */ +public interface AnnotationVisitor +{ + public void visitAnnotation(Clazz clazz, Annotation annotation); + public void visitAnnotation(Clazz clazz, Field field, Annotation annotation); + public void visitAnnotation(Clazz clazz, Method method, Annotation annotation); + public void visitAnnotation(Clazz clazz, Method method, int parameterIndex, Annotation annotation); + public void visitAnnotation(Clazz clazz, Method method, CodeAttribute codeAttribute, Annotation annotation); +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/visitor/ElementValueVisitor.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/visitor/ElementValueVisitor.java new file mode 100644 index 0000000000..076c0421fd --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/visitor/ElementValueVisitor.java @@ -0,0 +1,51 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation.visitor; + +import proguard.classfile.Clazz; +import proguard.classfile.attribute.annotation.*; + +/** + * This interface specifies the methods for a visitor of <code>ElementValue</code> + * objects. + * + * @author Eric Lafortune + */ +public interface ElementValueVisitor +{ + public void visitConstantElementValue( Clazz clazz, Annotation annotation, ConstantElementValue constantElementValue); + public void visitEnumConstantElementValue(Clazz clazz, Annotation annotation, EnumConstantElementValue enumConstantElementValue); + public void visitClassElementValue( Clazz clazz, Annotation annotation, ClassElementValue classElementValue); + public void visitAnnotationElementValue( Clazz clazz, Annotation annotation, AnnotationElementValue annotationElementValue); + public void visitArrayElementValue( Clazz clazz, Annotation annotation, ArrayElementValue arrayElementValue); + +// public void visitConstantElementValue( Clazz clazz, Field field, Annotation annotation, ConstantElementValue constantElementValue); +// public void visitEnumConstantElementValue(Clazz clazz, Field field, Annotation annotation, EnumConstantElementValue enumConstantElementValue); +// public void visitClassElementValue( Clazz clazz, Field field, Annotation annotation, ClassElementValue classElementValue); +// public void visitAnnotationElementValue( Clazz clazz, Field field, Annotation annotation, AnnotationElementValue annotationElementValue); +// public void visitArrayElementValue( Clazz clazz, Field field, Annotation annotation, ArrayElementValue arrayElementValue); +// +// public void visitConstantElementValue( Clazz clazz, Method method, Annotation annotation, ConstantElementValue constantElementValue); +// public void visitEnumConstantElementValue(Clazz clazz, Method method, Annotation annotation, EnumConstantElementValue enumConstantElementValue); +// public void visitClassElementValue( Clazz clazz, Method method, Annotation annotation, ClassElementValue classElementValue); +// public void visitAnnotationElementValue( Clazz clazz, Method method, Annotation annotation, AnnotationElementValue annotationElementValue); +// public void visitArrayElementValue( Clazz clazz, Method method, Annotation annotation, ArrayElementValue arrayElementValue); +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/visitor/TypeAnnotationVisitor.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/visitor/TypeAnnotationVisitor.java new file mode 100644 index 0000000000..3a2f4fd8fa --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/visitor/TypeAnnotationVisitor.java @@ -0,0 +1,41 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation.visitor; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.annotation.*; + +/** + * This interface specifies the methods for a visitor of + * TypeAnnotation instances. Note that there is only a single + * implementation of TypeAnnotation, such that this interface + * is not strictly necessary as a visitor. + * + * @author Eric Lafortune + */ +public interface TypeAnnotationVisitor +{ + public void visitTypeAnnotation(Clazz clazz, TypeAnnotation typeAnnotation); + public void visitTypeAnnotation(Clazz clazz, Field field, TypeAnnotation typeAnnotation); + public void visitTypeAnnotation(Clazz clazz, Method method, TypeAnnotation typeAnnotation); + public void visitTypeAnnotation(Clazz clazz, Method method, CodeAttribute codeAttribute, TypeAnnotation typeAnnotation); +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/visitor/TypePathInfoVisitor.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/visitor/TypePathInfoVisitor.java new file mode 100644 index 0000000000..34bfa081d0 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/visitor/TypePathInfoVisitor.java @@ -0,0 +1,41 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation.visitor; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.annotation.*; + +/** + * This interface specifies the methods for a visitor of + * TypePathInfo instances. Note that there is only a single + * implementation of TypePathInfo, such that this interface + * is not strictly necessary as a visitor. + * + * @author Eric Lafortune + */ +public interface TypePathInfoVisitor +{ + public void visitTypePathInfo(Clazz clazz, TypeAnnotation typeAnnotation, TypePathInfo typePathInfo); + public void visitTypePathInfo(Clazz clazz, Field field, TypeAnnotation typeAnnotation, TypePathInfo typePathInfo); + public void visitTypePathInfo(Clazz clazz, Method method, TypeAnnotation typeAnnotation, TypePathInfo typePathInfo); + public void visitTypePathInfo(Clazz clazz, Method method, CodeAttribute codeAttribute, TypeAnnotation typeAnnotation, TypePathInfo typePathInfo); +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/visitor/package.html b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/visitor/package.html new file mode 100644 index 0000000000..10d0648501 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/annotation/visitor/package.html @@ -0,0 +1,3 @@ +<body> +This package contains visitors for annotation attributes and their components. +</body> diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/package.html b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/package.html new file mode 100644 index 0000000000..d17caaafdc --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/package.html @@ -0,0 +1,3 @@ +<body> +This package contains classes to represent the attributes inside class files. +</body> diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/DoubleType.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/DoubleType.java new file mode 100644 index 0000000000..ff124d7b1d --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/DoubleType.java @@ -0,0 +1,66 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.preverification; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.preverification.visitor.VerificationTypeVisitor; + +/** + * This VerificationType represents a Double type. + * + * @author Eric Lafortune + */ +public class DoubleType extends VerificationType +{ + // Implementations for VerificationType. + + public int getTag() + { + return DOUBLE_TYPE; + } + + + public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, int instructionOffset, VerificationTypeVisitor verificationTypeVisitor) + { + verificationTypeVisitor.visitDoubleType(clazz, method, codeAttribute, instructionOffset, this); + } + + + public void stackAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, int instructionOffset, int stackIndex, VerificationTypeVisitor verificationTypeVisitor) + { + verificationTypeVisitor.visitStackDoubleType(clazz, method, codeAttribute, instructionOffset, stackIndex, this); + } + + + public void variablesAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, int instructionOffset, int variableIndex, VerificationTypeVisitor verificationTypeVisitor) + { + verificationTypeVisitor.visitVariablesDoubleType(clazz, method, codeAttribute, instructionOffset, variableIndex, this); + } + + + // Implementations for Object. + + public String toString() + { + return "d"; + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/FloatType.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/FloatType.java new file mode 100644 index 0000000000..3a8e8315c2 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/FloatType.java @@ -0,0 +1,66 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.preverification; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.preverification.visitor.VerificationTypeVisitor; + +/** + * This VerificationType represents a Float type. + * + * @author Eric Lafortune + */ +public class FloatType extends VerificationType +{ + // Implementations for VerificationType. + + public int getTag() + { + return FLOAT_TYPE; + } + + + public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, int instructionOffset, VerificationTypeVisitor verificationTypeVisitor) + { + verificationTypeVisitor.visitFloatType(clazz, method, codeAttribute, instructionOffset, this); + } + + + public void stackAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, int instructionOffset, int stackIndex, VerificationTypeVisitor verificationTypeVisitor) + { + verificationTypeVisitor.visitStackFloatType(clazz, method, codeAttribute, instructionOffset, stackIndex, this); + } + + + public void variablesAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, int instructionOffset, int variableIndex, VerificationTypeVisitor verificationTypeVisitor) + { + verificationTypeVisitor.visitVariablesFloatType(clazz, method, codeAttribute, instructionOffset, variableIndex, this); + } + + + // Implementations for Object. + + public String toString() + { + return "f"; + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/FullFrame.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/FullFrame.java new file mode 100644 index 0000000000..8c405d2246 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/FullFrame.java @@ -0,0 +1,202 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.preverification; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.preverification.visitor.*; + +/** + * This StackMapFrame represents a "full frame". + * + * @author Eric Lafortune + */ +public class FullFrame extends StackMapFrame +{ + public int variablesCount; + public VerificationType[] variables; + public int stackCount; + public VerificationType[] stack; + + + /** + * Creates an uninitialized FullFrame. + */ + public FullFrame() + { + } + + + /** + * Creates a FullFrame with the given variables and stack. + */ + public FullFrame(int offsetDelta, + VerificationType[] variables, + VerificationType[] stack) + { + this(offsetDelta, + variables.length, + variables, + stack.length, + stack); + } + + + /** + * Creates a FullFrame with the given variables and stack. + */ + public FullFrame(int offsetDelta, + int variablesCount, + VerificationType[] variables, + int stackCount, + VerificationType[] stack) + { + this.u2offsetDelta = offsetDelta; + this.variablesCount = variablesCount; + this.variables = variables; + this.stackCount = stackCount; + this.stack = stack; + } + + + /** + * Applies the given verification type visitor to all variables. + */ + public void variablesAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, VerificationTypeVisitor verificationTypeVisitor) + { + for (int index = 0; index < variablesCount; index++) + { + variables[index].variablesAccept(clazz, method, codeAttribute, offset, index, verificationTypeVisitor); + } + } + + + /** + * Applies the given verification type visitor to all stack. + */ + public void stackAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, VerificationTypeVisitor verificationTypeVisitor) + { + for (int index = 0; index < stackCount; index++) + { + stack[index].stackAccept(clazz, method, codeAttribute, offset, index, verificationTypeVisitor); + } + } + + + // Implementations for StackMapFrame. + + public int getTag() + { + return FULL_FRAME; + } + + + public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, StackMapFrameVisitor stackMapFrameVisitor) + { + stackMapFrameVisitor.visitFullFrame(clazz, method, codeAttribute, offset, this); + } + + + // Implementations for Object. + + public boolean equals(Object object) + { + if (!super.equals(object)) + { + return false; + } + + FullFrame other = (FullFrame)object; + + if (this.u2offsetDelta != other.u2offsetDelta || + this.variablesCount != other.variablesCount || + this.stackCount != other.stackCount) + { + return false; + } + + for (int index = 0; index < variablesCount; index++) + { + VerificationType thisType = this.variables[index]; + VerificationType otherType = other.variables[index]; + + if (!thisType.equals(otherType)) + { + return false; + } + } + + for (int index = 0; index < stackCount; index++) + { + VerificationType thisType = this.stack[index]; + VerificationType otherType = other.stack[index]; + + if (!thisType.equals(otherType)) + { + return false; + } + } + + return true; + } + + + public int hashCode() + { + int hashCode = super.hashCode(); + + for (int index = 0; index < variablesCount; index++) + { + hashCode ^= variables[index].hashCode(); + } + + for (int index = 0; index < stackCount; index++) + { + hashCode ^= stack[index].hashCode(); + } + + return hashCode; + } + + + public String toString() + { + StringBuffer buffer = new StringBuffer(super.toString()).append("Var: "); + + for (int index = 0; index < variablesCount; index++) + { + buffer = buffer.append('[') + .append(variables[index].toString()) + .append(']'); + } + + buffer.append(", Stack: "); + + for (int index = 0; index < stackCount; index++) + { + buffer = buffer.append('[') + .append(stack[index].toString()) + .append(']'); + } + + return buffer.toString(); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/IntegerType.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/IntegerType.java new file mode 100644 index 0000000000..5228b61b4e --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/IntegerType.java @@ -0,0 +1,66 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.preverification; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.preverification.visitor.VerificationTypeVisitor; + +/** + * This VerificationType represents a Integer type. + * + * @author Eric Lafortune + */ +public class IntegerType extends VerificationType +{ + // Implementations for VerificationType. + + public int getTag() + { + return INTEGER_TYPE; + } + + + public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, int instructionOffset, VerificationTypeVisitor verificationTypeVisitor) + { + verificationTypeVisitor.visitIntegerType(clazz, method, codeAttribute, instructionOffset, this); + } + + + public void stackAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, int instructionOffset, int stackIndex, VerificationTypeVisitor verificationTypeVisitor) + { + verificationTypeVisitor.visitStackIntegerType(clazz, method, codeAttribute, instructionOffset, stackIndex, this); + } + + + public void variablesAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, int instructionOffset, int variableIndex, VerificationTypeVisitor verificationTypeVisitor) + { + verificationTypeVisitor.visitVariablesIntegerType(clazz, method, codeAttribute, instructionOffset, variableIndex, this); + } + + + // Implementations for Object. + + public String toString() + { + return "i"; + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/LessZeroFrame.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/LessZeroFrame.java new file mode 100644 index 0000000000..4308506380 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/LessZeroFrame.java @@ -0,0 +1,103 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.preverification; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.preverification.visitor.StackMapFrameVisitor; + +/** + * This StackMapFrame represents an "chop frame". + * + * @author Eric Lafortune + */ +public class LessZeroFrame extends StackMapFrame +{ + public int choppedVariablesCount; + + + /** + * Creates an uninitialized LessZeroFrame. + */ + public LessZeroFrame() + { + } + + + /** + * Creates a LessZeroFrame with the given tag. + */ + public LessZeroFrame(int tag) + { + choppedVariablesCount = LESS_ZERO_FRAME + 3 - tag; + } + + + /** + * Creates a LessZeroFrame with the given number of chopped variables. + */ + public LessZeroFrame(byte choppedVariablesCount) + { + this.choppedVariablesCount = (int)choppedVariablesCount; + } + + + // Implementations for StackMapFrame. + + public int getTag() + { + return LESS_ZERO_FRAME + 3 - choppedVariablesCount; + } + + + public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, StackMapFrameVisitor stackMapFrameVisitor) + { + stackMapFrameVisitor.visitLessZeroFrame(clazz, method, codeAttribute, offset, this); + } + + + // Implementations for Object. + + public boolean equals(Object object) + { + if (!super.equals(object)) + { + return false; + } + + LessZeroFrame other = (LessZeroFrame)object; + + return this.u2offsetDelta == other.u2offsetDelta && + this.choppedVariablesCount != other.choppedVariablesCount; + } + + + public int hashCode() + { + return super.hashCode() ^ choppedVariablesCount; + } + + + public String toString() + { + return super.toString()+"Var: (chopped "+choppedVariablesCount+"), Stack: (empty)"; + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/LongType.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/LongType.java new file mode 100644 index 0000000000..82b8af9075 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/LongType.java @@ -0,0 +1,66 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.preverification; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.preverification.visitor.VerificationTypeVisitor; + +/** + * This VerificationType represents a Long type. + * + * @author Eric Lafortune + */ +public class LongType extends VerificationType +{ + // Implementations for VerificationType. + + public int getTag() + { + return LONG_TYPE; + } + + + public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, int instructionOffset, VerificationTypeVisitor verificationTypeVisitor) + { + verificationTypeVisitor.visitLongType(clazz, method, codeAttribute, instructionOffset, this); + } + + + public void stackAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, int instructionOffset, int stackIndex, VerificationTypeVisitor verificationTypeVisitor) + { + verificationTypeVisitor.visitStackLongType(clazz, method, codeAttribute, instructionOffset, stackIndex, this); + } + + + public void variablesAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, int instructionOffset, int variableIndex, VerificationTypeVisitor verificationTypeVisitor) + { + verificationTypeVisitor.visitVariablesLongType(clazz, method, codeAttribute, instructionOffset, variableIndex, this); + } + + + // Implementations for Object. + + public String toString() + { + return "l"; + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/MoreZeroFrame.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/MoreZeroFrame.java new file mode 100644 index 0000000000..a8858048e6 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/MoreZeroFrame.java @@ -0,0 +1,161 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.preverification; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.preverification.visitor.*; + +/** + * This StackMapFrame represents an "append frame". + * + * @author Eric Lafortune + */ +public class MoreZeroFrame extends StackMapFrame +{ + public int additionalVariablesCount; + public VerificationType[] additionalVariables; + + + /** + * Creates an uninitialized MoreZeroFrame. + */ + public MoreZeroFrame() + { + } + + + /** + * Creates a MoreZeroFrame with the given tag. + */ + public MoreZeroFrame(int tag) + { + additionalVariablesCount = tag + 1 - MORE_ZERO_FRAME; + } + + + /** + * Creates a MoreZeroFrame with the given additional variables. + */ + public MoreZeroFrame(VerificationType[] additionalVariables) + { + this(additionalVariables.length, additionalVariables); + } + + + /** + * Creates a MoreZeroFrame with the given additional variables. + */ + public MoreZeroFrame(int additionalVariablesCount, + VerificationType[] additionalVariables) + { + this.additionalVariablesCount = additionalVariablesCount; + this.additionalVariables = additionalVariables; + } + + + /** + * Applies the given verification type visitor to all variables. + */ + public void additionalVariablesAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, VerificationTypeVisitor verificationTypeVisitor) + { + for (int index = 0; index < additionalVariablesCount; index++) + { + additionalVariables[index].accept(clazz, method, codeAttribute, offset, verificationTypeVisitor); + } + } + + + // Implementations for StackMapFrame. + + public int getTag() + { + return MORE_ZERO_FRAME + additionalVariablesCount - 1; + } + + + public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, StackMapFrameVisitor stackMapFrameVisitor) + { + stackMapFrameVisitor.visitMoreZeroFrame(clazz, method, codeAttribute, offset, this); + } + + + // Implementations for Object. + + public boolean equals(Object object) + { + if (!super.equals(object)) + { + return false; + } + + MoreZeroFrame other = (MoreZeroFrame)object; + + if (this.u2offsetDelta != other.u2offsetDelta || + this.additionalVariablesCount != other.additionalVariablesCount) + { + return false; + } + + for (int index = 0; index < additionalVariablesCount; index++) + { + VerificationType thisType = this.additionalVariables[index]; + VerificationType otherType = other.additionalVariables[index]; + + if (!thisType.equals(otherType)) + { + return false; + } + } + + return true; + } + + + public int hashCode() + { + int hashCode = super.hashCode(); + + for (int index = 0; index < additionalVariablesCount; index++) + { + hashCode ^= additionalVariables[index].hashCode(); + } + + return hashCode; + } + + + public String toString() + { + StringBuffer buffer = new StringBuffer(super.toString()).append("Var: ..."); + + for (int index = 0; index < additionalVariablesCount; index++) + { + buffer = buffer.append('[') + .append(additionalVariables[index].toString()) + .append(']'); + } + + buffer.append(", Stack: (empty)"); + + return buffer.toString(); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/NullType.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/NullType.java new file mode 100644 index 0000000000..96003f0676 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/NullType.java @@ -0,0 +1,66 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.preverification; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.preverification.visitor.VerificationTypeVisitor; + +/** + * This VerificationType represents a Null type. + * + * @author Eric Lafortune + */ +public class NullType extends VerificationType +{ + // Implementations for VerificationType. + + public int getTag() + { + return NULL_TYPE; + } + + + public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, int instructionOffset, VerificationTypeVisitor verificationTypeVisitor) + { + verificationTypeVisitor.visitNullType(clazz, method, codeAttribute, instructionOffset, this); + } + + + public void stackAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, int instructionOffset, int stackIndex, VerificationTypeVisitor verificationTypeVisitor) + { + verificationTypeVisitor.visitStackNullType(clazz, method, codeAttribute, instructionOffset, stackIndex, this); + } + + + public void variablesAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, int instructionOffset, int variableIndex, VerificationTypeVisitor verificationTypeVisitor) + { + verificationTypeVisitor.visitVariablesNullType(clazz, method, codeAttribute, instructionOffset, variableIndex, this); + } + + + // Implementations for Object. + + public String toString() + { + return "n"; + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/ObjectType.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/ObjectType.java new file mode 100644 index 0000000000..5a4f1b775d --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/ObjectType.java @@ -0,0 +1,107 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.preverification; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.preverification.visitor.VerificationTypeVisitor; + +/** + * This VerificationType represents an Object type. + * + * @author Eric Lafortune + */ +public class ObjectType extends VerificationType +{ + public int u2classIndex; + + + + /** + * Creates an uninitialized ObjectType. + */ + public ObjectType() + { + } + + + /** + * Creates an ObjectType that points to the given class constant. + */ + public ObjectType(int u2classIndex) + { + this.u2classIndex = u2classIndex; + } + + + // Implementations for VerificationType. + + public int getTag() + { + return OBJECT_TYPE; + } + + + public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, int instructionOffset, VerificationTypeVisitor verificationTypeVisitor) + { + verificationTypeVisitor.visitObjectType(clazz, method, codeAttribute, instructionOffset, this); + } + + + public void stackAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, int instructionOffset, int stackIndex, VerificationTypeVisitor verificationTypeVisitor) + { + verificationTypeVisitor.visitStackObjectType(clazz, method, codeAttribute, instructionOffset, stackIndex, this); + } + + + public void variablesAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, int instructionOffset, int variableIndex, VerificationTypeVisitor verificationTypeVisitor) + { + verificationTypeVisitor.visitVariablesObjectType(clazz, method, codeAttribute, instructionOffset, variableIndex, this); + } + + + // Implementations for Object. + + public boolean equals(Object object) + { + if (!super.equals(object)) + { + return false; + } + + ObjectType other = (ObjectType)object; + + return this.u2classIndex == other.u2classIndex; + } + + + public int hashCode() + { + return super.hashCode() ^ + u2classIndex; + } + + + public String toString() + { + return "a:" + u2classIndex; + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/SameOneFrame.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/SameOneFrame.java new file mode 100644 index 0000000000..8a16762709 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/SameOneFrame.java @@ -0,0 +1,115 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.preverification; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.preverification.visitor.*; + +/** + * This StackMapFrame represents a "same locals 1 stack item frame" or a + * "same locals 1 stack item frame extended". + * + * @author Eric Lafortune + */ +public class SameOneFrame extends StackMapFrame +{ + public VerificationType stackItem; + + + /** + * Creates an uninitialized SameOneFrame. + */ + public SameOneFrame() + { + } + + + /** + * Creates a SameOneFrame with the given tag. + */ + public SameOneFrame(int tag) + { + u2offsetDelta = tag - SAME_ONE_FRAME; + } + + + /** + * Creates a SameOneFrame with the given stack verification type. + */ + public SameOneFrame(VerificationType stackItem) + { + this.stackItem = stackItem; + } + + + /** + * Applies the given verification type visitor to the stack item. + */ + public void stackItemAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, VerificationTypeVisitor verificationTypeVisitor) + { + stackItem.accept(clazz, method, codeAttribute, offset, verificationTypeVisitor); + } + + + // Implementations for StackMapFrame. + + public int getTag() + { + return u2offsetDelta < 64 ? + SAME_ONE_FRAME + u2offsetDelta : + SAME_ONE_FRAME_EXTENDED; + } + + + public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, StackMapFrameVisitor stackMapFrameVisitor) + { + stackMapFrameVisitor.visitSameOneFrame(clazz, method, codeAttribute, offset, this); + } + + + // Implementations for Object. + + public boolean equals(Object object) + { + if (!super.equals(object)) + { + return false; + } + + SameOneFrame other = (SameOneFrame)object; + + return this.u2offsetDelta == other.u2offsetDelta && + this.stackItem.equals(other.stackItem); + } + + + public int hashCode() + { + return super.hashCode() ^ stackItem.hashCode(); + } + + + public String toString() + { + return super.toString()+"Var: ..., Stack: ["+stackItem.toString()+"]"; + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/SameZeroFrame.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/SameZeroFrame.java new file mode 100644 index 0000000000..90200ba03d --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/SameZeroFrame.java @@ -0,0 +1,74 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.preverification; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.preverification.visitor.StackMapFrameVisitor; + +/** + * This StackMapFrame represents a "same frame" or a "same frame extended". + * + * @author Eric Lafortune + * @noinspection PointlessArithmeticExpression + */ +public class SameZeroFrame extends StackMapFrame +{ + /** + * Creates an uninitialized SameZeroFrame. + */ + public SameZeroFrame() + { + } + + + /** + * Creates a SameZeroFrame with the given tag. + */ + public SameZeroFrame(int tag) + { + u2offsetDelta = tag - SAME_ZERO_FRAME; + } + + + // Implementations for StackMapFrame. + + public int getTag() + { + return u2offsetDelta < 64 ? + SAME_ZERO_FRAME + u2offsetDelta : + SAME_ZERO_FRAME_EXTENDED; + } + + + public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, StackMapFrameVisitor stackMapFrameVisitor) + { + stackMapFrameVisitor.visitSameZeroFrame(clazz, method, codeAttribute, offset, this); + } + + + // Implementations for Object. + + public String toString() + { + return super.toString()+"Var: ..., Stack: (empty)"; + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/StackMapAttribute.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/StackMapAttribute.java new file mode 100644 index 0000000000..5ff0a08327 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/StackMapAttribute.java @@ -0,0 +1,91 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.preverification; + +import proguard.classfile.*; +import proguard.classfile.attribute.*; +import proguard.classfile.attribute.preverification.visitor.StackMapFrameVisitor; +import proguard.classfile.attribute.visitor.AttributeVisitor; + +/** + * This Attribute represents an exceptions attribute. + * + * @author Eric Lafortune + */ +public class StackMapAttribute extends Attribute +{ + public int u2stackMapFramesCount; + public FullFrame[] stackMapFrames; + + + /** + * Creates an uninitialized ExceptionsAttribute. + */ + public StackMapAttribute() + { + } + + + /** + * Creates a StackMapTableAttribute with the given stack map frames. + */ + public StackMapAttribute(FullFrame[] stackMapFrames) + { + this(stackMapFrames.length, stackMapFrames); + } + + + /** + * Creates a StackMapTableAttribute with the given stack map frames. + */ + public StackMapAttribute(int stackMapFramesCount, + FullFrame[] stackMapFrames) + { + this.u2stackMapFramesCount = stackMapFramesCount; + this.stackMapFrames = stackMapFrames; + } + + + + + // Implementations for Attribute. + + public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitStackMapAttribute(clazz, method, codeAttribute, this); + } + + + /** + * Applies the given stack map frame visitor to all stack map frames. + */ + public void stackMapFramesAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, StackMapFrameVisitor stackMapFrameVisitor) + { + for (int index = 0; index < u2stackMapFramesCount; index++) + { + FullFrame stackMapFrame = stackMapFrames[index]; + + // We don't need double dispatching here, since there is only one + // type of StackMapFrame. + stackMapFrameVisitor.visitFullFrame(clazz, method, codeAttribute, stackMapFrame.getOffsetDelta(), stackMapFrame); + } + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/StackMapFrame.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/StackMapFrame.java new file mode 100644 index 0000000000..474650cc2a --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/StackMapFrame.java @@ -0,0 +1,117 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.preverification; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.preverification.visitor.StackMapFrameVisitor; + +/** + * This abstract class represents a stack map frame. Specific types + * of entries are subclassed from it. + * + * @author Eric Lafortune + */ +public abstract class StackMapFrame implements VisitorAccepter +{ + public static final int SAME_ZERO_FRAME = 0; + public static final int SAME_ONE_FRAME = 64; + public static final int SAME_ONE_FRAME_EXTENDED = 247; + public static final int LESS_ZERO_FRAME = 248; + public static final int SAME_ZERO_FRAME_EXTENDED = 251; + public static final int MORE_ZERO_FRAME = 252; + public static final int FULL_FRAME = 255; + + + public int u2offsetDelta; + + /** + * An extra field in which visitors can store information. + */ + public Object visitorInfo; + + + + /** + * Returns the bytecode offset delta relative to the previous stack map + * frame. + */ + public int getOffsetDelta() + { + return u2offsetDelta; + } + + + // Abstract methods to be implemented by extensions. + + /** + * Returns the stack map frame tag that specifies the entry type. + */ + public abstract int getTag(); + + + /** + * Accepts the given visitor. + */ + public abstract void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, StackMapFrameVisitor stackMapFrameVisitor); + + + // Implementations for VisitorAccepter. + + public Object getVisitorInfo() + { + return visitorInfo; + } + + public void setVisitorInfo(Object visitorInfo) + { + this.visitorInfo = visitorInfo; + } + + + // Implementations for Object. + + public boolean equals(Object object) + { + if (object == null || + this.getClass() != object.getClass()) + { + return false; + } + + StackMapFrame other = (StackMapFrame)object; + + return this.u2offsetDelta == other.u2offsetDelta; + } + + + public int hashCode() + { + return getClass().hashCode() ^ + u2offsetDelta; + } + + + public String toString() + { + return "[" + u2offsetDelta + "] "; + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/StackMapTableAttribute.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/StackMapTableAttribute.java new file mode 100644 index 0000000000..b122221e7a --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/StackMapTableAttribute.java @@ -0,0 +1,93 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.preverification; + +import proguard.classfile.*; +import proguard.classfile.attribute.*; +import proguard.classfile.attribute.preverification.visitor.StackMapFrameVisitor; +import proguard.classfile.attribute.visitor.AttributeVisitor; + +/** + * This Attribute represents a stack map table attribute. + * + * @author Eric Lafortune + */ +public class StackMapTableAttribute extends Attribute +{ + public int u2stackMapFramesCount; + public StackMapFrame[] stackMapFrames; + + + /** + * Creates an uninitialized StackMapTableAttribute. + */ + public StackMapTableAttribute() + { + } + + + /** + * Creates a StackMapTableAttribute with the given stack map frames. + */ + public StackMapTableAttribute(StackMapFrame[] stackMapFrames) + { + this(stackMapFrames.length, stackMapFrames); + } + + + /** + * Creates a StackMapTableAttribute with the given stack map frames. + */ + public StackMapTableAttribute(int stackMapFramesCount, + StackMapFrame[] stackMapFrames) + { + this.u2stackMapFramesCount = stackMapFramesCount; + this.stackMapFrames = stackMapFrames; + } + + + // Implementations for Attribute. + + public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitStackMapTableAttribute(clazz, method, codeAttribute, this); + } + + + /** + * Applies the given stack map frame visitor to all stack map frames. + */ + public void stackMapFramesAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, StackMapFrameVisitor stackMapFrameVisitor) + { + int offset = 0; + + for (int index = 0; index < u2stackMapFramesCount; index++) + { + StackMapFrame stackMapFrame = stackMapFrames[index]; + + // Note that the byte code offset is computed differently for the + // first stack map frame. + offset += stackMapFrame.getOffsetDelta() + (index == 0 ? 0 : 1); + + stackMapFrame.accept(clazz, method, codeAttribute, offset, stackMapFrameVisitor); + } + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/TopType.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/TopType.java new file mode 100644 index 0000000000..065c9ebc64 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/TopType.java @@ -0,0 +1,66 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.preverification; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.preverification.visitor.VerificationTypeVisitor; + +/** + * This VerificationType represents a Top type. + * + * @author Eric Lafortune + */ +public class TopType extends VerificationType +{ + // Implementations for VerificationType. + + public int getTag() + { + return TOP_TYPE; + } + + + public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, int instructionOffset, VerificationTypeVisitor verificationTypeVisitor) + { + verificationTypeVisitor.visitTopType(clazz, method, codeAttribute, instructionOffset, this); + } + + + public void stackAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, int instructionOffset, int stackIndex, VerificationTypeVisitor verificationTypeVisitor) + { + verificationTypeVisitor.visitStackTopType(clazz, method, codeAttribute, instructionOffset, stackIndex, this); + } + + + public void variablesAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, int instructionOffset, int variableIndex, VerificationTypeVisitor verificationTypeVisitor) + { + verificationTypeVisitor.visitVariablesTopType(clazz, method, codeAttribute, instructionOffset, variableIndex, this); + } + + + // Implementations for Object. + + public String toString() + { + return "T"; + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/UninitializedThisType.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/UninitializedThisType.java new file mode 100644 index 0000000000..21d210be6b --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/UninitializedThisType.java @@ -0,0 +1,66 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.preverification; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.preverification.visitor.VerificationTypeVisitor; + +/** + * This VerificationType represents a UninitializedThis type. + * + * @author Eric Lafortune + */ +public class UninitializedThisType extends VerificationType +{ + // Implementations for VerificationType. + + public int getTag() + { + return UNINITIALIZED_THIS_TYPE; + } + + + public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, int instructionOffset, VerificationTypeVisitor verificationTypeVisitor) + { + verificationTypeVisitor.visitUninitializedThisType(clazz, method, codeAttribute, instructionOffset, this); + } + + + public void stackAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, int instructionOffset, int stackIndex, VerificationTypeVisitor verificationTypeVisitor) + { + verificationTypeVisitor.visitStackUninitializedThisType(clazz, method, codeAttribute, instructionOffset, stackIndex, this); + } + + + public void variablesAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, int instructionOffset, int variableIndex, VerificationTypeVisitor verificationTypeVisitor) + { + verificationTypeVisitor.visitVariablesUninitializedThisType(clazz, method, codeAttribute, instructionOffset, variableIndex, this); + } + + + // Implementations for Object. + + public String toString() + { + return "u:this"; + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/UninitializedType.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/UninitializedType.java new file mode 100644 index 0000000000..ad44e05c7c --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/UninitializedType.java @@ -0,0 +1,106 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.preverification; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.preverification.visitor.VerificationTypeVisitor; + +/** + * This VerificationType represents a Uninitialized type. + * + * @author Eric Lafortune + */ +public class UninitializedType extends VerificationType +{ + public int u2newInstructionOffset; + + + /** + * Creates an uninitialized UninitializedType. + */ + public UninitializedType() + { + } + + + /** + * Creates an UninitializedType pointing to the given 'new' instruction. + */ + public UninitializedType(int u2newInstructionOffset) + { + this.u2newInstructionOffset = u2newInstructionOffset; + } + + + // Implementations for VerificationType. + + public int getTag() + { + return UNINITIALIZED_TYPE; + } + + + public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, int instructionOffset, VerificationTypeVisitor verificationTypeVisitor) + { + verificationTypeVisitor.visitUninitializedType(clazz, method, codeAttribute, instructionOffset, this); + } + + + public void stackAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, int instructionOffset, int stackIndex, VerificationTypeVisitor verificationTypeVisitor) + { + verificationTypeVisitor.visitStackUninitializedType(clazz, method, codeAttribute, instructionOffset, stackIndex, this); + } + + + public void variablesAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, int instructionOffset, int variableIndex, VerificationTypeVisitor verificationTypeVisitor) + { + verificationTypeVisitor.visitVariablesUninitializedType(clazz, method, codeAttribute, instructionOffset, variableIndex, this); + } + + + // Implementations for Object. + + public boolean equals(Object object) + { + if (!super.equals(object)) + { + return false; + } + + UninitializedType other = (UninitializedType)object; + + return this.u2newInstructionOffset == other.u2newInstructionOffset; + } + + + public int hashCode() + { + return super.hashCode() ^ + u2newInstructionOffset; + } + + + public String toString() + { + return "u:" + u2newInstructionOffset; + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/VerificationType.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/VerificationType.java new file mode 100644 index 0000000000..29ff241fdb --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/VerificationType.java @@ -0,0 +1,103 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.preverification; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.preverification.visitor.VerificationTypeVisitor; + +/** + * This abstract class represents a verification type of a local variable or + * a stack element. Specific verification types are subclassed from it. + * + * @author Eric Lafortune + */ +public abstract class VerificationType implements VisitorAccepter +{ + public static final int TOP_TYPE = 0; + public static final int INTEGER_TYPE = 1; + public static final int FLOAT_TYPE = 2; + public static final int DOUBLE_TYPE = 3; + public static final int LONG_TYPE = 4; + public static final int NULL_TYPE = 5; + public static final int UNINITIALIZED_THIS_TYPE = 6; + public static final int OBJECT_TYPE = 7; + public static final int UNINITIALIZED_TYPE = 8; + + + /** + * An extra field in which visitors can store information. + */ + public Object visitorInfo; + + + /** + * Returns the tag of the verification type. + */ + public abstract int getTag(); + + + /** + * Accepts the given visitor in the context of a method's code, either on + * a stack or as a variable. + */ + public abstract void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, int instructionOffset, VerificationTypeVisitor verificationTypeVisitor); + + + /** + * Accepts the given visitor in the context of a stack in a method's code . + */ + public abstract void stackAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, int instructionOffset, int stackIndex, VerificationTypeVisitor verificationTypeVisitor); + + + /** + * Accepts the given visitor in the context of a variable in a method's code. + */ + public abstract void variablesAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, int instructionOffset, int variableIndex, VerificationTypeVisitor verificationTypeVisitor); + + + // Implementations for VisitorAccepter. + + public Object getVisitorInfo() + { + return visitorInfo; + } + + public void setVisitorInfo(Object visitorInfo) + { + this.visitorInfo = visitorInfo; + } + + + // Implementations for Object. + + public boolean equals(Object object) + { + return object != null && + this.getClass() == object.getClass(); + } + + + public int hashCode() + { + return this.getClass().hashCode(); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/VerificationTypeFactory.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/VerificationTypeFactory.java new file mode 100644 index 0000000000..3fca3d3524 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/VerificationTypeFactory.java @@ -0,0 +1,112 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.preverification; + +/** + * This class provides methods to create and reuse IntegerType objects. + * + * @author Eric Lafortune + */ +public class VerificationTypeFactory +{ + // Shared copies of Type objects, to avoid creating a lot of objects. + static final IntegerType INTEGER_TYPE = new IntegerType(); + static final LongType LONG_TYPE = new LongType(); + static final FloatType FLOAT_TYPE = new FloatType(); + static final DoubleType DOUBLE_TYPE = new DoubleType(); + static final TopType TOP_TYPE = new TopType(); + static final NullType NULL_TYPE = new NullType(); + static final UninitializedThisType UNINITIALIZED_THIS_TYPE = new UninitializedThisType(); + + + /** + * Creates a new IntegerType. + */ + public static IntegerType createIntegerType() + { + return INTEGER_TYPE; + } + + /** + * Creates a new LongType. + */ + public static LongType createLongType() + { + return LONG_TYPE; + } + + /** + * Creates a new FloatType. + */ + public static FloatType createFloatType() + { + return FLOAT_TYPE; + } + + /** + * Creates a new DoubleType. + */ + public static DoubleType createDoubleType() + { + return DOUBLE_TYPE; + } + + /** + * Creates a new TopType. + */ + public static TopType createTopType() + { + return TOP_TYPE; + } + + /** + * Creates a new NullType. + */ + public static NullType createNullType() + { + return NULL_TYPE; + } + + /** + * Creates a new UninitializedThisType. + */ + public static UninitializedThisType createUninitializedThisType() + { + return UNINITIALIZED_THIS_TYPE; + } + + /** + * Creates a new UninitializedType for an instance that was created at + * the given offset. + */ + public static UninitializedType createUninitializedType(int newInstructionOffset) + { + return new UninitializedType(newInstructionOffset); + } + + /** + * Creates a new ObjectType of the given type. + */ + public static ObjectType createObjectType(int classIndex) + { + return new ObjectType(classIndex); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/visitor/StackMapFrameVisitor.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/visitor/StackMapFrameVisitor.java new file mode 100644 index 0000000000..910bd3965e --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/visitor/StackMapFrameVisitor.java @@ -0,0 +1,40 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.preverification.visitor; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.preverification.*; + +/** + * This interface specifies the methods for a visitor of + * <code>StackMapFrame</code> objects. + * + * @author Eric Lafortune + */ +public interface StackMapFrameVisitor +{ + public void visitSameZeroFrame(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, SameZeroFrame sameZeroFrame); + public void visitSameOneFrame( Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, SameOneFrame sameOneFrame); + public void visitLessZeroFrame(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, LessZeroFrame lessZeroFrame); + public void visitMoreZeroFrame(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, MoreZeroFrame moreZeroFrame); + public void visitFullFrame( Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, FullFrame fullFrame); +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/visitor/VerificationTypeVisitor.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/visitor/VerificationTypeVisitor.java new file mode 100644 index 0000000000..3f087d5803 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/preverification/visitor/VerificationTypeVisitor.java @@ -0,0 +1,65 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.preverification.visitor; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.preverification.*; + +/** + * This interface specifies the methods for a visitor of + * <code>VerificationType</code> objects. There a methods for stack entries + * and methods for variable entries. + * + * @author Eric Lafortune + */ +public interface VerificationTypeVisitor +{ + public void visitIntegerType( Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, IntegerType integerType); + public void visitFloatType( Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, FloatType floatType); + public void visitLongType( Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, LongType longType); + public void visitDoubleType( Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, DoubleType doubleType); + public void visitTopType( Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, TopType topType); + public void visitObjectType( Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, ObjectType objectType); + public void visitNullType( Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, NullType nullType); + public void visitUninitializedType( Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, UninitializedType uninitializedType); + public void visitUninitializedThisType(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, UninitializedThisType uninitializedThisType); + + public void visitStackIntegerType( Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, int index, IntegerType integerType); + public void visitStackFloatType( Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, int index, FloatType floatType); + public void visitStackLongType( Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, int index, LongType longType); + public void visitStackDoubleType( Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, int index, DoubleType doubleType); + public void visitStackTopType( Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, int index, TopType topType); + public void visitStackObjectType( Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, int index, ObjectType objectType); + public void visitStackNullType( Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, int index, NullType nullType); + public void visitStackUninitializedType( Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, int index, UninitializedType uninitializedType); + public void visitStackUninitializedThisType(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, int index, UninitializedThisType uninitializedThisType); + + public void visitVariablesIntegerType( Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, int index, IntegerType integerType); + public void visitVariablesFloatType( Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, int index, FloatType floatType); + public void visitVariablesLongType( Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, int index, LongType longType); + public void visitVariablesDoubleType( Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, int index, DoubleType doubleType); + public void visitVariablesTopType( Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, int index, TopType topType); + public void visitVariablesObjectType( Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, int index, ObjectType objectType); + public void visitVariablesNullType( Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, int index, NullType nullType); + public void visitVariablesUninitializedType( Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, int index, UninitializedType uninitializedType); + public void visitVariablesUninitializedThisType(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, int index, UninitializedThisType uninitializedThisType); +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/AllAttributeVisitor.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/AllAttributeVisitor.java new file mode 100644 index 0000000000..62c53fb031 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/AllAttributeVisitor.java @@ -0,0 +1,117 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.visitor; + +import proguard.classfile.*; +import proguard.classfile.attribute.*; +import proguard.classfile.util.SimplifiedVisitor; +import proguard.classfile.visitor.*; + +/** + * This ClassVisitor, MemberVisitor, and AttributeVisitor lets a given + * AttributeVisitor visit all Attribute objects of the program classes, + * program class members, or code attributes, respectively, that it visits. + * + * @author Eric Lafortune + */ +public class AllAttributeVisitor +extends SimplifiedVisitor +implements ClassVisitor, + MemberVisitor, + AttributeVisitor +{ + private final boolean deep; + private final AttributeVisitor attributeVisitor; + + + /** + * Creates a new shallow AllAttributeVisitor. + * @param attributeVisitor the AttributeVisitor to which visits will be + * delegated. + */ + public AllAttributeVisitor(AttributeVisitor attributeVisitor) + { + this(false, attributeVisitor); + } + + + /** + * Creates a new optionally deep AllAttributeVisitor. + * @param deep specifies whether the attributes contained + * further down the class structure should be + * visited too. + * @param attributeVisitor the AttributeVisitor to which visits will be + * delegated. + */ + public AllAttributeVisitor(boolean deep, + AttributeVisitor attributeVisitor) + { + this.deep = deep; + this.attributeVisitor = attributeVisitor; + } + + + // Implementations for ClassVisitor. + + public void visitProgramClass(ProgramClass programClass) + { + programClass.attributesAccept(attributeVisitor); + + // Visit the attributes further down the class structure, if required. + if (deep) + { + programClass.fieldsAccept(this); + programClass.methodsAccept(this); + programClass.attributesAccept(this); + } + } + + + public void visitLibraryClass(LibraryClass libraryClass) {} + + + // Implementations for MemberVisitor. + + public void visitProgramMember(ProgramClass programClass, ProgramMember programMember) + { + programMember.attributesAccept(programClass, attributeVisitor); + + // Visit the attributes further down the member structure, if required. + if (deep) + { + programMember.attributesAccept(programClass, this); + } + } + + + public void visitLibraryMember(LibraryClass programClass, LibraryMember programMember) {} + + + // Implementations for AttributeVisitor. + + public void visitAnyAttribute(Clazz clazz, Attribute attribute) {} + + + public void visitCodeAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute) + { + codeAttribute.attributesAccept(clazz, method, attributeVisitor); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/AllBootstrapMethodInfoVisitor.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/AllBootstrapMethodInfoVisitor.java new file mode 100644 index 0000000000..11e892f684 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/AllBootstrapMethodInfoVisitor.java @@ -0,0 +1,55 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.visitor; + +import proguard.classfile.Clazz; +import proguard.classfile.attribute.*; +import proguard.classfile.util.SimplifiedVisitor; + +/** + * This AttributeVisitor lets a given BootstrapMethodInfoVisitor visit all + * bootstrap method objects of the BootstrapMethodsAttribute objects it visits. + * + * @author Eric Lafortune + */ +public class AllBootstrapMethodInfoVisitor +extends SimplifiedVisitor +implements AttributeVisitor +{ + private final BootstrapMethodInfoVisitor bootstrapMethodInfoVisitor; + + + public AllBootstrapMethodInfoVisitor(BootstrapMethodInfoVisitor bootstrapMethodInfoVisitor) + { + this.bootstrapMethodInfoVisitor = bootstrapMethodInfoVisitor; + } + + + // Implementations for AttributeVisitor. + + public void visitAnyAttribute(Clazz clazz, Attribute attribute) {} + + + public void visitBootstrapMethodsAttribute(Clazz clazz, BootstrapMethodsAttribute bootstrapMethodsAttribute) + { + bootstrapMethodsAttribute.bootstrapMethodEntriesAccept(clazz, bootstrapMethodInfoVisitor); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/AllExceptionInfoVisitor.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/AllExceptionInfoVisitor.java new file mode 100644 index 0000000000..1e4a6d6bf3 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/AllExceptionInfoVisitor.java @@ -0,0 +1,55 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.visitor; + +import proguard.classfile.*; +import proguard.classfile.attribute.*; +import proguard.classfile.util.SimplifiedVisitor; + +/** + * This AttributeVisitor lets a given ExceptionInfoVisitor visit all exceptions + * objects of the CodeAttribute objects it visits. + * + * @author Eric Lafortune + */ +public class AllExceptionInfoVisitor +extends SimplifiedVisitor +implements AttributeVisitor +{ + private final ExceptionInfoVisitor exceptionInfoVisitor; + + + public AllExceptionInfoVisitor(ExceptionInfoVisitor exceptionInfoVisitor) + { + this.exceptionInfoVisitor = exceptionInfoVisitor; + } + + + // Implementations for AttributeVisitor. + + public void visitAnyAttribute(Clazz clazz, Attribute attribute) {} + + + public void visitCodeAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute) + { + codeAttribute.exceptionsAccept(clazz, method, exceptionInfoVisitor); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/AllInnerClassesInfoVisitor.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/AllInnerClassesInfoVisitor.java new file mode 100644 index 0000000000..2c2d5603d9 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/AllInnerClassesInfoVisitor.java @@ -0,0 +1,55 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.visitor; + +import proguard.classfile.Clazz; +import proguard.classfile.attribute.*; +import proguard.classfile.util.SimplifiedVisitor; + +/** + * This AttributeVisitor lets a given InnerClassesInfoVisitor visit all + * InnerClassessInfo objects of the InnerClassesAttribute objects it visits. + * + * @author Eric Lafortune + */ +public class AllInnerClassesInfoVisitor +extends SimplifiedVisitor +implements AttributeVisitor +{ + private final InnerClassesInfoVisitor innerClassesInfoVisitor; + + + public AllInnerClassesInfoVisitor(InnerClassesInfoVisitor innerClassesInfoVisitor) + { + this.innerClassesInfoVisitor = innerClassesInfoVisitor; + } + + + // Implementations for AttributeVisitor. + + public void visitAnyAttribute(Clazz clazz, Attribute attribute) {} + + + public void visitInnerClassesAttribute(Clazz clazz, InnerClassesAttribute innerClassesAttribute) + { + innerClassesAttribute.innerClassEntriesAccept(clazz, innerClassesInfoVisitor); + } +}
\ No newline at end of file diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/AllLineNumberInfoVisitor.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/AllLineNumberInfoVisitor.java new file mode 100644 index 0000000000..a3a37ba455 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/AllLineNumberInfoVisitor.java @@ -0,0 +1,55 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.visitor; + +import proguard.classfile.*; +import proguard.classfile.attribute.*; +import proguard.classfile.util.SimplifiedVisitor; + +/** + * This AttributeVisitor lets a given LineNumberInfoVisitor visit all line numbers + * of the LineNumberTableAttribute objects it visits. + * + * @author Eric Lafortune + */ +public class AllLineNumberInfoVisitor +extends SimplifiedVisitor +implements AttributeVisitor +{ + private final LineNumberInfoVisitor lineNumberInfoVisitor; + + + public AllLineNumberInfoVisitor(LineNumberInfoVisitor lineNumberInfoVisitor) + { + this.lineNumberInfoVisitor = lineNumberInfoVisitor; + } + + + // Implementations for AttributeVisitor. + + public void visitAnyAttribute(Clazz clazz, Attribute attribute) {} + + + public void visitLineNumberTableAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, LineNumberTableAttribute lineNumberTableAttribute) + { + lineNumberTableAttribute.lineNumbersAccept(clazz, method, codeAttribute, lineNumberInfoVisitor); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/AttributeNameFilter.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/AttributeNameFilter.java new file mode 100644 index 0000000000..340e4f223c --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/AttributeNameFilter.java @@ -0,0 +1,467 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.visitor; + +import proguard.classfile.*; +import proguard.classfile.attribute.*; +import proguard.classfile.attribute.annotation.*; +import proguard.classfile.attribute.preverification.*; +import proguard.util.*; + +import java.util.List; + +/** + * This AttributeVisitor delegates its visits another AttributeVisitor, but + * only when the visited attribute has a name that that matches a given regular + * expression. + * + * @author Eric Lafortune + */ +public class AttributeNameFilter +implements AttributeVisitor +{ + private final StringMatcher regularExpressionMatcher; + private final AttributeVisitor attributeVisitor; + + + /** + * Creates a new AttributeNameFilter. + * @param regularExpression the regular expression against which attribute + * names will be matched. + * @param attributeVisitor the <code>AttributeVisitor</code> to which + * visits will be delegated. + */ + public AttributeNameFilter(String regularExpression, + AttributeVisitor attributeVisitor) + { + this(new ListParser(new NameParser()).parse(regularExpression), + attributeVisitor); + } + + + /** + * Creates a new AttributeNameFilter. + * @param regularExpression the regular expression against which attribute + * names will be matched. + * @param attributeVisitor the <code>AttributeVisitor</code> to which + * visits will be delegated. + */ + public AttributeNameFilter(List regularExpression, + AttributeVisitor attributeVisitor) + { + this(new ListParser(new NameParser()).parse(regularExpression), + attributeVisitor); + } + + + /** + * Creates a new AttributeNameFilter. + * @param regularExpressionMatcher the string matcher against which + * attribute names will be matched. + * @param attributeVisitor the <code>AttributeVisitor</code> to + * which visits will be delegated. + */ + public AttributeNameFilter(StringMatcher regularExpressionMatcher, + AttributeVisitor attributeVisitor) + { + this.regularExpressionMatcher = regularExpressionMatcher; + this.attributeVisitor = attributeVisitor; + } + + + // Implementations for AttributeVisitor. + + public void visitUnknownAttribute(Clazz clazz, UnknownAttribute unknownAttribute) + { + if (accepted(clazz, unknownAttribute)) + { + attributeVisitor.visitUnknownAttribute(clazz, unknownAttribute); + } + } + + + public void visitBootstrapMethodsAttribute(Clazz clazz, BootstrapMethodsAttribute bootstrapMethodsAttribute) + { + if (accepted(clazz, bootstrapMethodsAttribute)) + { + attributeVisitor.visitBootstrapMethodsAttribute(clazz, bootstrapMethodsAttribute); + } + } + + + public void visitSourceFileAttribute(Clazz clazz, SourceFileAttribute sourceFileAttribute) + { + if (accepted(clazz, sourceFileAttribute)) + { + attributeVisitor.visitSourceFileAttribute(clazz, sourceFileAttribute); + } + } + + + public void visitSourceDirAttribute(Clazz clazz, SourceDirAttribute sourceDirAttribute) + { + if (accepted(clazz, sourceDirAttribute)) + { + attributeVisitor.visitSourceDirAttribute(clazz, sourceDirAttribute); + } + } + + + public void visitInnerClassesAttribute(Clazz clazz, InnerClassesAttribute innerClassesAttribute) + { + if (accepted(clazz, innerClassesAttribute)) + { + attributeVisitor.visitInnerClassesAttribute(clazz, innerClassesAttribute); + } + } + + + public void visitEnclosingMethodAttribute(Clazz clazz, EnclosingMethodAttribute enclosingMethodAttribute) + { + if (accepted(clazz, enclosingMethodAttribute)) + { + attributeVisitor.visitEnclosingMethodAttribute(clazz, enclosingMethodAttribute); + } + } + + + public void visitDeprecatedAttribute(Clazz clazz, DeprecatedAttribute deprecatedAttribute) + { + if (accepted(clazz, deprecatedAttribute)) + { + attributeVisitor.visitDeprecatedAttribute(clazz, deprecatedAttribute); + } + } + + + public void visitDeprecatedAttribute(Clazz clazz, Field field, DeprecatedAttribute deprecatedAttribute) + { + if (accepted(clazz, deprecatedAttribute)) + { + attributeVisitor.visitDeprecatedAttribute(clazz, field, deprecatedAttribute); + } + } + + + public void visitDeprecatedAttribute(Clazz clazz, Method method, DeprecatedAttribute deprecatedAttribute) + { + if (accepted(clazz, deprecatedAttribute)) + { + attributeVisitor.visitDeprecatedAttribute(clazz, method, deprecatedAttribute); + } + } + + + public void visitSyntheticAttribute(Clazz clazz, SyntheticAttribute syntheticAttribute) + { + if (accepted(clazz, syntheticAttribute)) + { + attributeVisitor.visitSyntheticAttribute(clazz, syntheticAttribute); + } + } + + + public void visitSyntheticAttribute(Clazz clazz, Field field, SyntheticAttribute syntheticAttribute) + { + if (accepted(clazz, syntheticAttribute)) + { + attributeVisitor.visitSyntheticAttribute(clazz, field, syntheticAttribute); + } + } + + + public void visitSyntheticAttribute(Clazz clazz, Method method, SyntheticAttribute syntheticAttribute) + { + if (accepted(clazz, syntheticAttribute)) + { + attributeVisitor.visitSyntheticAttribute(clazz, method, syntheticAttribute); + } + } + + + public void visitSignatureAttribute(Clazz clazz, SignatureAttribute signatureAttribute) + { + if (accepted(clazz, signatureAttribute)) + { + attributeVisitor.visitSignatureAttribute(clazz, signatureAttribute); + } + } + + + public void visitSignatureAttribute(Clazz clazz, Field field, SignatureAttribute signatureAttribute) + { + if (accepted(clazz, signatureAttribute)) + { + attributeVisitor.visitSignatureAttribute(clazz, field, signatureAttribute); + } + } + + + public void visitSignatureAttribute(Clazz clazz, Method method, SignatureAttribute signatureAttribute) + { + if (accepted(clazz, signatureAttribute)) + { + attributeVisitor.visitSignatureAttribute(clazz, method, signatureAttribute); + } + } + + + public void visitConstantValueAttribute(Clazz clazz, Field field, ConstantValueAttribute constantValueAttribute) + { + if (accepted(clazz, constantValueAttribute)) + { + attributeVisitor.visitConstantValueAttribute(clazz, field, constantValueAttribute); + } + } + + + public void visitMethodParametersAttribute(Clazz clazz, Method method, MethodParametersAttribute exceptionsAttribute) + { + if (accepted(clazz, exceptionsAttribute)) + { + attributeVisitor.visitMethodParametersAttribute(clazz, method, exceptionsAttribute); + } + } + + + public void visitExceptionsAttribute(Clazz clazz, Method method, ExceptionsAttribute exceptionsAttribute) + { + if (accepted(clazz, exceptionsAttribute)) + { + attributeVisitor.visitExceptionsAttribute(clazz, method, exceptionsAttribute); + } + } + + + public void visitCodeAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute) + { + if (accepted(clazz, codeAttribute)) + { + attributeVisitor.visitCodeAttribute(clazz, method, codeAttribute); + } + } + + + public void visitStackMapAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, StackMapAttribute stackMapAttribute) + { + if (accepted(clazz, stackMapAttribute)) + { + attributeVisitor.visitStackMapAttribute(clazz, method, codeAttribute, stackMapAttribute); + } + } + + + public void visitStackMapTableAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, StackMapTableAttribute stackMapTableAttribute) + { + if (accepted(clazz, stackMapTableAttribute)) + { + attributeVisitor.visitStackMapTableAttribute(clazz, method, codeAttribute, stackMapTableAttribute); + } + } + + + public void visitLineNumberTableAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, LineNumberTableAttribute lineNumberTableAttribute) + { + if (accepted(clazz, lineNumberTableAttribute)) + { + attributeVisitor.visitLineNumberTableAttribute(clazz, method, codeAttribute, lineNumberTableAttribute); + } + } + + + public void visitLocalVariableTableAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, LocalVariableTableAttribute localVariableTableAttribute) + { + if (accepted(clazz, localVariableTableAttribute)) + { + attributeVisitor.visitLocalVariableTableAttribute(clazz, method, codeAttribute, localVariableTableAttribute); + } + } + + + public void visitLocalVariableTypeTableAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, LocalVariableTypeTableAttribute localVariableTypeTableAttribute) + { + if (accepted(clazz, localVariableTypeTableAttribute)) + { + attributeVisitor.visitLocalVariableTypeTableAttribute(clazz, method, codeAttribute, localVariableTypeTableAttribute); + } + } + + + public void visitRuntimeVisibleAnnotationsAttribute(Clazz clazz, RuntimeVisibleAnnotationsAttribute runtimeVisibleAnnotationsAttribute) + { + if (accepted(clazz, runtimeVisibleAnnotationsAttribute)) + { + attributeVisitor.visitRuntimeVisibleAnnotationsAttribute(clazz, runtimeVisibleAnnotationsAttribute); + } + } + + + public void visitRuntimeVisibleAnnotationsAttribute(Clazz clazz, Field field, RuntimeVisibleAnnotationsAttribute runtimeVisibleAnnotationsAttribute) + { + if (accepted(clazz, runtimeVisibleAnnotationsAttribute)) + { + attributeVisitor.visitRuntimeVisibleAnnotationsAttribute(clazz, field, runtimeVisibleAnnotationsAttribute); + } + } + + + public void visitRuntimeVisibleAnnotationsAttribute(Clazz clazz, Method method, RuntimeVisibleAnnotationsAttribute runtimeVisibleAnnotationsAttribute) + { + if (accepted(clazz, runtimeVisibleAnnotationsAttribute)) + { + attributeVisitor.visitRuntimeVisibleAnnotationsAttribute(clazz, method, runtimeVisibleAnnotationsAttribute); + } + } + + + public void visitRuntimeInvisibleAnnotationsAttribute(Clazz clazz, RuntimeInvisibleAnnotationsAttribute runtimeInvisibleAnnotationsAttribute) + { + if (accepted(clazz, runtimeInvisibleAnnotationsAttribute)) + { + attributeVisitor.visitRuntimeInvisibleAnnotationsAttribute(clazz, runtimeInvisibleAnnotationsAttribute); + } + } + + + public void visitRuntimeInvisibleAnnotationsAttribute(Clazz clazz, Field field, RuntimeInvisibleAnnotationsAttribute runtimeInvisibleAnnotationsAttribute) + { + if (accepted(clazz, runtimeInvisibleAnnotationsAttribute)) + { + attributeVisitor.visitRuntimeInvisibleAnnotationsAttribute(clazz, field, runtimeInvisibleAnnotationsAttribute); + } + } + + + public void visitRuntimeInvisibleAnnotationsAttribute(Clazz clazz, Method method, RuntimeInvisibleAnnotationsAttribute runtimeInvisibleAnnotationsAttribute) + { + if (accepted(clazz, runtimeInvisibleAnnotationsAttribute)) + { + attributeVisitor.visitRuntimeInvisibleAnnotationsAttribute(clazz, method, runtimeInvisibleAnnotationsAttribute); + } + } + + + public void visitRuntimeVisibleParameterAnnotationsAttribute(Clazz clazz, Method method, RuntimeVisibleParameterAnnotationsAttribute runtimeVisibleParameterAnnotationsAttribute) + { + if (accepted(clazz, runtimeVisibleParameterAnnotationsAttribute)) + { + attributeVisitor.visitRuntimeVisibleParameterAnnotationsAttribute(clazz, method, runtimeVisibleParameterAnnotationsAttribute); + } + } + + + public void visitRuntimeInvisibleParameterAnnotationsAttribute(Clazz clazz, Method method, RuntimeInvisibleParameterAnnotationsAttribute runtimeInvisibleParameterAnnotationsAttribute) + { + if (accepted(clazz, runtimeInvisibleParameterAnnotationsAttribute)) + { + attributeVisitor.visitRuntimeInvisibleParameterAnnotationsAttribute(clazz, method, runtimeInvisibleParameterAnnotationsAttribute); + } + } + + + public void visitRuntimeVisibleTypeAnnotationsAttribute(Clazz clazz, RuntimeVisibleTypeAnnotationsAttribute runtimeVisibleTypeAnnotationsAttribute) + { + if (accepted(clazz, runtimeVisibleTypeAnnotationsAttribute)) + { + attributeVisitor.visitRuntimeVisibleTypeAnnotationsAttribute(clazz, runtimeVisibleTypeAnnotationsAttribute); + } + } + + + public void visitRuntimeVisibleTypeAnnotationsAttribute(Clazz clazz, Field field, RuntimeVisibleTypeAnnotationsAttribute runtimeVisibleTypeAnnotationsAttribute) + { + if (accepted(clazz, runtimeVisibleTypeAnnotationsAttribute)) + { + attributeVisitor.visitRuntimeVisibleTypeAnnotationsAttribute(clazz, field, runtimeVisibleTypeAnnotationsAttribute); + } + } + + + public void visitRuntimeVisibleTypeAnnotationsAttribute(Clazz clazz, Method method, RuntimeVisibleTypeAnnotationsAttribute runtimeVisibleTypeAnnotationsAttribute) + { + if (accepted(clazz, runtimeVisibleTypeAnnotationsAttribute)) + { + attributeVisitor.visitRuntimeVisibleTypeAnnotationsAttribute(clazz, method, runtimeVisibleTypeAnnotationsAttribute); + } + } + + + public void visitRuntimeVisibleTypeAnnotationsAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, RuntimeVisibleTypeAnnotationsAttribute runtimeVisibleTypeAnnotationsAttribute) + { + if (accepted(clazz, runtimeVisibleTypeAnnotationsAttribute)) + { + attributeVisitor.visitRuntimeVisibleTypeAnnotationsAttribute(clazz, method, codeAttribute, runtimeVisibleTypeAnnotationsAttribute); + } + } + + + public void visitRuntimeInvisibleTypeAnnotationsAttribute(Clazz clazz, RuntimeInvisibleTypeAnnotationsAttribute runtimeInvisibleTypeAnnotationsAttribute) + { + if (accepted(clazz, runtimeInvisibleTypeAnnotationsAttribute)) + { + attributeVisitor.visitRuntimeInvisibleTypeAnnotationsAttribute(clazz, runtimeInvisibleTypeAnnotationsAttribute); + } + } + + + public void visitRuntimeInvisibleTypeAnnotationsAttribute(Clazz clazz, Field field, RuntimeInvisibleTypeAnnotationsAttribute runtimeInvisibleTypeAnnotationsAttribute) + { + if (accepted(clazz, runtimeInvisibleTypeAnnotationsAttribute)) + { + attributeVisitor.visitRuntimeInvisibleTypeAnnotationsAttribute(clazz, field, runtimeInvisibleTypeAnnotationsAttribute); + } + } + + + public void visitRuntimeInvisibleTypeAnnotationsAttribute(Clazz clazz, Method method, RuntimeInvisibleTypeAnnotationsAttribute runtimeInvisibleTypeAnnotationsAttribute) + { + if (accepted(clazz, runtimeInvisibleTypeAnnotationsAttribute)) + { + attributeVisitor.visitRuntimeInvisibleTypeAnnotationsAttribute(clazz, method, runtimeInvisibleTypeAnnotationsAttribute); + } + } + + + public void visitRuntimeInvisibleTypeAnnotationsAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, RuntimeInvisibleTypeAnnotationsAttribute runtimeInvisibleTypeAnnotationsAttribute) + { + if (accepted(clazz, runtimeInvisibleTypeAnnotationsAttribute)) + { + attributeVisitor.visitRuntimeInvisibleTypeAnnotationsAttribute(clazz, method, codeAttribute, runtimeInvisibleTypeAnnotationsAttribute); + } + } + + + public void visitAnnotationDefaultAttribute(Clazz clazz, Method method, AnnotationDefaultAttribute annotationDefaultAttribute) + { + if (accepted(clazz, annotationDefaultAttribute)) + { + attributeVisitor.visitAnnotationDefaultAttribute(clazz, method, annotationDefaultAttribute); + } + } + + + // Small utility methods. + + private boolean accepted(Clazz clazz, Attribute attribute) + { + return regularExpressionMatcher.matches(attribute.getAttributeName(clazz)); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/AttributeVisitor.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/AttributeVisitor.java new file mode 100644 index 0000000000..668d13a7a6 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/AttributeVisitor.java @@ -0,0 +1,101 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.visitor; + +import proguard.classfile.*; +import proguard.classfile.attribute.*; +import proguard.classfile.attribute.annotation.*; +import proguard.classfile.attribute.preverification.*; + +/** + * This interface specifies the methods for a visitor of <code>Attribute</code> + * objects. + * + * @author Eric Lafortune + */ +public interface AttributeVisitor +{ + // Attributes that are attached to classes. + + public void visitUnknownAttribute( Clazz clazz, UnknownAttribute unknownAttribute); + public void visitBootstrapMethodsAttribute( Clazz clazz, BootstrapMethodsAttribute bootstrapMethodsAttribute); + public void visitSourceFileAttribute( Clazz clazz, SourceFileAttribute sourceFileAttribute); + public void visitSourceDirAttribute( Clazz clazz, SourceDirAttribute sourceDirAttribute); + public void visitInnerClassesAttribute( Clazz clazz, InnerClassesAttribute innerClassesAttribute); + public void visitEnclosingMethodAttribute( Clazz clazz, EnclosingMethodAttribute enclosingMethodAttribute); + + // Attributes that are attached to classes, fields, and methods. + + public void visitDeprecatedAttribute( Clazz clazz, DeprecatedAttribute deprecatedAttribute); + public void visitDeprecatedAttribute( Clazz clazz, Field field, DeprecatedAttribute deprecatedAttribute); + public void visitDeprecatedAttribute( Clazz clazz, Method method, DeprecatedAttribute deprecatedAttribute); + + public void visitSyntheticAttribute( Clazz clazz, SyntheticAttribute syntheticAttribute); + public void visitSyntheticAttribute( Clazz clazz, Field field, SyntheticAttribute syntheticAttribute); + public void visitSyntheticAttribute( Clazz clazz, Method method, SyntheticAttribute syntheticAttribute); + + public void visitSignatureAttribute( Clazz clazz, SignatureAttribute signatureAttribute); + public void visitSignatureAttribute( Clazz clazz, Field field, SignatureAttribute signatureAttribute); + public void visitSignatureAttribute( Clazz clazz, Method method, SignatureAttribute signatureAttribute); + + // Attributes that are attached to fields. + + public void visitConstantValueAttribute( Clazz clazz, Field field, ConstantValueAttribute constantValueAttribute); + + // Attributes that are attached to methods. + + public void visitMethodParametersAttribute( Clazz clazz, Method method, MethodParametersAttribute methodParametersAttribute); + public void visitExceptionsAttribute( Clazz clazz, Method method, ExceptionsAttribute exceptionsAttribute); + public void visitCodeAttribute( Clazz clazz, Method method, CodeAttribute codeAttribute); + + // Attributes that are attached to code attributes. + + public void visitStackMapAttribute( Clazz clazz, Method method, CodeAttribute codeAttribute, StackMapAttribute stackMapAttribute); + public void visitStackMapTableAttribute( Clazz clazz, Method method, CodeAttribute codeAttribute, StackMapTableAttribute stackMapTableAttribute); + public void visitLineNumberTableAttribute( Clazz clazz, Method method, CodeAttribute codeAttribute, LineNumberTableAttribute lineNumberTableAttribute); + public void visitLocalVariableTableAttribute( Clazz clazz, Method method, CodeAttribute codeAttribute, LocalVariableTableAttribute localVariableTableAttribute); + public void visitLocalVariableTypeTableAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, LocalVariableTypeTableAttribute localVariableTypeTableAttribute); + + // Annotation attributes. + + public void visitRuntimeVisibleAnnotationsAttribute( Clazz clazz, RuntimeVisibleAnnotationsAttribute runtimeVisibleAnnotationsAttribute); + public void visitRuntimeVisibleAnnotationsAttribute( Clazz clazz, Field field, RuntimeVisibleAnnotationsAttribute runtimeVisibleAnnotationsAttribute); + public void visitRuntimeVisibleAnnotationsAttribute( Clazz clazz, Method method, RuntimeVisibleAnnotationsAttribute runtimeVisibleAnnotationsAttribute); + + public void visitRuntimeInvisibleAnnotationsAttribute( Clazz clazz, RuntimeInvisibleAnnotationsAttribute runtimeInvisibleAnnotationsAttribute); + public void visitRuntimeInvisibleAnnotationsAttribute( Clazz clazz, Field field, RuntimeInvisibleAnnotationsAttribute runtimeInvisibleAnnotationsAttribute); + public void visitRuntimeInvisibleAnnotationsAttribute( Clazz clazz, Method method, RuntimeInvisibleAnnotationsAttribute runtimeInvisibleAnnotationsAttribute); + + public void visitRuntimeVisibleParameterAnnotationsAttribute( Clazz clazz, Method method, RuntimeVisibleParameterAnnotationsAttribute runtimeVisibleParameterAnnotationsAttribute); + public void visitRuntimeInvisibleParameterAnnotationsAttribute(Clazz clazz, Method method, RuntimeInvisibleParameterAnnotationsAttribute runtimeInvisibleParameterAnnotationsAttribute); + + public void visitRuntimeVisibleTypeAnnotationsAttribute( Clazz clazz, RuntimeVisibleTypeAnnotationsAttribute runtimeVisibleTypeAnnotationsAttribute); + public void visitRuntimeVisibleTypeAnnotationsAttribute( Clazz clazz, Field field, RuntimeVisibleTypeAnnotationsAttribute runtimeVisibleTypeAnnotationsAttribute); + public void visitRuntimeVisibleTypeAnnotationsAttribute( Clazz clazz, Method method, RuntimeVisibleTypeAnnotationsAttribute runtimeVisibleTypeAnnotationsAttribute); + public void visitRuntimeVisibleTypeAnnotationsAttribute( Clazz clazz, Method method, CodeAttribute codeAttribute, RuntimeVisibleTypeAnnotationsAttribute runtimeVisibleTypeAnnotationsAttribute); + + public void visitRuntimeInvisibleTypeAnnotationsAttribute( Clazz clazz, RuntimeInvisibleTypeAnnotationsAttribute runtimeInvisibleTypeAnnotationsAttribute); + public void visitRuntimeInvisibleTypeAnnotationsAttribute( Clazz clazz, Field field, RuntimeInvisibleTypeAnnotationsAttribute runtimeInvisibleTypeAnnotationsAttribute); + public void visitRuntimeInvisibleTypeAnnotationsAttribute( Clazz clazz, Method method, RuntimeInvisibleTypeAnnotationsAttribute runtimeInvisibleTypeAnnotationsAttribute); + public void visitRuntimeInvisibleTypeAnnotationsAttribute( Clazz clazz, Method method, CodeAttribute codeAttribute, RuntimeInvisibleTypeAnnotationsAttribute runtimeInvisibleTypeAnnotationsAttribute); + + public void visitAnnotationDefaultAttribute( Clazz clazz, Method method, AnnotationDefaultAttribute annotationDefaultAttribute); +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/BootstrapMethodInfoVisitor.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/BootstrapMethodInfoVisitor.java new file mode 100755 index 0000000000..f796837765 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/BootstrapMethodInfoVisitor.java @@ -0,0 +1,38 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.visitor; + +import proguard.classfile.Clazz; +import proguard.classfile.attribute.BootstrapMethodInfo; + + +/** + * This interface specifies the methods for a visitor of + * <code>BootstrapMethodInfo</code> objects. Note that there is only a single + * implementation of <code>BootstrapMethodInfo</code>, such that this interface + * is not strictly necessary as a visitor. + * + * @author Eric Lafortune + */ +public interface BootstrapMethodInfoVisitor +{ + public void visitBootstrapMethodInfo(Clazz clazz, BootstrapMethodInfo bootstrapMethodInfo); +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/ExceptionInfoVisitor.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/ExceptionInfoVisitor.java new file mode 100644 index 0000000000..e15ab7cb10 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/ExceptionInfoVisitor.java @@ -0,0 +1,37 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.visitor; + +import proguard.classfile.*; +import proguard.classfile.attribute.*; + +/** + * This interface specifies the methods for a visitor of + * <code>ExceptionInfo</code> objects. Note that there is only a single + * implementation of <code>ExceptionInfo</code>, such that this interface + * is not strictly necessary as a visitor. + * + * @author Eric Lafortune + */ +public interface ExceptionInfoVisitor +{ + public void visitExceptionInfo(Clazz clazz, Method method, CodeAttribute codeAttribute, ExceptionInfo exceptionInfo); +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/InnerClassesInfoVisitor.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/InnerClassesInfoVisitor.java new file mode 100644 index 0000000000..d4e498493a --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/InnerClassesInfoVisitor.java @@ -0,0 +1,38 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.visitor; + +import proguard.classfile.Clazz; +import proguard.classfile.attribute.InnerClassesInfo; + + +/** + * This interface specifies the methods for a visitor of + * <code>InnerClassesInfo</code> objects. Note that there is only a single + * implementation of <code>InnerClassesInfo</code>, such that this interface + * is not strictly necessary as a visitor. + * + * @author Eric Lafortune + */ +public interface InnerClassesInfoVisitor +{ + public void visitInnerClassesInfo(Clazz clazz, InnerClassesInfo innerClassesInfo); +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/LineNumberInfoVisitor.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/LineNumberInfoVisitor.java new file mode 100644 index 0000000000..c58d11304a --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/LineNumberInfoVisitor.java @@ -0,0 +1,38 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.visitor; + +import proguard.classfile.*; +import proguard.classfile.attribute.*; + + +/** + * This interface specifies the methods for a visitor of + * <code>LineNumberInfo</code> objects. Note that there is only a single + * implementation of <code>LineNumberInfo</code>, such that this interface + * is not strictly necessary as a visitor. + * + * @author Eric Lafortune + */ +public interface LineNumberInfoVisitor +{ + public void visitLineNumberInfo(Clazz clazz, Method method, CodeAttribute codeAttribute, LineNumberInfo lineNumberInfo); +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/LineNumberRangeFinder.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/LineNumberRangeFinder.java new file mode 100644 index 0000000000..4cbbff0d7f --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/LineNumberRangeFinder.java @@ -0,0 +1,89 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.visitor; + +import proguard.classfile.*; +import proguard.classfile.attribute.*; + +/** + * This LineNumberInfoVisitor remembers the lowest and the highest line + * numbers that it finds in all the line numbers that it visits. It + * ignores the sources of the line numbers. + */ +public class LineNumberRangeFinder +implements LineNumberInfoVisitor +{ + private int lowestLineNumber = Integer.MAX_VALUE; + private int highestLineNumber = 0; + private boolean hasSource; + + + /** + * Returns the lowest line number that has been visited so far. + */ + public int getLowestLineNumber() + { + return lowestLineNumber; + } + + + /** + * Returns the highest line number that has been visited so far. + */ + public int getHighestLineNumber() + { + return highestLineNumber; + } + + + /** + * Returns whether any of the visited line numbers has a non-null source. + */ + public boolean hasSource() + { + return hasSource; + } + + + // Implementations for LineNumberInfoVisitor. + + public void visitLineNumberInfo(Clazz clazz, Method method, CodeAttribute codeAttribute, LineNumberInfo lineNumberInfo) + { + int lineNumber = lineNumberInfo.u2lineNumber; + + // Remember the lowest line number. + if (lowestLineNumber > lineNumber) + { + lowestLineNumber = lineNumber; + } + + // Remember the highest line number. + if (highestLineNumber < lineNumber) + { + highestLineNumber = lineNumber; + } + + if (lineNumberInfo.getSource() != null) + { + hasSource = true; + } + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/LocalVariableInfoVisitor.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/LocalVariableInfoVisitor.java new file mode 100644 index 0000000000..523c1922f4 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/LocalVariableInfoVisitor.java @@ -0,0 +1,38 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.visitor; + +import proguard.classfile.*; +import proguard.classfile.attribute.*; + + +/** + * This interface specifies the methods for a visitor of + * <code>LocalVariableInfo</code> objects. Note that there is only a single + * implementation of <code>LocalVariableInfo</code>, such that this interface + * is not strictly necessary as a visitor. + * + * @author Eric Lafortune + */ +public interface LocalVariableInfoVisitor +{ + public void visitLocalVariableInfo(Clazz clazz, Method method, CodeAttribute codeAttribute, LocalVariableInfo localVariableInfo); +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/LocalVariableTypeInfoVisitor.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/LocalVariableTypeInfoVisitor.java new file mode 100644 index 0000000000..870d340788 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/LocalVariableTypeInfoVisitor.java @@ -0,0 +1,38 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.visitor; + +import proguard.classfile.*; +import proguard.classfile.attribute.*; + + +/** + * This interface specifies the methods for a visitor of + * <code>LocalVariableTypeInfo</code> objects. Note that there is only a single + * implementation of <code>LocalVariableTypeInfo</code>, such that this interface + * is not strictly necessary as a visitor. + * + * @author Eric Lafortune + */ +public interface LocalVariableTypeInfoVisitor +{ + public void visitLocalVariableTypeInfo(Clazz clazz, Method method, CodeAttribute codeAttribute, LocalVariableTypeInfo localVariableTypeInfo); +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/MultiAttributeVisitor.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/MultiAttributeVisitor.java new file mode 100644 index 0000000000..92698ef9ce --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/MultiAttributeVisitor.java @@ -0,0 +1,446 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.visitor; + +import proguard.classfile.*; +import proguard.classfile.attribute.*; +import proguard.classfile.attribute.annotation.*; +import proguard.classfile.attribute.preverification.*; + +/** + * This AttributeVisitor delegates all visits to each AttributeVisitor + * in a given list. + * + * @author Eric Lafortune + */ +public class MultiAttributeVisitor implements AttributeVisitor +{ + private AttributeVisitor[] attributeVisitors; + + + public MultiAttributeVisitor() + { + } + + + public MultiAttributeVisitor(AttributeVisitor[] attributeVisitors) + { + this.attributeVisitors = attributeVisitors; + } + + + public void addAttributeVisitor(AttributeVisitor attributeVisitor) + { + incrementArraySize(); + + attributeVisitors[attributeVisitors.length - 1] = attributeVisitor; + } + + + private void incrementArraySize() + { + if (attributeVisitors == null) + { + attributeVisitors = new AttributeVisitor[1]; + } + else + { + AttributeVisitor[] newAttributeVisitors = + new AttributeVisitor[attributeVisitors.length + 1]; + System.arraycopy(attributeVisitors, 0, + newAttributeVisitors, 0, + attributeVisitors.length); + attributeVisitors = newAttributeVisitors; + } + } + + + // Implementations for AttributeVisitor. + + + public void visitUnknownAttribute(Clazz clazz, UnknownAttribute unknownAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitUnknownAttribute(clazz, unknownAttribute); + } + } + + + public void visitBootstrapMethodsAttribute(Clazz clazz, BootstrapMethodsAttribute bootstrapMethodsAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitBootstrapMethodsAttribute(clazz, bootstrapMethodsAttribute); + } + } + + + public void visitSourceFileAttribute(Clazz clazz, SourceFileAttribute sourceFileAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitSourceFileAttribute(clazz, sourceFileAttribute); + } + } + + + public void visitSourceDirAttribute(Clazz clazz, SourceDirAttribute sourceDirAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitSourceDirAttribute(clazz, sourceDirAttribute); + } + } + + + public void visitInnerClassesAttribute(Clazz clazz, InnerClassesAttribute innerClassesAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitInnerClassesAttribute(clazz, innerClassesAttribute); + } + } + + + public void visitEnclosingMethodAttribute(Clazz clazz, EnclosingMethodAttribute enclosingMethodAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitEnclosingMethodAttribute(clazz, enclosingMethodAttribute); + } + } + + + public void visitDeprecatedAttribute(Clazz clazz, DeprecatedAttribute deprecatedAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitDeprecatedAttribute(clazz, deprecatedAttribute); + } + } + + + public void visitSyntheticAttribute(Clazz clazz, SyntheticAttribute syntheticAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitSyntheticAttribute(clazz, syntheticAttribute); + } + } + + + public void visitSignatureAttribute(Clazz clazz, SignatureAttribute syntheticAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitSignatureAttribute(clazz, syntheticAttribute); + } + } + + + public void visitDeprecatedAttribute(Clazz clazz, Field field, DeprecatedAttribute deprecatedAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitDeprecatedAttribute(clazz, field, deprecatedAttribute); + } + } + + + public void visitSyntheticAttribute(Clazz clazz, Field field, SyntheticAttribute syntheticAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitSyntheticAttribute(clazz, field, syntheticAttribute); + } + } + + + public void visitSignatureAttribute(Clazz clazz, Field field, SignatureAttribute syntheticAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitSignatureAttribute(clazz, field, syntheticAttribute); + } + } + + + public void visitDeprecatedAttribute(Clazz clazz, Method method, DeprecatedAttribute deprecatedAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitDeprecatedAttribute(clazz, method, deprecatedAttribute); + } + } + + + public void visitSyntheticAttribute(Clazz clazz, Method method, SyntheticAttribute syntheticAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitSyntheticAttribute(clazz, method, syntheticAttribute); + } + } + + + public void visitSignatureAttribute(Clazz clazz, Method method, SignatureAttribute syntheticAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitSignatureAttribute(clazz, method, syntheticAttribute); + } + } + + + public void visitConstantValueAttribute(Clazz clazz, Field field, ConstantValueAttribute constantValueAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitConstantValueAttribute(clazz, field, constantValueAttribute); + } + } + + + public void visitMethodParametersAttribute(Clazz clazz, Method method, MethodParametersAttribute methodParametersAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitMethodParametersAttribute(clazz, method, methodParametersAttribute); + } + } + + + public void visitExceptionsAttribute(Clazz clazz, Method method, ExceptionsAttribute exceptionsAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitExceptionsAttribute(clazz, method, exceptionsAttribute); + } + } + + + public void visitCodeAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitCodeAttribute(clazz, method, codeAttribute); + } + } + + + public void visitStackMapAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, StackMapAttribute stackMapAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitStackMapAttribute(clazz, method, codeAttribute, stackMapAttribute); + } + } + + + public void visitStackMapTableAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, StackMapTableAttribute stackMapTableAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitStackMapTableAttribute(clazz, method, codeAttribute, stackMapTableAttribute); + } + } + + + public void visitLineNumberTableAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, LineNumberTableAttribute lineNumberTableAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitLineNumberTableAttribute(clazz, method, codeAttribute, lineNumberTableAttribute); + } + } + + + public void visitLocalVariableTableAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, LocalVariableTableAttribute localVariableTableAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitLocalVariableTableAttribute(clazz, method, codeAttribute, localVariableTableAttribute); + } + } + + + public void visitLocalVariableTypeTableAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, LocalVariableTypeTableAttribute localVariableTypeTableAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitLocalVariableTypeTableAttribute(clazz, method, codeAttribute, localVariableTypeTableAttribute); + } + } + + + public void visitRuntimeVisibleAnnotationsAttribute(Clazz clazz, RuntimeVisibleAnnotationsAttribute runtimeVisibleAnnotationsAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitRuntimeVisibleAnnotationsAttribute(clazz, runtimeVisibleAnnotationsAttribute); + } + } + + + public void visitRuntimeInvisibleAnnotationsAttribute(Clazz clazz, RuntimeInvisibleAnnotationsAttribute runtimeInvisibleAnnotationsAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitRuntimeInvisibleAnnotationsAttribute(clazz, runtimeInvisibleAnnotationsAttribute); + } + } + + + public void visitRuntimeVisibleAnnotationsAttribute(Clazz clazz, Field field, RuntimeVisibleAnnotationsAttribute runtimeVisibleAnnotationsAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitRuntimeVisibleAnnotationsAttribute(clazz, field, runtimeVisibleAnnotationsAttribute); + } + } + + + public void visitRuntimeInvisibleAnnotationsAttribute(Clazz clazz, Field field, RuntimeInvisibleAnnotationsAttribute runtimeInvisibleAnnotationsAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitRuntimeInvisibleAnnotationsAttribute(clazz, field, runtimeInvisibleAnnotationsAttribute); + } + } + + + public void visitRuntimeVisibleAnnotationsAttribute(Clazz clazz, Method method, RuntimeVisibleAnnotationsAttribute runtimeVisibleAnnotationsAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitRuntimeVisibleAnnotationsAttribute(clazz, method, runtimeVisibleAnnotationsAttribute); + } + } + + + public void visitRuntimeInvisibleAnnotationsAttribute(Clazz clazz, Method method, RuntimeInvisibleAnnotationsAttribute runtimeInvisibleAnnotationsAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitRuntimeInvisibleAnnotationsAttribute(clazz, method, runtimeInvisibleAnnotationsAttribute); + } + } + + + public void visitRuntimeVisibleParameterAnnotationsAttribute(Clazz clazz, Method method, RuntimeVisibleParameterAnnotationsAttribute runtimeVisibleParameterAnnotationsAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitRuntimeVisibleParameterAnnotationsAttribute(clazz, method, runtimeVisibleParameterAnnotationsAttribute); + } + } + + + public void visitRuntimeInvisibleParameterAnnotationsAttribute(Clazz clazz, Method method, RuntimeInvisibleParameterAnnotationsAttribute runtimeInvisibleParameterAnnotationsAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitRuntimeInvisibleParameterAnnotationsAttribute(clazz, method, runtimeInvisibleParameterAnnotationsAttribute); + } + } + + + public void visitRuntimeVisibleTypeAnnotationsAttribute(Clazz clazz, RuntimeVisibleTypeAnnotationsAttribute runtimeVisibleTypeAnnotationsAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitRuntimeVisibleTypeAnnotationsAttribute(clazz, runtimeVisibleTypeAnnotationsAttribute); + } + } + + + public void visitRuntimeVisibleTypeAnnotationsAttribute(Clazz clazz, Field field, RuntimeVisibleTypeAnnotationsAttribute runtimeVisibleTypeAnnotationsAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitRuntimeVisibleTypeAnnotationsAttribute(clazz, field, runtimeVisibleTypeAnnotationsAttribute); + } + } + + + public void visitRuntimeVisibleTypeAnnotationsAttribute(Clazz clazz, Method method, RuntimeVisibleTypeAnnotationsAttribute runtimeVisibleTypeAnnotationsAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitRuntimeVisibleTypeAnnotationsAttribute(clazz, method, runtimeVisibleTypeAnnotationsAttribute); + } + } + + + public void visitRuntimeVisibleTypeAnnotationsAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, RuntimeVisibleTypeAnnotationsAttribute runtimeVisibleTypeAnnotationsAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitRuntimeVisibleTypeAnnotationsAttribute(clazz, method, codeAttribute, runtimeVisibleTypeAnnotationsAttribute); + } + } + + + public void visitRuntimeInvisibleTypeAnnotationsAttribute(Clazz clazz, RuntimeInvisibleTypeAnnotationsAttribute runtimeInvisibleTypeAnnotationsAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitRuntimeInvisibleTypeAnnotationsAttribute(clazz, runtimeInvisibleTypeAnnotationsAttribute); + } + } + + + public void visitRuntimeInvisibleTypeAnnotationsAttribute(Clazz clazz, Field field, RuntimeInvisibleTypeAnnotationsAttribute runtimeInvisibleTypeAnnotationsAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitRuntimeInvisibleTypeAnnotationsAttribute(clazz, field, runtimeInvisibleTypeAnnotationsAttribute); + } + } + + + public void visitRuntimeInvisibleTypeAnnotationsAttribute(Clazz clazz, Method method, RuntimeInvisibleTypeAnnotationsAttribute runtimeInvisibleTypeAnnotationsAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitRuntimeInvisibleTypeAnnotationsAttribute(clazz, method, runtimeInvisibleTypeAnnotationsAttribute); + } + } + + + public void visitRuntimeInvisibleTypeAnnotationsAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, RuntimeInvisibleTypeAnnotationsAttribute runtimeInvisibleTypeAnnotationsAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitRuntimeInvisibleTypeAnnotationsAttribute(clazz, method, codeAttribute, runtimeInvisibleTypeAnnotationsAttribute); + } + } + + + public void visitAnnotationDefaultAttribute(Clazz clazz, Method method, AnnotationDefaultAttribute annotationDefaultAttribute) + { + for (int index = 0; index < attributeVisitors.length; index++) + { + attributeVisitors[index].visitAnnotationDefaultAttribute(clazz, method, annotationDefaultAttribute); + } + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/NonEmptyAttributeFilter.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/NonEmptyAttributeFilter.java new file mode 100644 index 0000000000..52bbae16d7 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/NonEmptyAttributeFilter.java @@ -0,0 +1,373 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.visitor; + +import proguard.classfile.*; +import proguard.classfile.attribute.*; +import proguard.classfile.attribute.annotation.*; +import proguard.classfile.attribute.preverification.*; + +/** + * This AttributeVisitor delegates its visits another AttributeVisitor, but + * only when the visited attribute is not empty. For instance, a local variable + * table without variables is empty. + * + * @author Eric Lafortune + */ +public class NonEmptyAttributeFilter +implements AttributeVisitor +{ + private final AttributeVisitor attributeVisitor; + + + /** + * Creates a new NonEmptyAttributeFilter. + * @param attributeVisitor the <code>AttributeVisitor</code> to which + * visits will be delegated. + */ + public NonEmptyAttributeFilter(AttributeVisitor attributeVisitor) + { + this.attributeVisitor = attributeVisitor; + } + + + // Implementations for AttributeVisitor. + + public void visitUnknownAttribute(Clazz clazz, UnknownAttribute unknownAttribute) + { + attributeVisitor.visitUnknownAttribute(clazz, unknownAttribute); + } + + + public void visitBootstrapMethodsAttribute(Clazz clazz, BootstrapMethodsAttribute bootstrapMethodsAttribute) + { + if (bootstrapMethodsAttribute.u2bootstrapMethodsCount > 0) + { + attributeVisitor.visitBootstrapMethodsAttribute(clazz, bootstrapMethodsAttribute); + } + } + + + public void visitSourceFileAttribute(Clazz clazz, SourceFileAttribute sourceFileAttribute) + { + attributeVisitor.visitSourceFileAttribute(clazz, sourceFileAttribute); + } + + + public void visitSourceDirAttribute(Clazz clazz, SourceDirAttribute sourceDirAttribute) + { + attributeVisitor.visitSourceDirAttribute(clazz, sourceDirAttribute); + } + + + public void visitInnerClassesAttribute(Clazz clazz, InnerClassesAttribute innerClassesAttribute) + { + if (innerClassesAttribute.u2classesCount > 0) + { + attributeVisitor.visitInnerClassesAttribute(clazz, innerClassesAttribute); + } + } + + + public void visitEnclosingMethodAttribute(Clazz clazz, EnclosingMethodAttribute enclosingMethodAttribute) + { + attributeVisitor.visitEnclosingMethodAttribute(clazz, enclosingMethodAttribute); + } + + + public void visitDeprecatedAttribute(Clazz clazz, DeprecatedAttribute deprecatedAttribute) + { + attributeVisitor.visitDeprecatedAttribute(clazz, deprecatedAttribute); + } + + + public void visitDeprecatedAttribute(Clazz clazz, Field field, DeprecatedAttribute deprecatedAttribute) + { + attributeVisitor.visitDeprecatedAttribute(clazz, field, deprecatedAttribute); + } + + + public void visitDeprecatedAttribute(Clazz clazz, Method method, DeprecatedAttribute deprecatedAttribute) + { + attributeVisitor.visitDeprecatedAttribute(clazz, method, deprecatedAttribute); + } + + + public void visitSyntheticAttribute(Clazz clazz, SyntheticAttribute syntheticAttribute) + { + attributeVisitor.visitSyntheticAttribute(clazz, syntheticAttribute); + } + + + public void visitSyntheticAttribute(Clazz clazz, Field field, SyntheticAttribute syntheticAttribute) + { + attributeVisitor.visitSyntheticAttribute(clazz, field, syntheticAttribute); + } + + + public void visitSyntheticAttribute(Clazz clazz, Method method, SyntheticAttribute syntheticAttribute) + { + attributeVisitor.visitSyntheticAttribute(clazz, method, syntheticAttribute); + } + + + public void visitSignatureAttribute(Clazz clazz, SignatureAttribute signatureAttribute) + { + attributeVisitor.visitSignatureAttribute(clazz, signatureAttribute); + } + + + public void visitSignatureAttribute(Clazz clazz, Field field, SignatureAttribute signatureAttribute) + { + attributeVisitor.visitSignatureAttribute(clazz, field, signatureAttribute); + } + + + public void visitSignatureAttribute(Clazz clazz, Method method, SignatureAttribute signatureAttribute) + { + attributeVisitor.visitSignatureAttribute(clazz, method, signatureAttribute); + } + + + public void visitConstantValueAttribute(Clazz clazz, Field field, ConstantValueAttribute constantValueAttribute) + { + attributeVisitor.visitConstantValueAttribute(clazz, field, constantValueAttribute); + } + + + public void visitMethodParametersAttribute(Clazz clazz, Method method, MethodParametersAttribute exceptionsAttribute) + { + if (exceptionsAttribute.u1parametersCount > 0) + { + attributeVisitor.visitMethodParametersAttribute(clazz, method, exceptionsAttribute); + } + } + + + public void visitExceptionsAttribute(Clazz clazz, Method method, ExceptionsAttribute exceptionsAttribute) + { + if (exceptionsAttribute.u2exceptionIndexTableLength > 0) + { + attributeVisitor.visitExceptionsAttribute(clazz, method, exceptionsAttribute); + } + } + + + public void visitCodeAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute) + { + attributeVisitor.visitCodeAttribute(clazz, method, codeAttribute); + } + + + public void visitStackMapAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, StackMapAttribute stackMapAttribute) + { + if (stackMapAttribute.u2stackMapFramesCount > 0) + { + attributeVisitor.visitStackMapAttribute(clazz, method, codeAttribute, stackMapAttribute); + } + } + + + public void visitStackMapTableAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, StackMapTableAttribute stackMapTableAttribute) + { + if (stackMapTableAttribute.u2stackMapFramesCount > 0) + { + attributeVisitor.visitStackMapTableAttribute(clazz, method, codeAttribute, stackMapTableAttribute); + } + } + + + public void visitLineNumberTableAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, LineNumberTableAttribute lineNumberTableAttribute) + { + if (lineNumberTableAttribute.u2lineNumberTableLength > 0) + { + attributeVisitor.visitLineNumberTableAttribute(clazz, method, codeAttribute, lineNumberTableAttribute); + } + } + + + public void visitLocalVariableTableAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, LocalVariableTableAttribute localVariableTableAttribute) + { + if (localVariableTableAttribute.u2localVariableTableLength > 0) + { + attributeVisitor.visitLocalVariableTableAttribute(clazz, method, codeAttribute, localVariableTableAttribute); + } + } + + + public void visitLocalVariableTypeTableAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, LocalVariableTypeTableAttribute localVariableTypeTableAttribute) + { + if (localVariableTypeTableAttribute.u2localVariableTypeTableLength > 0) + { + attributeVisitor.visitLocalVariableTypeTableAttribute(clazz, method, codeAttribute, localVariableTypeTableAttribute); + } + } + + + public void visitRuntimeVisibleAnnotationsAttribute(Clazz clazz, RuntimeVisibleAnnotationsAttribute runtimeVisibleAnnotationsAttribute) + { + if (runtimeVisibleAnnotationsAttribute.u2annotationsCount > 0) + { + attributeVisitor.visitRuntimeVisibleAnnotationsAttribute(clazz, runtimeVisibleAnnotationsAttribute); + } + } + + + public void visitRuntimeVisibleAnnotationsAttribute(Clazz clazz, Field field, RuntimeVisibleAnnotationsAttribute runtimeVisibleAnnotationsAttribute) + { + if (runtimeVisibleAnnotationsAttribute.u2annotationsCount > 0) + { + attributeVisitor.visitRuntimeVisibleAnnotationsAttribute(clazz, field, runtimeVisibleAnnotationsAttribute); + } + } + + + public void visitRuntimeVisibleAnnotationsAttribute(Clazz clazz, Method method, RuntimeVisibleAnnotationsAttribute runtimeVisibleAnnotationsAttribute) + { + if (runtimeVisibleAnnotationsAttribute.u2annotationsCount > 0) + { + attributeVisitor.visitRuntimeVisibleAnnotationsAttribute(clazz, method, runtimeVisibleAnnotationsAttribute); + } + } + + + public void visitRuntimeInvisibleAnnotationsAttribute(Clazz clazz, RuntimeInvisibleAnnotationsAttribute runtimeInvisibleAnnotationsAttribute) + { + if (runtimeInvisibleAnnotationsAttribute.u2annotationsCount > 0) + { + attributeVisitor.visitRuntimeInvisibleAnnotationsAttribute(clazz, runtimeInvisibleAnnotationsAttribute); + } + } + + + public void visitRuntimeInvisibleAnnotationsAttribute(Clazz clazz, Field field, RuntimeInvisibleAnnotationsAttribute runtimeInvisibleAnnotationsAttribute) + { + if (runtimeInvisibleAnnotationsAttribute.u2annotationsCount > 0) + { + attributeVisitor.visitRuntimeInvisibleAnnotationsAttribute(clazz, field, runtimeInvisibleAnnotationsAttribute); + } + } + + + public void visitRuntimeInvisibleAnnotationsAttribute(Clazz clazz, Method method, RuntimeInvisibleAnnotationsAttribute runtimeInvisibleAnnotationsAttribute) + { + if (runtimeInvisibleAnnotationsAttribute.u2annotationsCount > 0) + { + attributeVisitor.visitRuntimeInvisibleAnnotationsAttribute(clazz, method, runtimeInvisibleAnnotationsAttribute); + } + } + + + public void visitRuntimeVisibleParameterAnnotationsAttribute(Clazz clazz, Method method, RuntimeVisibleParameterAnnotationsAttribute runtimeVisibleParameterAnnotationsAttribute) + { + if (runtimeVisibleParameterAnnotationsAttribute.u1parametersCount > 0) + { + attributeVisitor.visitRuntimeVisibleParameterAnnotationsAttribute(clazz, method, runtimeVisibleParameterAnnotationsAttribute); + } + } + + + public void visitRuntimeInvisibleParameterAnnotationsAttribute(Clazz clazz, Method method, RuntimeInvisibleParameterAnnotationsAttribute runtimeInvisibleParameterAnnotationsAttribute) + { + if (runtimeInvisibleParameterAnnotationsAttribute.u1parametersCount > 0) + { + attributeVisitor.visitRuntimeInvisibleParameterAnnotationsAttribute(clazz, method, runtimeInvisibleParameterAnnotationsAttribute); + } + } + + + public void visitRuntimeVisibleTypeAnnotationsAttribute(Clazz clazz, RuntimeVisibleTypeAnnotationsAttribute runtimeVisibleTypeAnnotationsAttribute) + { + if (runtimeVisibleTypeAnnotationsAttribute.u2annotationsCount > 0) + { + attributeVisitor.visitRuntimeVisibleTypeAnnotationsAttribute(clazz, runtimeVisibleTypeAnnotationsAttribute); + } + } + + + public void visitRuntimeVisibleTypeAnnotationsAttribute(Clazz clazz, Field field, RuntimeVisibleTypeAnnotationsAttribute runtimeVisibleTypeAnnotationsAttribute) + { + if (runtimeVisibleTypeAnnotationsAttribute.u2annotationsCount > 0) + { + attributeVisitor.visitRuntimeVisibleTypeAnnotationsAttribute(clazz, field, runtimeVisibleTypeAnnotationsAttribute); + } + } + + + public void visitRuntimeVisibleTypeAnnotationsAttribute(Clazz clazz, Method method, RuntimeVisibleTypeAnnotationsAttribute runtimeVisibleTypeAnnotationsAttribute) + { + if (runtimeVisibleTypeAnnotationsAttribute.u2annotationsCount > 0) + { + attributeVisitor.visitRuntimeVisibleTypeAnnotationsAttribute(clazz, method, runtimeVisibleTypeAnnotationsAttribute); + } + } + + + public void visitRuntimeVisibleTypeAnnotationsAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, RuntimeVisibleTypeAnnotationsAttribute runtimeVisibleTypeAnnotationsAttribute) + { + if (runtimeVisibleTypeAnnotationsAttribute.u2annotationsCount > 0) + { + attributeVisitor.visitRuntimeVisibleTypeAnnotationsAttribute(clazz, method, codeAttribute, runtimeVisibleTypeAnnotationsAttribute); + } + } + + + public void visitRuntimeInvisibleTypeAnnotationsAttribute(Clazz clazz, RuntimeInvisibleTypeAnnotationsAttribute runtimeInvisibleTypeAnnotationsAttribute) + { + if (runtimeInvisibleTypeAnnotationsAttribute.u2annotationsCount > 0) + { + attributeVisitor.visitRuntimeInvisibleTypeAnnotationsAttribute(clazz, runtimeInvisibleTypeAnnotationsAttribute); + } + } + + + public void visitRuntimeInvisibleTypeAnnotationsAttribute(Clazz clazz, Field field, RuntimeInvisibleTypeAnnotationsAttribute runtimeInvisibleTypeAnnotationsAttribute) + { + if (runtimeInvisibleTypeAnnotationsAttribute.u2annotationsCount > 0) + { + attributeVisitor.visitRuntimeInvisibleTypeAnnotationsAttribute(clazz, field, runtimeInvisibleTypeAnnotationsAttribute); + } + } + + + public void visitRuntimeInvisibleTypeAnnotationsAttribute(Clazz clazz, Method method, RuntimeInvisibleTypeAnnotationsAttribute runtimeInvisibleTypeAnnotationsAttribute) + { + if (runtimeInvisibleTypeAnnotationsAttribute.u2annotationsCount > 0) + { + attributeVisitor.visitRuntimeInvisibleTypeAnnotationsAttribute(clazz, method, runtimeInvisibleTypeAnnotationsAttribute); + } + } + + + public void visitRuntimeInvisibleTypeAnnotationsAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, RuntimeInvisibleTypeAnnotationsAttribute runtimeInvisibleTypeAnnotationsAttribute) + { + if (runtimeInvisibleTypeAnnotationsAttribute.u2annotationsCount > 0) + { + attributeVisitor.visitRuntimeInvisibleTypeAnnotationsAttribute(clazz, method, codeAttribute, runtimeInvisibleTypeAnnotationsAttribute); + } + } + + + public void visitAnnotationDefaultAttribute(Clazz clazz, Method method, AnnotationDefaultAttribute annotationDefaultAttribute) + { + attributeVisitor.visitAnnotationDefaultAttribute(clazz, method, annotationDefaultAttribute); + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/ParameterInfoVisitor.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/ParameterInfoVisitor.java new file mode 100644 index 0000000000..59a743027d --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/ParameterInfoVisitor.java @@ -0,0 +1,37 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.visitor; + +import proguard.classfile.*; +import proguard.classfile.attribute.ParameterInfo; + +/** + * This interface specifies the method for a visitor of + * <code>ParameterInfo</code> objects. Note that there is only a single + * implementation of <code>ParameterInfo</code>, such that this interface + * is not strictly necessary as a visitor. + * + * @author Eric Lafortune + */ +public interface ParameterInfoVisitor +{ + public void visitParameterInfo(Clazz clazz, Method method, int parameterIndex, ParameterInfo parameterInfo); +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/RequiredAttributeFilter.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/RequiredAttributeFilter.java new file mode 100644 index 0000000000..32f29bfdd7 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/RequiredAttributeFilter.java @@ -0,0 +1,443 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.visitor; + +import proguard.classfile.*; +import proguard.classfile.attribute.*; +import proguard.classfile.attribute.annotation.*; +import proguard.classfile.attribute.preverification.*; +import proguard.obfuscate.AttributeShrinker; + +/** + * This AttributeVisitor delegates its visits to one of two other + * AttributeVisitor instances, depending on whether the visited attribute + * is strictly required or not. + * + * Stack map attributes and stack map table attributes are treated as optional. + * + * @see AttributeShrinker + * + * @author Eric Lafortune + */ +public class RequiredAttributeFilter +implements AttributeVisitor +{ + private final AttributeVisitor requiredAttributeVisitor; + private final AttributeVisitor optionalAttributeVisitor; + + + /** + * Creates a new RequiredAttributeFilter for visiting required attributes. + * @param requiredAttributeVisitor the visitor that will visit required + * attributes. + */ + public RequiredAttributeFilter(AttributeVisitor requiredAttributeVisitor) + { + this(requiredAttributeVisitor, null); + } + + + /** + * Creates a new RequiredAttributeFilter for visiting required and + * optional attributes. + * @param requiredAttributeVisitor the visitor that will visit required + * attributes. + * @param optionalAttributeVisitor the visitor that will visit optional + * attributes. + */ + public RequiredAttributeFilter(AttributeVisitor requiredAttributeVisitor, + AttributeVisitor optionalAttributeVisitor) + { + this.requiredAttributeVisitor = requiredAttributeVisitor; + this.optionalAttributeVisitor = optionalAttributeVisitor; + } + + + // Implementations for AttributeVisitor. + + public void visitUnknownAttribute(Clazz clazz, UnknownAttribute unknownAttribute) + { + if (optionalAttributeVisitor != null) + { + optionalAttributeVisitor.visitUnknownAttribute(clazz, unknownAttribute); + } + } + + + public void visitBootstrapMethodsAttribute(Clazz clazz, BootstrapMethodsAttribute bootstrapMethodsAttribute) + { + if (requiredAttributeVisitor != null) + { + requiredAttributeVisitor.visitBootstrapMethodsAttribute(clazz, bootstrapMethodsAttribute); + } + } + + + public void visitSourceFileAttribute(Clazz clazz, SourceFileAttribute sourceFileAttribute) + { + if (optionalAttributeVisitor != null) + { + optionalAttributeVisitor.visitSourceFileAttribute(clazz, sourceFileAttribute); + } + } + + + public void visitSourceDirAttribute(Clazz clazz, SourceDirAttribute sourceDirAttribute) + { + if (optionalAttributeVisitor != null) + { + optionalAttributeVisitor.visitSourceDirAttribute(clazz, sourceDirAttribute); + } + } + + + public void visitInnerClassesAttribute(Clazz clazz, InnerClassesAttribute innerClassesAttribute) + { + if (optionalAttributeVisitor != null) + { + optionalAttributeVisitor.visitInnerClassesAttribute(clazz, innerClassesAttribute); + } + } + + + public void visitEnclosingMethodAttribute(Clazz clazz, EnclosingMethodAttribute enclosingMethodAttribute) + { + if (optionalAttributeVisitor != null) + { + optionalAttributeVisitor.visitEnclosingMethodAttribute(clazz, enclosingMethodAttribute); + } + } + + + public void visitDeprecatedAttribute(Clazz clazz, DeprecatedAttribute deprecatedAttribute) + { + if (optionalAttributeVisitor != null) + { + optionalAttributeVisitor.visitDeprecatedAttribute(clazz, deprecatedAttribute); + } + } + + + public void visitDeprecatedAttribute(Clazz clazz, Field field, DeprecatedAttribute deprecatedAttribute) + { + if (optionalAttributeVisitor != null) + { + optionalAttributeVisitor.visitDeprecatedAttribute(clazz, field, deprecatedAttribute); + } + } + + + public void visitDeprecatedAttribute(Clazz clazz, Method method, DeprecatedAttribute deprecatedAttribute) + { + if (optionalAttributeVisitor != null) + { + optionalAttributeVisitor.visitDeprecatedAttribute(clazz, method, deprecatedAttribute); + } + } + + + public void visitSyntheticAttribute(Clazz clazz, SyntheticAttribute syntheticAttribute) + { + if (optionalAttributeVisitor != null) + { + optionalAttributeVisitor.visitSyntheticAttribute(clazz, syntheticAttribute); + } + } + + + public void visitSyntheticAttribute(Clazz clazz, Field field, SyntheticAttribute syntheticAttribute) + { + if (optionalAttributeVisitor != null) + { + optionalAttributeVisitor.visitSyntheticAttribute(clazz, field, syntheticAttribute); + } + } + + + public void visitSyntheticAttribute(Clazz clazz, Method method, SyntheticAttribute syntheticAttribute) + { + if (optionalAttributeVisitor != null) + { + optionalAttributeVisitor.visitSyntheticAttribute(clazz, method, syntheticAttribute); + } + } + + + public void visitSignatureAttribute(Clazz clazz, SignatureAttribute signatureAttribute) + { + if (optionalAttributeVisitor != null) + { + optionalAttributeVisitor.visitSignatureAttribute(clazz, signatureAttribute); + } + } + + + public void visitSignatureAttribute(Clazz clazz, Field field, SignatureAttribute signatureAttribute) + { + if (optionalAttributeVisitor != null) + { + optionalAttributeVisitor.visitSignatureAttribute(clazz, field, signatureAttribute); + } + } + + + public void visitSignatureAttribute(Clazz clazz, Method method, SignatureAttribute signatureAttribute) + { + if (optionalAttributeVisitor != null) + { + optionalAttributeVisitor.visitSignatureAttribute(clazz, method, signatureAttribute); + } + } + + + public void visitConstantValueAttribute(Clazz clazz, Field field, ConstantValueAttribute constantValueAttribute) + { + if (requiredAttributeVisitor != null) + { + requiredAttributeVisitor.visitConstantValueAttribute(clazz, field, constantValueAttribute); + } + } + + + public void visitMethodParametersAttribute(Clazz clazz, Method method, MethodParametersAttribute exceptionsAttribute) + { + if (optionalAttributeVisitor != null) + { + optionalAttributeVisitor.visitMethodParametersAttribute(clazz, method, exceptionsAttribute); + } + } + + + public void visitExceptionsAttribute(Clazz clazz, Method method, ExceptionsAttribute exceptionsAttribute) + { + if (optionalAttributeVisitor != null) + { + optionalAttributeVisitor.visitExceptionsAttribute(clazz, method, exceptionsAttribute); + } + } + + + public void visitCodeAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute) + { + if (requiredAttributeVisitor != null) + { + requiredAttributeVisitor.visitCodeAttribute(clazz, method, codeAttribute); + } + } + + + public void visitStackMapAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, StackMapAttribute stackMapAttribute) + { + if (optionalAttributeVisitor != null) + { + optionalAttributeVisitor.visitStackMapAttribute(clazz, method, codeAttribute, stackMapAttribute); + } + } + + + public void visitStackMapTableAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, StackMapTableAttribute stackMapTableAttribute) + { + if (optionalAttributeVisitor != null) + { + optionalAttributeVisitor.visitStackMapTableAttribute(clazz, method, codeAttribute, stackMapTableAttribute); + } + } + + + public void visitLineNumberTableAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, LineNumberTableAttribute lineNumberTableAttribute) + { + if (optionalAttributeVisitor != null) + { + optionalAttributeVisitor.visitLineNumberTableAttribute(clazz, method, codeAttribute, lineNumberTableAttribute); + } + } + + + public void visitLocalVariableTableAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, LocalVariableTableAttribute localVariableTableAttribute) + { + if (optionalAttributeVisitor != null) + { + optionalAttributeVisitor.visitLocalVariableTableAttribute(clazz, method, codeAttribute, localVariableTableAttribute); + } + } + + + public void visitLocalVariableTypeTableAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, LocalVariableTypeTableAttribute localVariableTypeTableAttribute) + { + if (optionalAttributeVisitor != null) + { + optionalAttributeVisitor.visitLocalVariableTypeTableAttribute(clazz, method, codeAttribute, localVariableTypeTableAttribute); + } + } + + + public void visitRuntimeVisibleAnnotationsAttribute(Clazz clazz, RuntimeVisibleAnnotationsAttribute runtimeVisibleAnnotationsAttribute) + { + if (optionalAttributeVisitor != null) + { + optionalAttributeVisitor.visitRuntimeVisibleAnnotationsAttribute(clazz, runtimeVisibleAnnotationsAttribute); + } + } + + + public void visitRuntimeVisibleAnnotationsAttribute(Clazz clazz, Field field, RuntimeVisibleAnnotationsAttribute runtimeVisibleAnnotationsAttribute) + { + if (optionalAttributeVisitor != null) + { + optionalAttributeVisitor.visitRuntimeVisibleAnnotationsAttribute(clazz, field, runtimeVisibleAnnotationsAttribute); + } + } + + + public void visitRuntimeVisibleAnnotationsAttribute(Clazz clazz, Method method, RuntimeVisibleAnnotationsAttribute runtimeVisibleAnnotationsAttribute) + { + if (optionalAttributeVisitor != null) + { + optionalAttributeVisitor.visitRuntimeVisibleAnnotationsAttribute(clazz, method, runtimeVisibleAnnotationsAttribute); + } + } + + + public void visitRuntimeInvisibleAnnotationsAttribute(Clazz clazz, RuntimeInvisibleAnnotationsAttribute runtimeInvisibleAnnotationsAttribute) + { + if (optionalAttributeVisitor != null) + { + optionalAttributeVisitor.visitRuntimeInvisibleAnnotationsAttribute(clazz, runtimeInvisibleAnnotationsAttribute); + } + } + + + public void visitRuntimeInvisibleAnnotationsAttribute(Clazz clazz, Field field, RuntimeInvisibleAnnotationsAttribute runtimeInvisibleAnnotationsAttribute) + { + if (optionalAttributeVisitor != null) + { + optionalAttributeVisitor.visitRuntimeInvisibleAnnotationsAttribute(clazz, field, runtimeInvisibleAnnotationsAttribute); + } + } + + + public void visitRuntimeInvisibleAnnotationsAttribute(Clazz clazz, Method method, RuntimeInvisibleAnnotationsAttribute runtimeInvisibleAnnotationsAttribute) + { + if (optionalAttributeVisitor != null) + { + optionalAttributeVisitor.visitRuntimeInvisibleAnnotationsAttribute(clazz, method, runtimeInvisibleAnnotationsAttribute); + } + } + + + public void visitRuntimeVisibleParameterAnnotationsAttribute(Clazz clazz, Method method, RuntimeVisibleParameterAnnotationsAttribute runtimeVisibleParameterAnnotationsAttribute) + { + if (optionalAttributeVisitor != null) + { + optionalAttributeVisitor.visitRuntimeVisibleParameterAnnotationsAttribute(clazz, method, runtimeVisibleParameterAnnotationsAttribute); + } + } + + + public void visitRuntimeInvisibleParameterAnnotationsAttribute(Clazz clazz, Method method, RuntimeInvisibleParameterAnnotationsAttribute runtimeInvisibleParameterAnnotationsAttribute) + { + if (optionalAttributeVisitor != null) + { + optionalAttributeVisitor.visitRuntimeInvisibleParameterAnnotationsAttribute(clazz, method, runtimeInvisibleParameterAnnotationsAttribute); + } + } + + + public void visitRuntimeVisibleTypeAnnotationsAttribute(Clazz clazz, RuntimeVisibleTypeAnnotationsAttribute runtimeVisibleTypeAnnotationsAttribute) + { + if (optionalAttributeVisitor != null) + { + optionalAttributeVisitor.visitRuntimeVisibleTypeAnnotationsAttribute(clazz, runtimeVisibleTypeAnnotationsAttribute); + } + } + + + public void visitRuntimeVisibleTypeAnnotationsAttribute(Clazz clazz, Field field, RuntimeVisibleTypeAnnotationsAttribute runtimeVisibleTypeAnnotationsAttribute) + { + if (optionalAttributeVisitor != null) + { + optionalAttributeVisitor.visitRuntimeVisibleTypeAnnotationsAttribute(clazz, field, runtimeVisibleTypeAnnotationsAttribute); + } + } + + + public void visitRuntimeVisibleTypeAnnotationsAttribute(Clazz clazz, Method method, RuntimeVisibleTypeAnnotationsAttribute runtimeVisibleTypeAnnotationsAttribute) + { + if (optionalAttributeVisitor != null) + { + optionalAttributeVisitor.visitRuntimeVisibleTypeAnnotationsAttribute(clazz, method, runtimeVisibleTypeAnnotationsAttribute); + } + } + + + public void visitRuntimeVisibleTypeAnnotationsAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, RuntimeVisibleTypeAnnotationsAttribute runtimeVisibleTypeAnnotationsAttribute) + { + if (optionalAttributeVisitor != null) + { + optionalAttributeVisitor.visitRuntimeVisibleTypeAnnotationsAttribute(clazz, method, codeAttribute, runtimeVisibleTypeAnnotationsAttribute); + } + } + + + public void visitRuntimeInvisibleTypeAnnotationsAttribute(Clazz clazz, RuntimeInvisibleTypeAnnotationsAttribute runtimeInvisibleTypeAnnotationsAttribute) + { + if (optionalAttributeVisitor != null) + { + optionalAttributeVisitor.visitRuntimeInvisibleTypeAnnotationsAttribute(clazz, runtimeInvisibleTypeAnnotationsAttribute); + } + } + + + public void visitRuntimeInvisibleTypeAnnotationsAttribute(Clazz clazz, Field field, RuntimeInvisibleTypeAnnotationsAttribute runtimeInvisibleTypeAnnotationsAttribute) + { + if (optionalAttributeVisitor != null) + { + optionalAttributeVisitor.visitRuntimeInvisibleTypeAnnotationsAttribute(clazz, field, runtimeInvisibleTypeAnnotationsAttribute); + } + } + + + public void visitRuntimeInvisibleTypeAnnotationsAttribute(Clazz clazz, Method method, RuntimeInvisibleTypeAnnotationsAttribute runtimeInvisibleTypeAnnotationsAttribute) + { + if (optionalAttributeVisitor != null) + { + optionalAttributeVisitor.visitRuntimeInvisibleTypeAnnotationsAttribute(clazz, method, runtimeInvisibleTypeAnnotationsAttribute); + } + } + + + public void visitRuntimeInvisibleTypeAnnotationsAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, RuntimeInvisibleTypeAnnotationsAttribute runtimeInvisibleTypeAnnotationsAttribute) + { + if (optionalAttributeVisitor != null) + { + optionalAttributeVisitor.visitRuntimeInvisibleTypeAnnotationsAttribute(clazz, method, codeAttribute, runtimeInvisibleTypeAnnotationsAttribute); + } + } + + + public void visitAnnotationDefaultAttribute(Clazz clazz, Method method, AnnotationDefaultAttribute annotationDefaultAttribute) + { + if (optionalAttributeVisitor != null) + { + optionalAttributeVisitor.visitAnnotationDefaultAttribute(clazz, method, annotationDefaultAttribute); + } + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/StackSizeComputer.java b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/StackSizeComputer.java new file mode 100644 index 0000000000..009666c695 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/StackSizeComputer.java @@ -0,0 +1,389 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2017 Eric Lafortune @ GuardSquare + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.visitor; + +import proguard.classfile.*; +import proguard.classfile.attribute.*; +import proguard.classfile.instruction.*; +import proguard.classfile.instruction.visitor.InstructionVisitor; +import proguard.classfile.util.SimplifiedVisitor; +import proguard.classfile.visitor.ClassPrinter; +import proguard.util.ArrayUtil; + +/** + * This AttributeVisitor computes the stack sizes at all instruction offsets + * of the code attributes that it visits. + * + * @author Eric Lafortune + */ +public class StackSizeComputer +extends SimplifiedVisitor +implements AttributeVisitor, + InstructionVisitor, + ExceptionInfoVisitor +{ + //* + private static final boolean DEBUG = false; + /*/ + private static boolean DEBUG = true; + //*/ + + + private boolean[] evaluated = new boolean[ClassConstants.TYPICAL_CODE_LENGTH]; + private int[] stackSizesBefore = new int[ClassConstants.TYPICAL_CODE_LENGTH]; + private int[] stackSizesAfter = new int[ClassConstants.TYPICAL_CODE_LENGTH]; + + private boolean exitInstructionBlock; + + private int stackSize; + private int maxStackSize; + + + /** + * Returns whether the instruction at the given offset is reachable in the + * most recently visited code attribute. + */ + public boolean isReachable(int instructionOffset) + { + return evaluated[instructionOffset]; + } + + + /** + * Returns the stack size before the given instruction offset of the most + * recently visited code attribute. + */ + public int getStackSizeBefore(int instructionOffset) + { + if (!evaluated[instructionOffset]) + { + throw new IllegalArgumentException("Unknown stack size before unreachable instruction offset ["+instructionOffset+"]"); + } + + return stackSizesBefore[instructionOffset]; + } + + + /** + * Returns the stack size after the given instruction offset of the most + * recently visited code attribute. + */ + public int getStackSizeAfter(int instructionOffset) + { + if (!evaluated[instructionOffset]) + { + throw new IllegalArgumentException("Unknown stack size after unreachable instruction offset ["+instructionOffset+"]"); + } + + return stackSizesAfter[instructionOffset]; + } + + + /** + * Returns the maximum stack size of the most recently visited code attribute. + */ + public int getMaxStackSize() + { + return maxStackSize; + } + + + // Implementations for AttributeVisitor. + + public void visitAnyAttribute(Clazz clazz, Attribute attribute) {} + + + public void visitCodeAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute) + { +// DEBUG = +// clazz.getName().equals("abc/Def") && +// method.getName(clazz).equals("abc"); + + // TODO: Remove this when the code has stabilized. + // Catch any unexpected exceptions from the actual visiting method. + try + { + // Process the code. + visitCodeAttribute0(clazz, method, codeAttribute); + } + catch (RuntimeException ex) + { + System.err.println("Unexpected error while computing stack sizes:"); + System.err.println(" Class = ["+clazz.getName()+"]"); + System.err.println(" Method = ["+method.getName(clazz)+method.getDescriptor(clazz)+"]"); + System.err.println(" Exception = ["+ex.getClass().getName()+"] ("+ex.getMessage()+")"); + + if (DEBUG) + { + method.accept(clazz, new ClassPrinter()); + } + + throw ex; + } + } + + + public void visitCodeAttribute0(Clazz clazz, Method method, CodeAttribute codeAttribute) + { + if (DEBUG) + { + System.out.println("StackSizeComputer: "+clazz.getName()+"."+method.getName(clazz)+method.getDescriptor(clazz)); + } + + int codeLength = codeAttribute.u4codeLength; + + // Make sure the global arrays are sufficiently large. + evaluated = ArrayUtil.ensureArraySize(evaluated, codeLength, false); + stackSizesBefore = ArrayUtil.ensureArraySize(stackSizesBefore, codeLength, 0); + stackSizesAfter = ArrayUtil.ensureArraySize(stackSizesAfter, codeLength, 0); + + // The initial stack is always empty. + stackSize = 0; + maxStackSize = 0; + + // Evaluate the instruction block starting at the entry point of the method. + evaluateInstructionBlock(clazz, method, codeAttribute, 0); + + // Evaluate the exception handlers. + codeAttribute.exceptionsAccept(clazz, method, this); + } + + + // Implementations for InstructionVisitor. + + public void visitSimpleInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, SimpleInstruction simpleInstruction) + { + byte opcode = simpleInstruction.opcode; + + // Some simple instructions exit from the current instruction block. + exitInstructionBlock = + opcode == InstructionConstants.OP_IRETURN || + opcode == InstructionConstants.OP_LRETURN || + opcode == InstructionConstants.OP_FRETURN || + opcode == InstructionConstants.OP_DRETURN || + opcode == InstructionConstants.OP_ARETURN || + opcode == InstructionConstants.OP_RETURN || + opcode == InstructionConstants.OP_ATHROW; + } + + public void visitConstantInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, ConstantInstruction constantInstruction) + { + // Constant pool instructions never end the current instruction block. + exitInstructionBlock = false; + } + + public void visitVariableInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, VariableInstruction variableInstruction) + { + byte opcode = variableInstruction.opcode; + + // The ret instruction end the current instruction block. + exitInstructionBlock = + opcode == InstructionConstants.OP_RET; + } + + public void visitBranchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, BranchInstruction branchInstruction) + { + byte opcode = branchInstruction.opcode; + + // Evaluate the target instruction blocks. + evaluateInstructionBlock(clazz, + method, + codeAttribute, + offset + + branchInstruction.branchOffset); + + // Evaluate the instructions after a subroutine branch. + if (opcode == InstructionConstants.OP_JSR || + opcode == InstructionConstants.OP_JSR_W) + { + // We assume subroutine calls (jsr and jsr_w instructions) don't + // change the stack, other than popping the return value. + stackSize -= 1; + + evaluateInstructionBlock(clazz, + method, + codeAttribute, + offset + branchInstruction.length(offset)); + } + + // Some branch instructions always end the current instruction block. + exitInstructionBlock = + opcode == InstructionConstants.OP_GOTO || + opcode == InstructionConstants.OP_GOTO_W || + opcode == InstructionConstants.OP_JSR || + opcode == InstructionConstants.OP_JSR_W; + } + + + public void visitAnySwitchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, SwitchInstruction switchInstruction) + { + // Evaluate the target instruction blocks. + + // Loop over all jump offsets. + int[] jumpOffsets = switchInstruction.jumpOffsets; + + for (int index = 0; index < jumpOffsets.length; index++) + { + // Evaluate the jump instruction block. + evaluateInstructionBlock(clazz, + method, + codeAttribute, + offset + jumpOffsets[index]); + } + + // Also evaluate the default instruction block. + evaluateInstructionBlock(clazz, + method, + codeAttribute, + offset + switchInstruction.defaultOffset); + + // The switch instruction always ends the current instruction block. + exitInstructionBlock = true; + } + + + // Implementations for ExceptionInfoVisitor. + + public void visitExceptionInfo(Clazz clazz, Method method, CodeAttribute codeAttribute, ExceptionInfo exceptionInfo) + { + if (DEBUG) + { + System.out.println("Exception:"); + } + + // The stack size when entering the exception handler is always 1. + stackSize = 1; + + // Evaluate the instruction block starting at the entry point of the + // exception handler. + evaluateInstructionBlock(clazz, + method, + codeAttribute, + exceptionInfo.u2handlerPC); + } + + + // Small utility methods. + + /** + * Evaluates a block of instructions that hasn't been handled before, + * starting at the given offset and ending at a branch instruction, a return + * instruction, or a throw instruction. Branch instructions are handled + * recursively. + */ + private void evaluateInstructionBlock(Clazz clazz, + Method method, + CodeAttribute codeAttribute, + int instructionOffset) + { + if (DEBUG) + { + if (evaluated[instructionOffset]) + { + System.out.println("-- (instruction block at "+instructionOffset+" already evaluated)"); + } + else + { + System.out.println("-- instruction block:"); + } + } + + // Remember the initial stack size. + int initialStackSize = stackSize; + + // Remember the maximum stack size. + if (maxStackSize < stackSize) + { + maxStackSize = stackSize; + } + + // Evaluate any instructions that haven't been evaluated before. + while (!evaluated[instructionOffset]) + { + // Mark the instruction as evaluated. + evaluated[instructionOffset] = true; + stackSizesBefore[instructionOffset] = stackSize; + + Instruction instruction = InstructionFactory.create(codeAttribute.code, + instructionOffset); + + if (DEBUG) + { + int stackPushCount = instruction.stackPushCount(clazz); + int stackPopCount = instruction.stackPopCount(clazz); + System.out.println("["+instructionOffset+"]: "+ + stackSize+" - "+ + stackPopCount+" + "+ + stackPushCount+" = "+ + (stackSize+stackPushCount-stackPopCount)+": "+ + instruction.toString(instructionOffset)); + } + + // Compute the instruction's effect on the stack size. + stackSize -= instruction.stackPopCount(clazz); + + if (stackSize < 0) + { + throw new IllegalArgumentException("Stack size becomes negative after instruction "+ + instruction.toString(instructionOffset)+" in ["+ + clazz.getName()+"."+ + method.getName(clazz)+ + method.getDescriptor(clazz)+"]"); + } + + stackSize += instruction.stackPushCount(clazz); + stackSizesAfter[instructionOffset] = stackSize; + + // Remember the maximum stack size. + if (maxStackSize < stackSize) + { + maxStackSize = stackSize; + } + + // Remember the next instruction offset. + int nextInstructionOffset = instructionOffset + + instruction.length(instructionOffset); + + // Visit the instruction, in order to handle branches. + instruction.accept(clazz, method, codeAttribute, instructionOffset, this); + + // Stop evaluating after a branch. + if (exitInstructionBlock) + { + break; + } + + // Continue with the next instruction. + instructionOffset = nextInstructionOffset; + + if (DEBUG) + { + if (evaluated[instructionOffset]) + { + System.out.println("-- (instruction at "+instructionOffset+" already evaluated)"); + } + } + } + + // Restore the stack size for possible subsequent instruction blocks. + this.stackSize = initialStackSize; + } +} diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/package.html b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/package.html new file mode 100644 index 0000000000..056244af62 --- /dev/null +++ b/third_party/java/proguard/proguard5.3.3/src/proguard/classfile/attribute/visitor/package.html @@ -0,0 +1,3 @@ +<body> +This package contains visitors for attributes and their components. +</body> |