aboutsummaryrefslogtreecommitdiffhomepage
path: root/third_party/java/proguard/proguard5.3.3/src/proguard/optimize/info/SimpleEnumFilter.java
diff options
context:
space:
mode:
authorGravatar Adam Michael <ajmichael@google.com>2017-09-21 15:00:07 -0400
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2017-10-05 00:18:35 +0200
commitb4ebfd724d33223ac78190be88c6f8704c249651 (patch)
tree7dcf4db51a9d5fad13ad17c69074b64e02228418 /third_party/java/proguard/proguard5.3.3/src/proguard/optimize/info/SimpleEnumFilter.java
parent74776b409214846aa3fe3a41a3447c6412dc046c (diff)
Add proguard 5.3.3 to third_party.
See https://github.com/bazelbuild/bazel/issues/3777 The Android SDK provides a very old proguard and will be removing it soon, so we need to bundle our own. Change-Id: I054c54130bef1befc8591598768184fe23f76161 RELNOTES: None
Diffstat (limited to 'third_party/java/proguard/proguard5.3.3/src/proguard/optimize/info/SimpleEnumFilter.java')
-rw-r--r--third_party/java/proguard/proguard5.3.3/src/proguard/optimize/info/SimpleEnumFilter.java96
1 files changed, 96 insertions, 0 deletions
diff --git a/third_party/java/proguard/proguard5.3.3/src/proguard/optimize/info/SimpleEnumFilter.java b/third_party/java/proguard/proguard5.3.3/src/proguard/optimize/info/SimpleEnumFilter.java
new file mode 100644
index 0000000000..9d05a9f2e7
--- /dev/null
+++ b/third_party/java/proguard/proguard5.3.3/src/proguard/optimize/info/SimpleEnumFilter.java
@@ -0,0 +1,96 @@
+/*
+ * 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.optimize.info;
+
+import proguard.classfile.*;
+import proguard.classfile.visitor.ClassVisitor;
+
+/**
+ * This ClassVisitor delegates its visits to one of two other given
+ * ClassVisitor instances, depending on whether the classes are marked
+ * as simple enums or not.
+ *
+ * @see SimpleEnumMarker
+ *
+ * @author Eric Lafortune
+ */
+public class SimpleEnumFilter
+implements ClassVisitor
+{
+ private final ClassVisitor simpleEnumClassVisitor;
+ private final ClassVisitor otherClassVisitor;
+
+
+ /**
+ * Creates a new SimpleEnumClassFilter.
+ *
+ * @param simpleEnumClassVisitor the class visitor to which visits to
+ * classes that are marked to be simpleEnum
+ * will be delegated.
+ */
+ public SimpleEnumFilter(ClassVisitor simpleEnumClassVisitor)
+ {
+ this(simpleEnumClassVisitor, null);
+ }
+
+
+ /**
+ * Creates a new SimpleEnumClassFilter.
+ *
+ * @param simpleEnumClassVisitor the class visitor to which visits to
+ * classes that are marked as simple enums
+ * will be delegated.
+ * @param otherClassVisitor the class visitor to which visits to
+ * classes that are not marked as simple
+ * enums will be delegated.
+ */
+ public SimpleEnumFilter(ClassVisitor simpleEnumClassVisitor,
+ ClassVisitor otherClassVisitor)
+ {
+ this.simpleEnumClassVisitor = simpleEnumClassVisitor;
+ this.otherClassVisitor = otherClassVisitor;
+ }
+
+
+ // Implementations for ClassVisitor.
+
+ public void visitProgramClass(ProgramClass programClass)
+ {
+ // Is the class marked as a simple enum?
+ ClassVisitor classVisitor = SimpleEnumMarker.isSimpleEnum(programClass) ?
+ simpleEnumClassVisitor : otherClassVisitor;
+
+ if (classVisitor != null)
+ {
+ classVisitor.visitProgramClass(programClass);
+ }
+ }
+
+
+ public void visitLibraryClass(LibraryClass libraryClass)
+ {
+ // A library class can't be marked as a simple enum.
+ if (otherClassVisitor != null)
+ {
+ otherClassVisitor.visitLibraryClass(libraryClass);
+ }
+ }
+} \ No newline at end of file