• 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.graph;
5 
6 public class OffsetToObjectMapping {
7 
8   private DexProgramClass[] classes;
9   private DexMethod[] methods;
10   private DexProto[] protos;
11   private DexField[] fields;
12   private DexType[] types;
13   private DexString[] strings;
14   private DexCallSite[] callSites;
15   private DexMethodHandle[] methodHandles;
16 
initializeClasses(int length)17   public void initializeClasses(int length) {
18     assert classes == null;
19     classes = new DexProgramClass[length];
20   }
21 
initializeMethods(int length)22   public void initializeMethods(int length) {
23     assert methods == null;
24     methods = new DexMethod[length];
25   }
26 
initializeProtos(int length)27   public void initializeProtos(int length) {
28     assert protos == null;
29     protos = new DexProto[length];
30   }
31 
initializeFields(int length)32   public void initializeFields(int length) {
33     assert fields == null;
34     fields = new DexField[length];
35   }
36 
initializeTypes(int length)37   public void initializeTypes(int length) {
38     assert types == null;
39     types = new DexType[length];
40   }
41 
initializeStrings(int length)42   public void initializeStrings(int length) {
43     assert strings == null;
44     strings = new DexString[length];
45   }
46 
initializeCallSites(int length)47   public void initializeCallSites(int length) {
48     assert callSites == null;
49     callSites = new DexCallSite[length];
50   }
51 
initializeMethodHandles(int length)52   public void initializeMethodHandles(int length) {
53     assert methodHandles == null;
54     methodHandles = new DexMethodHandle[length];
55   }
56 
getClassMap()57   public DexProgramClass[] getClassMap() {
58     assert classes != null;
59     return classes;
60   }
61 
getMethodMap()62   public DexMethod[] getMethodMap() {
63     assert methods != null;
64     return methods;
65   }
66 
getProtosMap()67   public DexProto[] getProtosMap() {
68     assert protos != null;
69     return protos;
70   }
71 
getFieldMap()72   public DexField[] getFieldMap() {
73     assert fields != null;
74     return fields;
75   }
76 
getTypeMap()77   public DexType[] getTypeMap() {
78     assert types != null;
79     return types;
80   }
81 
getStringMap()82   public DexString[] getStringMap() {
83     assert strings != null;
84     return strings;
85   }
86 
getCallSiteMap()87   public DexCallSite[] getCallSiteMap() {
88     assert callSites != null;
89     return callSites;
90   }
91 
getMethodHandleMap()92   public DexMethodHandle[] getMethodHandleMap() {
93     assert methodHandles != null;
94     return methodHandles;
95   }
96 
getClass(int index)97   public DexProgramClass getClass(int index) {
98     assert classes[index] != null;
99     return classes[index];
100   }
101 
getMethod(int index)102   public DexMethod getMethod(int index) {
103     assert methods[index] != null;
104     return methods[index];
105   }
106 
getProto(int index)107   public DexProto getProto(int index) {
108     assert protos[index] != null;
109     return protos[index];
110   }
111 
getField(int index)112   public DexField getField(int index) {
113     assert fields[index] != null;
114     return fields[index];
115   }
116 
getType(int index)117   public DexType getType(int index) {
118     assert types[index] != null;
119     return types[index];
120   }
121 
getString(int index)122   public DexString getString(int index) {
123     assert strings[index] != null;
124     return strings[index];
125   }
126 
getCallSite(int index)127   public DexCallSite getCallSite(int index) {
128     assert callSites[index] != null;
129     return callSites[index];
130   }
131 
getMethodHandle(int index)132   public DexMethodHandle getMethodHandle(int index) {
133     assert methodHandles[index] != null;
134     return methodHandles[index];
135   }
136 
setClass(int index, DexProgramClass clazz)137   public void setClass(int index, DexProgramClass clazz) {
138     assert classes[index] == null;
139     classes[index] = clazz;
140   }
141 
setProto(int index, DexProto proto)142   public void setProto(int index, DexProto proto) {
143     assert protos[index] == null;
144     protos[index] = proto;
145   }
146 
setMethod(int index, DexMethod method)147   public void setMethod(int index, DexMethod method) {
148     assert methods[index] == null;
149     methods[index] = method;
150   }
151 
setField(int index, DexField field)152   public void setField(int index, DexField field) {
153     assert fields[index] == null;
154     fields[index] = field;
155   }
156 
setType(int index, DexType type)157   public void setType(int index, DexType type) {
158     assert types[index] == null;
159     types[index] = type;
160   }
161 
setString(int index, DexString string)162   public void setString(int index, DexString string) {
163     assert strings[index] == null;
164     strings[index] = string;
165   }
166 
setCallSites(int index, DexCallSite callSite)167   public void setCallSites(int index, DexCallSite callSite) {
168     assert callSites[index] == null;
169     callSites[index] = callSite;
170   }
171 
setMethodHandle(int index, DexMethodHandle methodHandle)172   public void setMethodHandle(int index, DexMethodHandle methodHandle) {
173     assert methodHandles[index] == null;
174     methodHandles[index] = methodHandle;
175   }
176 }
177