本文整理汇总了Java中com.sun.org.apache.bcel.internal.generic.InstructionList.copy方法的典型用法代码示例。如果您正苦于以下问题:Java InstructionList.copy方法的具体用法?Java InstructionList.copy怎么用?Java InstructionList.copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.org.apache.bcel.internal.generic.InstructionList
的用法示例。
在下文中一共展示了InstructionList.copy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compile
import com.sun.org.apache.bcel.internal.generic.InstructionList; //导入方法依赖的package包/类
/**
* Compile the code for this test sequence. Compile patterns
* from highest to lowest priority. Note that since patterns
* can be share by multiple test sequences, instruction lists
* must be copied before backpatching.
*/
public InstructionHandle compile(ClassGenerator classGen,
MethodGenerator methodGen,
InstructionHandle continuation)
{
// Returned cached value if already compiled
if (_start != null) {
return _start;
}
// If not patterns, then return handle for default template
final int count = _patterns.size();
if (count == 0) {
return (_start = getTemplateHandle(_default));
}
// Init handle to jump when all patterns failed
InstructionHandle fail = (_default == null) ? continuation
: getTemplateHandle(_default);
// Compile all patterns in reverse order
for (int n = count - 1; n >= 0; n--) {
final LocationPathPattern pattern = getPattern(n);
final Template template = pattern.getTemplate();
final InstructionList il = new InstructionList();
// Patterns expect current node on top of stack
il.append(methodGen.loadCurrentNode());
// Apply the test-code compiled for the pattern
InstructionList ilist = methodGen.getInstructionList(pattern);
if (ilist == null) {
ilist = pattern.compile(classGen, methodGen);
methodGen.addInstructionList(pattern, ilist);
}
// Make a copy of the instruction list for backpatching
InstructionList copyOfilist = ilist.copy();
FlowList trueList = pattern.getTrueList();
if (trueList != null) {
trueList = trueList.copyAndRedirect(ilist, copyOfilist);
}
FlowList falseList = pattern.getFalseList();
if (falseList != null) {
falseList = falseList.copyAndRedirect(ilist, copyOfilist);
}
il.append(copyOfilist);
// On success branch to the template code
final InstructionHandle gtmpl = getTemplateHandle(template);
final InstructionHandle success = il.append(new GOTO_W(gtmpl));
if (trueList != null) {
trueList.backPatch(success);
}
if (falseList != null) {
falseList.backPatch(fail);
}
// Next pattern's 'fail' target is this pattern's first instruction
fail = il.getStart();
// Append existing instruction list to the end of this one
if (_instructionList != null) {
il.append(_instructionList);
}
// Set current instruction list to be this one
_instructionList = il;
}
return (_start = fail);
}