本文整理汇总了Java中com.sun.org.apache.bcel.internal.generic.InstructionList.append方法的典型用法代码示例。如果您正苦于以下问题:Java InstructionList.append方法的具体用法?Java InstructionList.append怎么用?Java InstructionList.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.org.apache.bcel.internal.generic.InstructionList
的用法示例。
在下文中一共展示了InstructionList.append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadAsArrayOffsetLength
import com.sun.org.apache.bcel.internal.generic.InstructionList; //导入方法依赖的package包/类
/**
* Generates code that loads the array that will contain the character
* data represented by this Text node, followed by the offset of the
* data from the start of the array, and then the length of the data.
*
* The pre-condition to calling this method is that
* canLoadAsArrayOffsetLength() returns true.
* @see #canLoadArrayOffsetLength()
*/
public void loadAsArrayOffsetLength(ClassGenerator classGen,
MethodGenerator methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
final XSLTC xsltc = classGen.getParser().getXSLTC();
// The XSLTC object keeps track of character data
// that is to be stored in char arrays.
final int offset = xsltc.addCharacterData(_text);
final int length = _text.length();
String charDataFieldName =
STATIC_CHAR_DATA_FIELD + (xsltc.getCharacterDataCount()-1);
il.append(new GETSTATIC(cpg.addFieldref(xsltc.getClassName(),
charDataFieldName,
STATIC_CHAR_DATA_FIELD_SIG)));
il.append(new PUSH(cpg, offset));
il.append(new PUSH(cpg, _text.length()));
}
示例2: translate
import com.sun.org.apache.bcel.internal.generic.InstructionList; //导入方法依赖的package包/类
/**
* This method is called when the constructor is compiled in
* Stylesheet.compileConstructor() and not as the syntax tree is traversed.
*/
public void translate(ClassGenerator classGen,
MethodGenerator methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
final int tst = cpg.addMethodref(BASIS_LIBRARY_CLASS,
"testLanguage",
"("+STRING_SIG+DOM_INTF_SIG+"I)Z");
_lang.translate(classGen,methodGen);
il.append(methodGen.loadDOM());
if (classGen instanceof FilterGenerator)
il.append(new ILOAD(1));
else
il.append(methodGen.loadContextNode());
il.append(new INVOKESTATIC(tst));
}
示例3: translateTo
import com.sun.org.apache.bcel.internal.generic.InstructionList; //导入方法依赖的package包/类
/**
* Expects an integer on the stack and pushes its string value by calling
* <code>Integer.toString(int i)</code>.
*
* @see com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
*/
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
StringType type) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
il.append(DUP);
final BranchHandle ifNull = il.append(new IFNULL(null));
il.append(new INVOKEVIRTUAL(cpg.addMethodref(_javaClassName,
"toString",
"()" + STRING_SIG)));
final BranchHandle gotobh = il.append(new GOTO(null));
ifNull.setTarget(il.append(POP));
il.append(new PUSH(cpg, ""));
gotobh.setTarget(il.append(NOP));
}
示例4: compileDefaultText
import com.sun.org.apache.bcel.internal.generic.InstructionList; //导入方法依赖的package包/类
/**
* Compiles the default action for DOM text nodes and attribute nodes:
* output the node's text value
*/
private InstructionList compileDefaultText(ClassGenerator classGen,
MethodGenerator methodGen,
InstructionHandle next) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = new InstructionList();
final int chars = cpg.addInterfaceMethodref(DOM_INTF,
CHARACTERS,
CHARACTERS_SIG);
il.append(methodGen.loadDOM());
il.append(new ILOAD(_currentIndex));
il.append(methodGen.loadHandler());
il.append(new INVOKEINTERFACE(chars, 3));
il.append(new GOTO_W(next));
return il;
}
示例5: translateTo
import com.sun.org.apache.bcel.internal.generic.InstructionList; //导入方法依赖的package包/类
/**
* Expects a boolean on the stack and pushes a string. If the value on the
* stack is zero, then the string 'false' is pushed. Otherwise, the string
* 'true' is pushed.
*
* @see com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
*/
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
StringType type) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
final BranchHandle falsec = il.append(new IFEQ(null));
il.append(new PUSH(cpg, "true"));
final BranchHandle truec = il.append(new GOTO(null));
falsec.setTarget(il.append(new PUSH(cpg, "false")));
truec.setTarget(il.append(NOP));
}
示例6: compileGetChildren
import com.sun.org.apache.bcel.internal.generic.InstructionList; //导入方法依赖的package包/类
public static void compileGetChildren(ClassGenerator classGen,
MethodGenerator methodGen,
int node) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
final int git = cpg.addInterfaceMethodref(DOM_INTF,
GET_CHILDREN,
GET_CHILDREN_SIG);
il.append(methodGen.loadDOM());
il.append(new ILOAD(node));
il.append(new INVOKEINTERFACE(git, 2));
}
示例7: translate
import com.sun.org.apache.bcel.internal.generic.InstructionList; //导入方法依赖的package包/类
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
final InstructionList il = methodGen.getInstructionList();
if (argumentCount() == 0) {
il.append(methodGen.loadContextNode());
}
else { // one argument
argument().translate(classGen, methodGen);
}
final ConstantPoolGen cpg = classGen.getConstantPool();
il.append(new INVOKESTATIC(cpg.addMethodref(BASIS_LIBRARY_CLASS,
"generate_idF",
// reuse signature
GET_NODE_NAME_SIG)));
}
示例8: translate
import com.sun.org.apache.bcel.internal.generic.InstructionList; //导入方法依赖的package包/类
/**
* Translate code that leaves a node's QName (as a String) on the stack
*/
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
final int getName = cpg.addInterfaceMethodref(DOM_INTF,
GET_NODE_NAME,
GET_NODE_NAME_SIG);
super.translate(classGen, methodGen);
il.append(new INVOKEINTERFACE(getName, 2));
}
示例9: compileStripSpace
import com.sun.org.apache.bcel.internal.generic.InstructionList; //导入方法依赖的package包/类
public static void compileStripSpace(BranchHandle strip[],
int sCount,
InstructionList il) {
final InstructionHandle target = il.append(ICONST_1);
il.append(IRETURN);
for (int i = 0; i < sCount; i++) {
strip[i].setTarget(target);
}
}
示例10: translateDesynthesized
import com.sun.org.apache.bcel.internal.generic.InstructionList; //导入方法依赖的package包/类
/**
* Compile expression and update true/false-lists
*/
public void translateDesynthesized(ClassGenerator classGen,
MethodGenerator methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
_base.translate(classGen, methodGen);
_token.translate(classGen, methodGen);
il.append(new INVOKEVIRTUAL(cpg.addMethodref(STRING_CLASS,
"indexOf",
"("+STRING_SIG+")I")));
_falseList.add(il.append(new IFLT(null)));
}
示例11: translate
import com.sun.org.apache.bcel.internal.generic.InstructionList; //导入方法依赖的package包/类
/**
* Generate a call to the method compiled for this attribute set
*/
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
final SymbolTable symbolTable = getParser().getSymbolTable();
// Go through each attribute set and generate a method call
for (int i=0; i<_sets.size(); i++) {
// Get the attribute set name
final QName name = (QName)_sets.elementAt(i);
// Get the AttributeSet reference from the symbol table
final AttributeSet attrs = symbolTable.lookupAttributeSet(name);
// Compile the call to the set's method if the set exists
if (attrs != null) {
final String methodName = attrs.getMethodName();
il.append(classGen.loadTranslet());
il.append(methodGen.loadDOM());
il.append(methodGen.loadIterator());
il.append(methodGen.loadHandler());
il.append(methodGen.loadCurrentNode());
final int method = cpg.addMethodref(classGen.getClassName(),
methodName, ATTR_SET_SIG);
il.append(new INVOKESPECIAL(method));
}
// Generate an error if the attribute set does not exist
else {
final Parser parser = getParser();
final String atrs = name.toString();
reportError(this, parser, ErrorMsg.ATTRIBSET_UNDEF_ERR, atrs);
}
}
}
示例12: compileNamedTemplate
import com.sun.org.apache.bcel.internal.generic.InstructionList; //导入方法依赖的package包/类
private void compileNamedTemplate(Template template,
ClassGenerator classGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = new InstructionList();
String methodName = Util.escape(template.getName().toString());
int numParams = 0;
if (template.isSimpleNamedTemplate()) {
Vector parameters = template.getParameters();
numParams = parameters.size();
}
// Initialize the types and names arrays for the NamedMethodGenerator.
com.sun.org.apache.bcel.internal.generic.Type[] types =
new com.sun.org.apache.bcel.internal.generic.Type[4 + numParams];
String[] names = new String[4 + numParams];
types[0] = Util.getJCRefType(DOM_INTF_SIG);
types[1] = Util.getJCRefType(NODE_ITERATOR_SIG);
types[2] = Util.getJCRefType(TRANSLET_OUTPUT_SIG);
types[3] = com.sun.org.apache.bcel.internal.generic.Type.INT;
names[0] = DOCUMENT_PNAME;
names[1] = ITERATOR_PNAME;
names[2] = TRANSLET_OUTPUT_PNAME;
names[3] = NODE_PNAME;
// For simple named templates, the signature of the generated method
// is not fixed. It depends on the number of parameters declared in the
// template.
for (int i = 4; i < 4 + numParams; i++) {
types[i] = Util.getJCRefType(OBJECT_SIG);
names[i] = "param" + String.valueOf(i-4);
}
NamedMethodGenerator methodGen =
new NamedMethodGenerator(ACC_PUBLIC,
com.sun.org.apache.bcel.internal.generic.Type.VOID,
types, names, methodName,
getClassName(), il, cpg);
il.append(template.compile(classGen, methodGen));
il.append(RETURN);
classGen.addMethod(methodGen);
}
示例13: translate
import com.sun.org.apache.bcel.internal.generic.InstructionList; //导入方法依赖的package包/类
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
// Fall-through for variables that are implemented as methods
if (_type.implementedAsMethod()) return;
final String name = _variable.getEscapedName();
final String signature = _type.toSignature();
if (_variable.isLocal()) {
if (classGen.isExternal()) {
Closure variableClosure = _closure;
while (variableClosure != null) {
if (variableClosure.inInnerClass()) break;
variableClosure = variableClosure.getParentClosure();
}
if (variableClosure != null) {
il.append(ALOAD_0);
il.append(new GETFIELD(
cpg.addFieldref(variableClosure.getInnerClassName(),
name, signature)));
}
else {
il.append(_variable.loadInstruction());
}
}
else {
il.append(_variable.loadInstruction());
}
}
else {
final String className = classGen.getClassName();
il.append(classGen.loadTranslet());
if (classGen.isExternal()) {
il.append(new CHECKCAST(cpg.addClass(className)));
}
il.append(new GETFIELD(cpg.addFieldref(className,name,signature)));
}
if (_variable.getType() instanceof NodeSetType) {
// The method cloneIterator() also does resetting
final int clone = cpg.addInterfaceMethodref(NODE_ITERATOR,
"cloneIterator",
"()" +
NODE_ITERATOR_SIG);
il.append(new INVOKEINTERFACE(clone, 1));
}
}
示例14: translate
import com.sun.org.apache.bcel.internal.generic.InstructionList; //导入方法依赖的package包/类
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
/*
* To fix bug 24518 related to setting parameters of the form
* {namespaceuri}localName, which will get mapped to an instance
* variable in the class.
*/
final String name = BasisLibrary.mapQNameToJavaName (_name.toString());
final String signature = _type.toSignature();
if (_variable.isLocal()) {
if (classGen.isExternal()) {
Closure variableClosure = _closure;
while (variableClosure != null) {
if (variableClosure.inInnerClass()) break;
variableClosure = variableClosure.getParentClosure();
}
if (variableClosure != null) {
il.append(ALOAD_0);
il.append(new GETFIELD(
cpg.addFieldref(variableClosure.getInnerClassName(),
name, signature)));
}
else {
il.append(_variable.loadInstruction());
}
}
else {
il.append(_variable.loadInstruction());
}
}
else {
final String className = classGen.getClassName();
il.append(classGen.loadTranslet());
if (classGen.isExternal()) {
il.append(new CHECKCAST(cpg.addClass(className)));
}
il.append(new GETFIELD(cpg.addFieldref(className,name,signature)));
}
if (_variable.getType() instanceof NodeSetType) {
// The method cloneIterator() also does resetting
final int clone = cpg.addInterfaceMethodref(NODE_ITERATOR,
"cloneIterator",
"()" +
NODE_ITERATOR_SIG);
il.append(new INVOKEINTERFACE(clone, 1));
}
}
示例15: translate
import com.sun.org.apache.bcel.internal.generic.InstructionList; //导入方法依赖的package包/类
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
final LocalVariableGen local =
methodGen.addLocalVariable2("ppt",
Util.getJCRefType(NODE_SIG),
null);
final com.sun.org.apache.bcel.internal.generic.Instruction loadLocal =
new ILOAD(local.getIndex());
final com.sun.org.apache.bcel.internal.generic.Instruction storeLocal =
new ISTORE(local.getIndex());
if (_right.isWildcard()) {
il.append(methodGen.loadDOM());
il.append(SWAP);
}
else if (_right instanceof StepPattern) {
il.append(DUP);
local.setStart(il.append(storeLocal));
_right.translate(classGen, methodGen);
il.append(methodGen.loadDOM());
local.setEnd(il.append(loadLocal));
}
else {
_right.translate(classGen, methodGen);
if (_right instanceof AncestorPattern) {
il.append(methodGen.loadDOM());
il.append(SWAP);
}
}
final int getParent = cpg.addInterfaceMethodref(DOM_INTF,
GET_PARENT,
GET_PARENT_SIG);
il.append(new INVOKEINTERFACE(getParent, 2));
final SyntaxTreeNode p = getParent();
if (p == null || p instanceof Instruction ||
p instanceof TopLevelElement)
{
_left.translate(classGen, methodGen);
}
else {
il.append(DUP);
InstructionHandle storeInst = il.append(storeLocal);
if (local.getStart() == null) {
local.setStart(storeInst);
}
_left.translate(classGen, methodGen);
il.append(methodGen.loadDOM());
local.setEnd(il.append(loadLocal));
}
methodGen.removeLocalVariable(local);
/*
* If _right is an ancestor pattern, backpatch _left false
* list to the loop that searches for more ancestors.
*/
if (_right instanceof AncestorPattern) {
final AncestorPattern ancestor = (AncestorPattern) _right;
_left.backPatchFalseList(ancestor.getLoopHandle()); // clears list
}
_trueList.append(_right._trueList.append(_left._trueList));
_falseList.append(_right._falseList.append(_left._falseList));
}