blob: 4bb13142b09c4908915199201985152ac3d769e0 [file] [log] [blame]
// Copyright (c) 2016, the R8 project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
package com.android.tools.r8.graph;
import com.android.tools.r8.dex.IndexedItemCollection;
import com.android.tools.r8.dex.MixedSectionCollection;
import java.util.Arrays;
public class DexAnnotationSetRefList extends DexItem {
private static final DexAnnotationSetRefList theEmptyTypeList = new DexAnnotationSetRefList();
public final DexAnnotationSet[] values;
private final int missingParameterAnnotations;
public static DexAnnotationSetRefList empty() {
return theEmptyTypeList;
}
private DexAnnotationSetRefList() {
this.values = new DexAnnotationSet[0];
this.missingParameterAnnotations = 0;
}
public DexAnnotationSetRefList(DexAnnotationSet[] values) {
this(values, 0);
}
public DexAnnotationSetRefList(DexAnnotationSet[] values, int missingParameterAnnotations) {
assert values != null && values.length > 0;
this.values = values;
this.missingParameterAnnotations = missingParameterAnnotations;
}
@Override
public int hashCode() {
return Arrays.hashCode(values);
}
@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (other instanceof DexAnnotationSetRefList) {
return Arrays.equals(values, ((DexAnnotationSetRefList) other).values);
}
return false;
}
@Override
public void collectIndexedItems(IndexedItemCollection indexedItems,
DexMethod method, int instructionOffset) {
collectAll(indexedItems, values);
}
@Override
void collectMixedSectionItems(MixedSectionCollection mixedItems) {
// Collect values first so that the annotation sets have sorted themselves before adding this.
collectAll(mixedItems, values);
mixedItems.add(this);
}
public boolean isEmpty() {
return values.length == 0;
}
public int getMissingParameterAnnotations() {
return missingParameterAnnotations;
}
}