📄 asmifierclassvisitor.java
字号:
appendConstant(debug);
buf.append(");\n\n");
text.add(buf.toString());
}
public void visitOuterClass(
final String owner,
final String name,
final String desc)
{
buf.setLength(0);
buf.append("cw.visitOuterClass(");
appendConstant(owner);
buf.append(", ");
appendConstant(name);
buf.append(", ");
appendConstant(desc);
buf.append(");\n\n");
text.add(buf.toString());
}
public void visitInnerClass(
final String name,
final String outerName,
final String innerName,
final int access)
{
buf.setLength(0);
buf.append("cw.visitInnerClass(");
appendConstant(name);
buf.append(", ");
appendConstant(outerName);
buf.append(", ");
appendConstant(innerName);
buf.append(", ");
appendAccess(access | ACCESS_INNER);
buf.append(");\n\n");
text.add(buf.toString());
}
public FieldVisitor visitField(
final int access,
final String name,
final String desc,
final String signature,
final Object value)
{
buf.setLength(0);
buf.append("{\n");
buf.append("fv = cw.visitField(");
appendAccess(access | ACCESS_FIELD);
buf.append(", ");
appendConstant(name);
buf.append(", ");
appendConstant(desc);
buf.append(", ");
appendConstant(signature);
buf.append(", ");
appendConstant(value);
buf.append(");\n");
text.add(buf.toString());
ASMifierFieldVisitor aav = new ASMifierFieldVisitor();
text.add(aav.getText());
text.add("}\n");
return aav;
}
public MethodVisitor visitMethod(
final int access,
final String name,
final String desc,
final String signature,
final String[] exceptions)
{
buf.setLength(0);
buf.append("{\n");
buf.append("mv = cw.visitMethod(");
appendAccess(access);
buf.append(", ");
appendConstant(name);
buf.append(", ");
appendConstant(desc);
buf.append(", ");
appendConstant(signature);
buf.append(", ");
if (exceptions != null && exceptions.length > 0) {
buf.append("new String[] {");
for (int i = 0; i < exceptions.length; ++i) {
buf.append(i == 0 ? " " : ", ");
appendConstant(exceptions[i]);
}
buf.append(" }");
} else {
buf.append("null");
}
buf.append(");\n");
text.add(buf.toString());
ASMifierMethodVisitor acv = createASMifierMethodVisitor();
text.add(acv.getText());
text.add("}\n");
return acv;
}
protected ASMifierMethodVisitor createASMifierMethodVisitor() {
return new ASMifierMethodVisitor();
}
public AnnotationVisitor visitAnnotation(
final String desc,
final boolean visible)
{
buf.setLength(0);
buf.append("{\n");
buf.append("av0 = cw.visitAnnotation(");
appendConstant(desc);
buf.append(", ");
buf.append(visible);
buf.append(");\n");
text.add(buf.toString());
ASMifierAnnotationVisitor av = new ASMifierAnnotationVisitor(0);
text.add(av.getText());
text.add("}\n");
return av;
}
public void visitEnd() {
text.add("cw.visitEnd();\n\n");
text.add("return cw.toByteArray();\n");
text.add("}\n");
text.add("}\n");
printList(pw, text);
pw.flush();
}
// ------------------------------------------------------------------------
// Utility methods
// ------------------------------------------------------------------------
/**
* Appends a string representation of the given access modifiers to {@link
* #buf buf}.
*
* @param access some access modifiers.
*/
void appendAccess(final int access) {
boolean first = true;
if ((access & Opcodes.ACC_PUBLIC) != 0) {
buf.append("ACC_PUBLIC");
first = false;
}
if ((access & Opcodes.ACC_PRIVATE) != 0) {
buf.append("ACC_PRIVATE");
first = false;
}
if ((access & Opcodes.ACC_PROTECTED) != 0) {
buf.append("ACC_PROTECTED");
first = false;
}
if ((access & Opcodes.ACC_FINAL) != 0) {
if (!first) {
buf.append(" + ");
}
buf.append("ACC_FINAL");
first = false;
}
if ((access & Opcodes.ACC_STATIC) != 0) {
if (!first) {
buf.append(" + ");
}
buf.append("ACC_STATIC");
first = false;
}
if ((access & Opcodes.ACC_SYNCHRONIZED) != 0) {
if (!first) {
buf.append(" + ");
}
if ((access & ACCESS_CLASS) != 0) {
buf.append("ACC_SUPER");
} else {
buf.append("ACC_SYNCHRONIZED");
}
first = false;
}
if ((access & Opcodes.ACC_VOLATILE) != 0
&& (access & ACCESS_FIELD) != 0)
{
if (!first) {
buf.append(" + ");
}
buf.append("ACC_VOLATILE");
first = false;
}
if ((access & Opcodes.ACC_BRIDGE) != 0 && (access & ACCESS_CLASS) == 0
&& (access & ACCESS_FIELD) == 0)
{
if (!first) {
buf.append(" + ");
}
buf.append("ACC_BRIDGE");
first = false;
}
if ((access & Opcodes.ACC_VARARGS) != 0 && (access & ACCESS_CLASS) == 0
&& (access & ACCESS_FIELD) == 0)
{
if (!first) {
buf.append(" + ");
}
buf.append("ACC_VARARGS");
first = false;
}
if ((access & Opcodes.ACC_TRANSIENT) != 0
&& (access & ACCESS_FIELD) != 0)
{
if (!first) {
buf.append(" + ");
}
buf.append("ACC_TRANSIENT");
first = false;
}
if ((access & Opcodes.ACC_NATIVE) != 0 && (access & ACCESS_CLASS) == 0
&& (access & ACCESS_FIELD) == 0)
{
if (!first) {
buf.append(" + ");
}
buf.append("ACC_NATIVE");
first = false;
}
if ((access & Opcodes.ACC_ENUM) != 0
&& ((access & ACCESS_CLASS) != 0
|| (access & ACCESS_FIELD) != 0 || (access & ACCESS_INNER) != 0))
{
if (!first) {
buf.append(" + ");
}
buf.append("ACC_ENUM");
first = false;
}
if ((access & Opcodes.ACC_ANNOTATION) != 0
&& (access & ACCESS_CLASS) != 0)
{
if (!first) {
buf.append(" + ");
}
buf.append("ACC_ANNOTATION");
first = false;
}
if ((access & Opcodes.ACC_ABSTRACT) != 0) {
if (!first) {
buf.append(" + ");
}
buf.append("ACC_ABSTRACT");
first = false;
}
if ((access & Opcodes.ACC_INTERFACE) != 0) {
if (!first) {
buf.append(" + ");
}
buf.append("ACC_INTERFACE");
first = false;
}
if ((access & Opcodes.ACC_STRICT) != 0) {
if (!first) {
buf.append(" + ");
}
buf.append("ACC_STRICT");
first = false;
}
if ((access & Opcodes.ACC_SYNTHETIC) != 0) {
if (!first) {
buf.append(" + ");
}
buf.append("ACC_SYNTHETIC");
first = false;
}
if ((access & Opcodes.ACC_DEPRECATED) != 0) {
if (!first) {
buf.append(" + ");
}
buf.append("ACC_DEPRECATED");
first = false;
}
if (first) {
buf.append("0");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -