• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2016, the R8 project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4 package com.android.tools.r8.dex;
5 
6 import com.android.tools.r8.graph.DexAnnotation;
7 import com.android.tools.r8.graph.DexAnnotationDirectory;
8 import com.android.tools.r8.graph.DexAnnotationSet;
9 import com.android.tools.r8.graph.DexAnnotationSetRefList;
10 import com.android.tools.r8.graph.DexCode;
11 import com.android.tools.r8.graph.DexDebugInfo;
12 import com.android.tools.r8.graph.DexEncodedArray;
13 import com.android.tools.r8.graph.DexItem;
14 import com.android.tools.r8.graph.DexProgramClass;
15 import com.android.tools.r8.graph.DexTypeList;
16 
17 /**
18  * Collection of the various components of the mixed section of a dex file.
19  *
20  * <p>This semantically is just a wrapper around a bunch of collections. We do not expose the
21  * collections directly to allow for implementations that under the hood do not use collections.
22  *
23  * <p>See {@link DexItem#collectMixedSectionItems(MixedSectionCollection)} for
24  * information on how to fill a {@link MixedSectionCollection}.
25  */
26 public abstract class MixedSectionCollection {
27 
28   /**
29    * Adds the given class data to the collection.
30    *
31    * Does not add any dependencies.
32    *
33    * @return true if the item was not added before
34    */
add(DexProgramClass dexClassData)35   public abstract boolean add(DexProgramClass dexClassData);
36 
37   /**
38    * Adds the given encoded array to the collection.
39    *
40    * Does not add any dependencies.
41    *
42    * @return true if the item was not added before
43    */
add(DexEncodedArray dexEncodedArray)44   public abstract boolean add(DexEncodedArray dexEncodedArray);
45 
46   /**
47    * Adds the given annotation set to the collection.
48    *
49    * Does not add any dependencies.
50    *
51    * @return true if the item was not added before
52    */
add(DexAnnotationSet dexAnnotationSet)53   public abstract boolean add(DexAnnotationSet dexAnnotationSet);
54 
55   /**
56    * Adds the given code item to the collection.
57    *
58    * Does not add any dependencies.
59    *
60    * @return true if the item was not added before
61    */
add(DexCode dexCode)62   public abstract boolean add(DexCode dexCode);
63 
64   /**
65    * Adds the given debug info to the collection.
66    *
67    * Does not add any dependencies.
68    *
69    * @return true if the item was not added before
70    */
add(DexDebugInfo dexDebugInfo)71   public abstract boolean add(DexDebugInfo dexDebugInfo);
72 
73   /**
74    * Adds the given type list to the collection.
75    *
76    * Does not add any dependencies.
77    *
78    * @return true if the item was not added before
79    */
add(DexTypeList dexTypeList)80   public abstract boolean add(DexTypeList dexTypeList);
81 
82   /**
83    * Adds the given annotation-set reference list to the collection.
84    *
85    * Does not add any dependencies.
86    *
87    * @return true if the item was not added before
88    */
add(DexAnnotationSetRefList annotationSetRefList)89   public abstract boolean add(DexAnnotationSetRefList annotationSetRefList);
90 
91   /**
92    * Adds the given annotation to the collection.
93    *
94    * Does not add any dependencies.
95    *
96    * @return true if the item was not added before
97    */
add(DexAnnotation annotation)98   public abstract boolean add(DexAnnotation annotation);
99 
100   /**
101    * Adds the given annotation directory to the collection.
102    *
103    * Add a dependency between the clazz and the annotation directory.
104    *
105    * @return true if the item was not added before
106    */
setAnnotationsDirectoryForClass(DexProgramClass clazz, DexAnnotationDirectory annotationDirectory)107   public abstract boolean setAnnotationsDirectoryForClass(DexProgramClass clazz,
108       DexAnnotationDirectory annotationDirectory);
109 }
110