Add annotation attribute constant pool info getters
This commit is contained in:
parent
114b9b099c
commit
af03ece92d
1 changed files with 31 additions and 6 deletions
|
|
@ -730,6 +730,11 @@ pub const StackMapTable = struct {
|
|||
.offset_delta = try input.takeInt(u16, .big),
|
||||
},
|
||||
},
|
||||
251 => .{
|
||||
.same_frame_extended = .{
|
||||
.offset_delta = try input.takeInt(u16, .big),
|
||||
},
|
||||
},
|
||||
252...254 => blk: {
|
||||
const offset_delta = try input.takeInt(u16, .big);
|
||||
|
||||
|
|
@ -796,12 +801,8 @@ pub const StackMapTable = struct {
|
|||
long,
|
||||
null,
|
||||
uninitialized_this,
|
||||
object: struct {
|
||||
cpool_index: u16,
|
||||
},
|
||||
uninitialized: struct {
|
||||
cpool_index: u16,
|
||||
},
|
||||
object: Object,
|
||||
uninitialized: Uninitialized,
|
||||
|
||||
pub const Tag = enum(u8) {
|
||||
top = 0,
|
||||
|
|
@ -815,6 +816,18 @@ pub const StackMapTable = struct {
|
|||
uninitialized = 8,
|
||||
};
|
||||
|
||||
pub const Object = struct {
|
||||
cpool_index: u16,
|
||||
|
||||
pub fn class(self: *const Object, constant_pool: ConstantPool) ResolveError!ConstantPool.Info {
|
||||
return constant_pool.getTag(self.cpool_index, .class);
|
||||
}
|
||||
};
|
||||
|
||||
pub const Uninitialized = struct {
|
||||
offset: u16,
|
||||
};
|
||||
|
||||
pub fn parse(input: *std.Io.Reader) ParseError!VerificationTypeInfo {
|
||||
const tag_byte = try input.takeByte();
|
||||
const tag = std.enums.fromInt(StackMapTable.VerificationTypeInfo.Tag, tag_byte) orelse return ParseError.InvalidTag;
|
||||
|
|
@ -1301,12 +1314,20 @@ pub const ElementValue = union(enum) {
|
|||
pub const ElementValuePair = struct {
|
||||
element_name_index: u16,
|
||||
value: ElementValue,
|
||||
|
||||
const Self = @This();
|
||||
|
||||
pub fn elementName(self: *const Self, constant_pool: ConstantPool) ResolveError!ConstantPool.Info {
|
||||
return constant_pool.getTag(self.element_name_index, .utf8);
|
||||
}
|
||||
};
|
||||
|
||||
pub const Annotation = struct {
|
||||
type_index: u16,
|
||||
element_value_pairs: []ElementValuePair,
|
||||
|
||||
const Self = @This();
|
||||
|
||||
pub fn parse(input: *std.Io.Reader, allocator: std.mem.Allocator) ParseError!Annotation {
|
||||
const type_index = try input.takeInt(u16, .big);
|
||||
|
||||
|
|
@ -1332,6 +1353,10 @@ pub const Annotation = struct {
|
|||
}
|
||||
allocator.free(self.element_value_pairs);
|
||||
}
|
||||
|
||||
pub fn @"type"(self: *const Self, constant_pool: ConstantPool) ResolveError!ConstantPool.Info {
|
||||
return constant_pool.getTag(self.type_index, .utf8);
|
||||
}
|
||||
};
|
||||
|
||||
pub const RuntimeVisibleAnnotations = struct {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue