Skip to content

Commit

Permalink
Rename Matcher attribute elements
Browse files Browse the repository at this point in the history
  • Loading branch information
biboudis committed Jun 2, 2023
1 parent b65664f commit 2c8d86f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -868,12 +868,9 @@ int writeRecordAttribute(ClassSymbol csym) {
int writeMatcherAttribute(MethodSymbol m) {
final int attrIndex = writeAttr(names.Matcher);

databuf.appendChar(MatcherFlags.value(m.matcherFlags));

databuf.appendChar(poolWriter.putName(m.name));

Type patternDescriptor = m.type;
databuf.appendChar(poolWriter.putDescriptor(patternDescriptor));
databuf.appendChar(MatcherFlags.value(m.matcherFlags));
databuf.appendChar(poolWriter.putConstant(m.type.asMethodType()));

int acountIdx = beginAttrs();
int acount = 0;
Expand All @@ -887,6 +884,7 @@ int writeMatcherAttribute(MethodSymbol m) {

endAttrs(acountIdx, acount);
endAttr(attrIndex);

return 1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,9 +528,9 @@ protected void writeLocalVariableTypeTableEntry(LocalVariableTypeTable_attribute

@Override
public Void visitMatcher(Matcher_attribute attr, ClassOutputStream out) {
out.writeShort(attr.pattern_flags);
out.writeShort(attr.pattern_name_index);
out.writeShort(attr.pattern_descriptor.index);
out.writeShort(attr.matcher_flags);
out.writeShort(attr.matcher_name_index);
out.writeShort(attr.matcher_methodtype.descriptor_index);
int size = attr.attributes.size();
out.writeShort(size);
for (Attribute componentAttr: attr.attributes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

import java.io.IOException;

import static com.sun.tools.classfile.ConstantPool.*;

/**
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own risk.
Expand All @@ -37,19 +39,19 @@ public class Matcher_attribute extends Attribute {
public static final int PAT_DECONSTRUCTOR = 0x0001;
public static final int PAT_TOTAL = 0x0002;

Matcher_attribute(ClassReader cr, int name_index, int length) throws IOException {
Matcher_attribute(ClassReader cr, int name_index, int length) throws IOException, ConstantPoolException {
super(name_index, length);
pattern_flags = cr.readUnsignedShort();
pattern_name_index = cr.readUnsignedShort();
pattern_descriptor = new Descriptor(cr);
matcher_name_index = cr.readUnsignedShort();
matcher_flags = cr.readUnsignedShort();
matcher_methodtype = new CONSTANT_MethodType_info(cr.getConstantPool(), cr.readUnsignedShort());
attributes = new Attributes(cr);
}

public Matcher_attribute(int name_index, int pattern_flags, int pattern_name_index, Descriptor pattern_descriptor, Attributes attributes) {
public Matcher_attribute(int name_index, int pattern_flags, int matcher_name_index, CONSTANT_MethodType_info matcher_methodtype, Attributes attributes) {
super(name_index, 4);
this.pattern_flags = pattern_flags;
this.pattern_name_index = pattern_name_index;
this.pattern_descriptor = pattern_descriptor;
this.matcher_name_index = matcher_name_index;
this.matcher_flags = pattern_flags;
this.matcher_methodtype = matcher_methodtype;
this.attributes = attributes;
}

Expand All @@ -58,8 +60,8 @@ public <R, D> R accept(Visitor<R, D> visitor, D data) {
return visitor.visitMatcher(this, data);
}

public final int pattern_flags;
public final int pattern_name_index;
public final Descriptor pattern_descriptor;
public final int matcher_name_index;
public final int matcher_flags;
public final CONSTANT_MethodType_info matcher_methodtype;
public final Attributes attributes;
}
Original file line number Diff line number Diff line change
Expand Up @@ -368,18 +368,18 @@ public Void visitMatcher(Matcher_attribute attr, Void unused) {
println("Matcher:");
indent(+1);

String nameString = attr.pattern_name_index != 0 ?
constantWriter.stringValue(attr.pattern_name_index) : "<no name>";
println("pattern_name: " + nameString);
String nameString = attr.matcher_name_index != 0 ?
constantWriter.stringValue(attr.matcher_name_index) : "<no name>";
println("matcher_name_index: " + nameString);

String flagString =
(0 != (attr.pattern_flags & Matcher_attribute.PAT_DECONSTRUCTOR) ? "deconstructor " : "") +
(0 != (attr.pattern_flags & Matcher_attribute.PAT_TOTAL) ? "total" : "");
println("flags: " + flagString);
(0 != (attr.matcher_flags & Matcher_attribute.PAT_DECONSTRUCTOR) ? "deconstructor " : "") +
(0 != (attr.matcher_flags & Matcher_attribute.PAT_TOTAL) ? "total" : "");
println("matcher_flags: " + flagString);

constantWriter.write(attr.matcher_methodtype.descriptor_index);
println();

if (options.showDescriptors) {
println("pattern_descriptor: " + getValue(attr.pattern_descriptor));
}
if (options.showAllAttrs && attr.attributes.size() > 0) {
for (Attribute matcherAttribute: attr.attributes)
write(attr, matcherAttribute, constant_pool);
Expand Down

0 comments on commit 2c8d86f

Please sign in to comment.