Dump constant pool in debug mode
This commit is contained in:
parent
a18ae9c265
commit
07d43f2fe7
5 changed files with 77 additions and 42 deletions
|
|
@ -197,7 +197,7 @@ pub const AttributeInfo = union(enum) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn format(
|
||||
pub fn indentedFormat(
|
||||
self: *const Self,
|
||||
w: *std.Io.Writer,
|
||||
depth: usize,
|
||||
|
|
@ -213,7 +213,7 @@ pub const AttributeInfo = union(enum) {
|
|||
try w.splatByteAll(' ', depth * indent);
|
||||
_ = try w.write("name:\n");
|
||||
const attribute_name = new.attributeName(constant_pool) catch return error.WriteFailed;
|
||||
try attribute_name.format(w, depth, indent + 1, constant_pool);
|
||||
try attribute_name.indentedFormat(w, depth, indent + 1, constant_pool);
|
||||
},
|
||||
.predefined => |predefined| {
|
||||
try w.splatByteAll(' ', depth * indent);
|
||||
|
|
@ -225,7 +225,7 @@ pub const AttributeInfo = union(enum) {
|
|||
switch (predefined) {
|
||||
.constant_value => |attr| {
|
||||
const constant_value = attr.constantValue(constant_pool) catch return error.WriteFailed;
|
||||
try constant_value.format(w, depth, indent + 1, constant_pool);
|
||||
try constant_value.indentedFormat(w, depth, indent + 1, constant_pool);
|
||||
},
|
||||
.code => |attr| {
|
||||
try w.splatByteAll(' ', depth * indent);
|
||||
|
|
@ -268,7 +268,7 @@ pub const AttributeInfo = union(enum) {
|
|||
try w.splatByteAll(' ', depth * attr_indent);
|
||||
try w.print("{d}:\n", .{ i });
|
||||
|
||||
try a.format(w, depth, attr_indent + 1, allocator, constant_pool);
|
||||
try a.indentedFormat(w, depth, attr_indent + 1, allocator, constant_pool);
|
||||
}
|
||||
},
|
||||
//.stack_map_table,
|
||||
|
|
@ -286,7 +286,7 @@ pub const AttributeInfo = union(enum) {
|
|||
|
||||
try w.splatByteAll(' ', depth * exception_indent);
|
||||
try w.print("{d}:\n", .{ i });
|
||||
try cp_info.?.format(w, depth, exception_indent + 1, constant_pool);
|
||||
try cp_info.?.indentedFormat(w, depth, exception_indent + 1, constant_pool);
|
||||
}
|
||||
},
|
||||
.inner_classes => |attr| {
|
||||
|
|
@ -299,30 +299,30 @@ pub const AttributeInfo = union(enum) {
|
|||
|
||||
try w.splatByteAll(' ', depth * class_indent);
|
||||
try w.print("{d}:\n", .{ i });
|
||||
try class.format(w, depth, class_indent + 1, constant_pool);
|
||||
try class.indentedFormat(w, depth, class_indent + 1, constant_pool);
|
||||
}
|
||||
},
|
||||
.enclosing_method => |attr| {
|
||||
const class = attr.class(constant_pool) catch return error.WriteFailed;
|
||||
try w.splatByteAll(' ', depth * indent);
|
||||
_ = try w.write("class:\n");
|
||||
try class.format(w, depth, indent + 1, constant_pool);
|
||||
try class.indentedFormat(w, depth, indent + 1, constant_pool);
|
||||
|
||||
const method = attr.method(constant_pool) catch return error.WriteFailed;
|
||||
if (method) |m| {
|
||||
try w.splatByteAll(' ', depth * indent);
|
||||
_ = try w.write("method:\n");
|
||||
try m.format(w, depth, indent + 1, constant_pool);
|
||||
try m.indentedFormat(w, depth, indent + 1, constant_pool);
|
||||
}
|
||||
},
|
||||
.synthetic => {},
|
||||
.signature => |attr| {
|
||||
const signature = attr.signature(constant_pool) catch return error.WriteFailed;
|
||||
try signature.format(w, depth, indent + 1, constant_pool);
|
||||
try signature.indentedFormat(w, depth, indent + 1, constant_pool);
|
||||
},
|
||||
.source_file => |attr| {
|
||||
const source_file = attr.sourceFile(constant_pool) catch return error.WriteFailed;
|
||||
try source_file.format(w, depth, indent + 1, constant_pool);
|
||||
try source_file.indentedFormat(w, depth, indent + 1, constant_pool);
|
||||
},
|
||||
//.source_debug_extension,
|
||||
//.line_number_table,
|
||||
|
|
@ -675,27 +675,33 @@ pub const InnerClasses = struct {
|
|||
inner_name_index: u16,
|
||||
inner_class_access_flags: InnerClassAccessFlags,
|
||||
|
||||
pub fn format(self: *const InnerClass, w: *std.Io.Writer, depth: usize, indent: u8, constant_pool: []const ?ConstantPoolInfo) std.Io.Writer.Error!void {
|
||||
pub fn indentedFormat(
|
||||
self: *const InnerClass,
|
||||
w: *std.Io.Writer,
|
||||
depth: usize,
|
||||
indent: u8,
|
||||
constant_pool: []const ?ConstantPoolInfo,
|
||||
) std.Io.Writer.Error!void {
|
||||
try w.splatByteAll(' ', depth * indent);
|
||||
try w.print("flags: {f}\n", .{ self.inner_class_access_flags });
|
||||
|
||||
const inner_class = self.innerClass(constant_pool) catch return error.WriteFailed;
|
||||
try w.splatByteAll(' ', depth * indent);
|
||||
_ = try w.write("inner_class:\n");
|
||||
try inner_class.format(w, depth, indent + 1, constant_pool);
|
||||
try inner_class.indentedFormat(w, depth, indent + 1, constant_pool);
|
||||
|
||||
const outer_class = self.outerClass(constant_pool) catch return error.WriteFailed;
|
||||
if (outer_class) |oc| {
|
||||
try w.splatByteAll(' ', depth * indent);
|
||||
_ = try w.write("outer_class:\n");
|
||||
try oc.format(w, depth, indent + 1, constant_pool);
|
||||
try oc.indentedFormat(w, depth, indent + 1, constant_pool);
|
||||
}
|
||||
|
||||
const inner_name = self.innerName(constant_pool) catch return error.WriteFailed;
|
||||
if (inner_name) |in| {
|
||||
try w.splatByteAll(' ', depth * indent);
|
||||
_ = try w.write("inner_name:\n");
|
||||
try in.format(w, depth, indent + 1, constant_pool);
|
||||
try in.indentedFormat(w, depth, indent + 1, constant_pool);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ pub fn deinit(self: *Self, allocator: std.mem.Allocator) void {
|
|||
allocator.free(self.attributes);
|
||||
}
|
||||
|
||||
pub fn format(
|
||||
pub fn indentedFormat(
|
||||
self: *const Self,
|
||||
w: *std.Io.Writer,
|
||||
depth: usize,
|
||||
|
|
@ -62,12 +62,12 @@ pub fn format(
|
|||
try w.splatByteAll(' ', depth * indent);
|
||||
_ = try w.write("name:\n");
|
||||
const field_name = self.name(constant_pool) catch return error.WriteFailed;
|
||||
try field_name.format(w, depth, indent + 1, constant_pool);
|
||||
try field_name.indentedFormat(w, depth, indent + 1, constant_pool);
|
||||
|
||||
try w.splatByteAll(' ', depth * indent);
|
||||
_ = try w.write("descriptor:\n");
|
||||
const field_descriptor = self.descriptor(constant_pool) catch return error.WriteFailed;
|
||||
try field_descriptor.format(w, depth, indent + 1, constant_pool);
|
||||
try field_descriptor.indentedFormat(w, depth, indent + 1, constant_pool);
|
||||
|
||||
try w.splatByteAll(' ', depth * indent);
|
||||
_ = try w.write("attributes:\n");
|
||||
|
|
@ -79,7 +79,7 @@ pub fn format(
|
|||
try w.splatByteAll(' ', depth * attr_indent);
|
||||
try w.print("{d}:\n", .{ j });
|
||||
|
||||
try attribute.format(w, depth, attr_indent + 1, allocator, constant_pool);
|
||||
try attribute.indentedFormat(w, depth, attr_indent + 1, allocator, constant_pool);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ pub fn deinit(self: *Self, allocator: std.mem.Allocator) void {
|
|||
allocator.free(self.attributes);
|
||||
}
|
||||
|
||||
pub fn format(
|
||||
pub fn indentedFormat(
|
||||
self: *const Self,
|
||||
w: *std.Io.Writer,
|
||||
depth: usize,
|
||||
|
|
@ -65,12 +65,12 @@ pub fn format(
|
|||
try w.splatByteAll(' ', depth * indent);
|
||||
_ = try w.write("name:\n");
|
||||
const method_name = self.name(constant_pool) catch return error.WriteFailed;
|
||||
try method_name.format(w, depth, indent + 1, constant_pool);
|
||||
try method_name.indentedFormat(w, depth, indent + 1, constant_pool);
|
||||
|
||||
try w.splatByteAll(' ', depth * indent);
|
||||
_ = try w.write("descriptor:\n");
|
||||
const method_descriptor = self.descriptor(constant_pool) catch return error.WriteFailed;
|
||||
try method_descriptor.format(w, depth, indent + 1, constant_pool);
|
||||
try method_descriptor.indentedFormat(w, depth, indent + 1, constant_pool);
|
||||
|
||||
try w.splatByteAll(' ', depth * indent);
|
||||
_ = try w.write("attributes:\n");
|
||||
|
|
@ -82,7 +82,7 @@ pub fn format(
|
|||
try w.splatByteAll(' ', depth * attr_indent);
|
||||
try w.print("{d}:\n", .{ j });
|
||||
|
||||
try attribute.format(w, depth, attr_indent + 1, allocator, constant_pool);
|
||||
try attribute.indentedFormat(w, depth, attr_indent + 1, allocator, constant_pool);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue