本文整理汇总了Java中com.sun.tools.classfile.Instruction.accept方法的典型用法代码示例。如果您正苦于以下问题:Java Instruction.accept方法的具体用法?Java Instruction.accept怎么用?Java Instruction.accept使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.tools.classfile.Instruction
的用法示例。
在下文中一共展示了Instruction.accept方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkClassFile
import com.sun.tools.classfile.Instruction; //导入方法依赖的package包/类
void checkClassFile(final Path path) throws Exception {
ClassFile classFile = ClassFile.read(
new BufferedInputStream(Files.newInputStream(path)));
constantPool = classFile.constant_pool;
utf8Index = constantPool.getUTF8Index("STR_TO_LOOK_FOR");
for (Method method: classFile.methods) {
if (method.getName(constantPool).equals("methodToLookFor")) {
Code_attribute codeAtt = (Code_attribute)method.attributes.get(Attribute.Code);
for (Instruction inst: codeAtt.getInstructions()) {
inst.accept(codeVisitor, null);
}
}
}
Assert.check(numberOfRefToStr == 1,
"There should only be one reference to a CONSTANT_String_info structure in the generated code");
}
示例2: writeInstr
import com.sun.tools.classfile.Instruction; //导入方法依赖的package包/类
public void writeInstr(Instruction instr) {
print(String.format("%4d: %-13s ", instr.getPC(), instr.getMnemonic()));
// compute the number of indentations for the body of multi-line instructions
// This is 6 (the width of "%4d: "), divided by the width of each indentation level,
// and rounded up to the next integer.
int indentWidth = options.indentWidth;
int indent = (6 + indentWidth - 1) / indentWidth;
instr.accept(instructionPrinter, indent);
println();
}
示例3: visit
import com.sun.tools.classfile.Instruction; //导入方法依赖的package包/类
public Element visit(Instruction i) {
Element ie = i.accept(this, null);
ie.trimToSize();
return ie;
}