blob: 1d891e09a86a26d2af7ebf77754d95c9339a6082 [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.dex;
public class Segment {
final int type;
final int size;
public final int offset;
int end;
public Segment(int type, int unused, int size, int offset) {
this.type = type;
assert unused == 0;
this.size = size;
this.offset = offset;
this.end = -1;
}
public int getType() {
return type;
}
public int getSize() {
return size;
}
void setEnd(int end) {
this.end = end;
}
public String typeName() {
switch (type) {
case Constants.TYPE_HEADER_ITEM:
return "Header";
case Constants.TYPE_STRING_ID_ITEM:
return "Strings";
case Constants.TYPE_TYPE_ID_ITEM:
return "Types";
case Constants.TYPE_PROTO_ID_ITEM:
return "Protos";
case Constants.TYPE_FIELD_ID_ITEM:
return "Fields";
case Constants.TYPE_METHOD_ID_ITEM:
return "Methods";
case Constants.TYPE_CLASS_DEF_ITEM:
return "Class defs";
case Constants.TYPE_MAP_LIST:
return "Maps";
case Constants.TYPE_TYPE_LIST:
return "Type lists";
case Constants.TYPE_ANNOTATION_SET_REF_LIST:
return "Annotation set refs";
case Constants.TYPE_ANNOTATION_SET_ITEM:
return "Annotation sets";
case Constants.TYPE_CLASS_DATA_ITEM:
return "Class data";
case Constants.TYPE_CODE_ITEM:
return "Code";
case Constants.TYPE_STRING_DATA_ITEM:
return "String data";
case Constants.TYPE_DEBUG_INFO_ITEM:
return "Debug info";
case Constants.TYPE_ANNOTATION_ITEM:
return "Annotation";
case Constants.TYPE_ENCODED_ARRAY_ITEM:
return "Encoded arrays";
case Constants.TYPE_ANNOTATIONS_DIRECTORY_ITEM:
return "Annotations directory";
default:
return "Unknown";
}
}
public String toString() {
return typeName() + " @" + offset + " " + size;
}
}