本文整理汇总了Java中com.sun.org.apache.bcel.internal.generic.ConstantPoolGen.addMethodref方法的典型用法代码示例。如果您正苦于以下问题:Java ConstantPoolGen.addMethodref方法的具体用法?Java ConstantPoolGen.addMethodref怎么用?Java ConstantPoolGen.addMethodref使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.org.apache.bcel.internal.generic.ConstantPoolGen
的用法示例。
在下文中一共展示了ConstantPoolGen.addMethodref方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: translate
import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; //导入方法依赖的package包/类
/**
* Translate the fallback element (if any).
*/
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
if (_fallbacks != null) {
int count = _fallbacks.size();
for (int i = 0; i < count; i++) {
Fallback fallback = (Fallback)_fallbacks.elementAt(i);
fallback.translate(classGen, methodGen);
}
}
// We only go into the else block in forward-compatibility mode, when
// the unsupported element has no fallback.
else {
// If the unsupported element does not have any fallback child, then
// at runtime, a runtime error should be raised when the unsupported
// element is instantiated. Otherwise, no error is thrown.
ConstantPoolGen cpg = classGen.getConstantPool();
InstructionList il = methodGen.getInstructionList();
final int unsupportedElem = cpg.addMethodref(BASIS_LIBRARY_CLASS, "unsupported_ElementF",
"(" + STRING_SIG + "Z)V");
il.append(new PUSH(cpg, getQName().toString()));
il.append(new PUSH(cpg, _isExtension));
il.append(new INVOKESTATIC(unsupportedElem));
}
}
示例2: compileDefaultRecursion
import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; //导入方法依赖的package包/类
/**
* Compiles the default handling for DOM elements: traverse all children
*/
private InstructionList compileDefaultRecursion(ClassGenerator classGen,
MethodGenerator methodGen,
InstructionHandle next) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = new InstructionList();
final String applyTemplatesSig = classGen.getApplyTemplatesSig();
final int git = cpg.addInterfaceMethodref(DOM_INTF,
GET_CHILDREN,
GET_CHILDREN_SIG);
final int applyTemplates = cpg.addMethodref(getClassName(),
functionName(),
applyTemplatesSig);
il.append(classGen.loadTranslet());
il.append(methodGen.loadDOM());
il.append(methodGen.loadDOM());
il.append(new ILOAD(_currentIndex));
il.append(new INVOKEINTERFACE(git, 2));
il.append(methodGen.loadHandler());
il.append(new INVOKEVIRTUAL(applyTemplates));
il.append(new GOTO_W(next));
return il;
}
示例3: unmapRegister
import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; //导入方法依赖的package包/类
/**
* Remove the mapping of this variable to a register.
* Called when we leave the AST scope of the variable's declaration
*/
public void unmapRegister(ClassGenerator classGen, MethodGenerator methodGen) {
if (_local != null) {
if (_type instanceof ResultTreeType) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
if (classGen.getStylesheet().callsNodeset() && classGen.getDOMClass().equals(MULTI_DOM_CLASS)) {
final int removeDA = cpg.addMethodref(MULTI_DOM_CLASS, "removeDOMAdapter", "(" + DOM_ADAPTER_SIG + ")V");
il.append(methodGen.loadDOM());
il.append(new CHECKCAST(cpg.addClass(MULTI_DOM_CLASS)));
il.append(loadInstruction());
il.append(new CHECKCAST(cpg.addClass(DOM_ADAPTER_CLASS)));
il.append(new INVOKEVIRTUAL(removeDA));
}
final int release = cpg.addInterfaceMethodref(DOM_IMPL_CLASS, "release", "()V");
il.append(loadInstruction());
il.append(new INVOKEINTERFACE(release, 1));
}
_local.setEnd(methodGen.getInstructionList().getEnd());
methodGen.removeLocalVariable(_local);
_refs = null;
_local = null;
}
}
示例4: translateTo
import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; //导入方法依赖的package包/类
/**
* Casts a reference into a NodeIterator.
*
* @see com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
*/
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
NodeSetType type) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
int index = cpg.addMethodref(BASIS_LIBRARY_CLASS, "referenceToNodeSet",
"("
+ OBJECT_SIG
+ ")"
+ NODE_ITERATOR_SIG);
il.append(new INVOKESTATIC(index));
// Reset this iterator
index = cpg.addInterfaceMethodref(NODE_ITERATOR, RESET, RESET_SIG);
il.append(new INVOKEINTERFACE(index, 1));
}
示例5: translate
import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; //导入方法依赖的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));
}
示例6: translateTo
import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; //导入方法依赖的package包/类
/**
* Expects a node on the stack and pushes a singleton node-set. Singleton
* iterators are already started after construction.
*
* @see com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
*/
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
NodeSetType type) {
ConstantPoolGen cpg = classGen.getConstantPool();
InstructionList il = methodGen.getInstructionList();
// Create a new instance of SingletonIterator
il.append(new NEW(cpg.addClass(SINGLETON_ITERATOR)));
il.append(DUP_X1);
il.append(SWAP);
final int init = cpg.addMethodref(SINGLETON_ITERATOR, "<init>",
"(" + NODE_SIG +")V");
il.append(new INVOKESPECIAL(init));
}
示例7: translate
import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; //导入方法依赖的package包/类
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
if (hasNodeSetArgs() || hasReferenceArgs()) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
// Call compare() from the BasisLibrary
_left.translate(classGen, methodGen);
_left.startIterator(classGen, methodGen);
_right.translate(classGen, methodGen);
_right.startIterator(classGen, methodGen);
il.append(new PUSH(cpg, _op));
il.append(methodGen.loadDOM());
int index = cpg.addMethodref(BASIS_LIBRARY_CLASS, "compare",
"("
+ _left.getType().toSignature()
+ _right.getType().toSignature()
+ "I"
+ DOM_INTF_SIG
+ ")Z");
il.append(new INVOKESTATIC(index));
}
else {
translateDesynthesized(classGen, methodGen);
synthesize(classGen, methodGen);
}
}
示例8: translate
import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; //导入方法依赖的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);
}
}
}
示例9: translateTo
import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; //导入方法依赖的package包/类
/**
* Casts a reference into a ResultTree.
*
* @see com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
*/
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
ResultTreeType type) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
int index = cpg.addMethodref(BASIS_LIBRARY_CLASS, "referenceToResultTree",
"(" + OBJECT_SIG + ")" + DOM_INTF_SIG);
il.append(new INVOKESTATIC(index));
}
示例10: generateAddReads
import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; //导入方法依赖的package包/类
private void generateAddReads(ClassGenerator classGen, MethodGenerator methodGen,
String clazz) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
// Generate call to Module.addReads:
// <TransletClass>.class.getModule().addReads(
// Class.forName(<clazz>).getModule());
// Class.forName may throw ClassNotFoundException.
// This is OK as it will caught higher up the stack in
// TransformerImpl.transform() and wrapped into a
// TransformerException.
methodGen.markChunkStart();
int index = cpg.addMethodref(CLASS_CLASS,
GET_MODULE,
GET_MODULE_SIG);
int index2 = cpg.addMethodref(CLASS_CLASS,
FOR_NAME,
FOR_NAME_SIG);
il.append(new LDC(cpg.addString(classGen.getClassName())));
il.append(new INVOKESTATIC(index2));
il.append(new INVOKEVIRTUAL(index));
il.append(new LDC(cpg.addString(clazz)));
il.append(new INVOKESTATIC(index2));
il.append(new INVOKEVIRTUAL(index));
index = cpg.addMethodref(MODULE_CLASS,
ADD_READS,
ADD_READS_SIG);
il.append(new INVOKEVIRTUAL(index));
il.append(InstructionConst.POP);
methodGen.markChunkEnd();
}
示例11: translateUnallowedExtension
import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; //导入方法依赖的package包/类
/**
* Translate code to call the BasisLibrary.unallowed_extensionF(String)
* method.
*/
private void translateUnallowedExtension(ConstantPoolGen cpg,
InstructionList il) {
int index = cpg.addMethodref(BASIS_LIBRARY_CLASS,
"unallowed_extension_functionF",
"(Ljava/lang/String;)V");
il.append(new PUSH(cpg, _fname.toString()));
il.append(new INVOKESTATIC(index));
}
示例12: translate
import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; //导入方法依赖的package包/类
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
if (!_isLiteral) {
// if the ncname is an AVT, then the ncname has to be checked at runtime if it is a valid ncname
LocalVariableGen nameValue =
methodGen.addLocalVariable2("nameValue",
Util.getJCRefType(STRING_SIG),
null);
// store the name into a variable first so _name.translate only needs to be called once
_name.translate(classGen, methodGen);
nameValue.setStart(il.append(new ASTORE(nameValue.getIndex())));
il.append(new ALOAD(nameValue.getIndex()));
// call checkNCName if the name is an AVT
final int check = cpg.addMethodref(BASIS_LIBRARY_CLASS, "checkNCName",
"("
+STRING_SIG
+")V");
il.append(new INVOKESTATIC(check));
// Save the current handler base on the stack
il.append(methodGen.loadHandler());
il.append(DUP); // first arg to "attributes" call
// load name value again
nameValue.setEnd(il.append(new ALOAD(nameValue.getIndex())));
} else {
// Save the current handler base on the stack
il.append(methodGen.loadHandler());
il.append(DUP); // first arg to "attributes" call
// Push attribute name
_name.translate(classGen, methodGen);// 2nd arg
}
il.append(classGen.loadTranslet());
il.append(new GETFIELD(cpg.addFieldref(TRANSLET_CLASS,
"stringValueHandler",
STRING_VALUE_HANDLER_SIG)));
il.append(DUP);
il.append(methodGen.storeHandler());
// translate contents with substituted handler
translateContents(classGen, methodGen);
// get String out of the handler
il.append(new INVOKEVIRTUAL(cpg.addMethodref(STRING_VALUE_HANDLER,
"getValueOfPI",
"()" + STRING_SIG)));
// call "processingInstruction"
final int processingInstruction =
cpg.addInterfaceMethodref(TRANSLET_OUTPUT_INTERFACE,
"processingInstruction",
"(" + STRING_SIG + STRING_SIG + ")V");
il.append(new INVOKEINTERFACE(processingInstruction, 3));
// Restore old handler base from stack
il.append(methodGen.storeHandler());
}
示例13: translate
import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; //导入方法依赖的package包/类
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
final Type tselect = _select.getType();
final String CPY1_SIG = "("+NODE_ITERATOR_SIG+TRANSLET_OUTPUT_SIG+")V";
final int cpy1 = cpg.addInterfaceMethodref(DOM_INTF, "copy", CPY1_SIG);
final String CPY2_SIG = "("+NODE_SIG+TRANSLET_OUTPUT_SIG+")V";
final int cpy2 = cpg.addInterfaceMethodref(DOM_INTF, "copy", CPY2_SIG);
final String getDoc_SIG = "()"+NODE_SIG;
final int getDoc = cpg.addInterfaceMethodref(DOM_INTF, "getDocument", getDoc_SIG);
if (tselect instanceof NodeSetType) {
il.append(methodGen.loadDOM());
// push NodeIterator
_select.translate(classGen, methodGen);
_select.startIterator(classGen, methodGen);
// call copy from the DOM 'library'
il.append(methodGen.loadHandler());
il.append(new INVOKEINTERFACE(cpy1, 3));
}
else if (tselect instanceof NodeType) {
il.append(methodGen.loadDOM());
_select.translate(classGen, methodGen);
il.append(methodGen.loadHandler());
il.append(new INVOKEINTERFACE(cpy2, 3));
}
else if (tselect instanceof ResultTreeType) {
_select.translate(classGen, methodGen);
// We want the whole tree, so we start with the root node
il.append(DUP); //need a pointer to the DOM ;
il.append(new INVOKEINTERFACE(getDoc,1)); //ICONST_0);
il.append(methodGen.loadHandler());
il.append(new INVOKEINTERFACE(cpy2, 3));
}
else if (tselect instanceof ReferenceType) {
_select.translate(classGen, methodGen);
il.append(methodGen.loadHandler());
il.append(methodGen.loadCurrentNode());
il.append(methodGen.loadDOM());
final int copy = cpg.addMethodref(BASIS_LIBRARY_CLASS, "copy",
"("
+ OBJECT_SIG
+ TRANSLET_OUTPUT_SIG
+ NODE_SIG
+ DOM_INTF_SIG
+ ")V");
il.append(new INVOKESTATIC(copy));
}
else {
il.append(classGen.loadTranslet());
_select.translate(classGen, methodGen);
il.append(methodGen.loadHandler());
il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS,
CHARACTERSW,
CHARACTERSW_SIG)));
}
}
示例14: translate
import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; //导入方法依赖的package包/类
/**
* At runtime the compilation of xsl:element results in code that: (i)
* evaluates the avt for the name, (ii) checks for a prefix in the name
* (iii) generates a new prefix and create a new qname when necessary
* (iv) calls startElement() on the handler (v) looks up a uri in the XML
* when the prefix is not known at compile time (vi) calls namespace()
* on the handler (vii) evaluates the contents (viii) calls endElement().
*/
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
LocalVariableGen local = null;
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
// Optimize translation if element name is a literal
if (_isLiteralName) {
translateLiteral(classGen, methodGen);
return;
}
if (!_ignore) {
// if the qname is an AVT, then the qname has to be checked at runtime if it is a valid qname
LocalVariableGen nameValue =
methodGen.addLocalVariable2("nameValue",
Util.getJCRefType(STRING_SIG),
null);
// store the name into a variable first so _name.translate only needs to be called once
_name.translate(classGen, methodGen);
nameValue.setStart(il.append(new ASTORE(nameValue.getIndex())));
il.append(new ALOAD(nameValue.getIndex()));
// call checkQName if the name is an AVT
final int check = cpg.addMethodref(BASIS_LIBRARY_CLASS, "checkQName",
"("
+STRING_SIG
+")V");
il.append(new INVOKESTATIC(check));
// Push handler for call to endElement()
il.append(methodGen.loadHandler());
// load name value again
nameValue.setEnd(il.append(new ALOAD(nameValue.getIndex())));
if (_namespace != null) {
_namespace.translate(classGen, methodGen);
}
else {
il.append(ACONST_NULL);
}
// Push additional arguments
il.append(methodGen.loadHandler());
il.append(methodGen.loadDOM());
il.append(methodGen.loadCurrentNode());
// Invoke BasisLibrary.startXslElemCheckQName()
il.append(new INVOKESTATIC(
cpg.addMethodref(BASIS_LIBRARY_CLASS, "startXslElement",
"(" + STRING_SIG
+ STRING_SIG
+ TRANSLET_OUTPUT_SIG
+ DOM_INTF_SIG + "I)" + STRING_SIG)));
}
translateContents(classGen, methodGen);
if (!_ignore) {
il.append(methodGen.endElement());
}
}
示例15: translate
import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; //导入方法依赖的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();
// Returns the KeyIndex object of a given name
final int getKeyIndex = cpg.addMethodref(TRANSLET_CLASS,
"getKeyIndex",
"(Ljava/lang/String;)"+
KEY_INDEX_SIG);
// Initialises a KeyIndex to return nodes with specific values
final int lookupId = cpg.addMethodref(KEY_INDEX_CLASS,
"containsID",
"(ILjava/lang/Object;)I");
final int lookupKey = cpg.addMethodref(KEY_INDEX_CLASS,
"containsKey",
"(ILjava/lang/Object;)I");
final int getNodeIdent = cpg.addInterfaceMethodref(DOM_INTF,
"getNodeIdent",
"(I)"+NODE_SIG);
// Call getKeyIndex in AbstractTranslet with the name of the key
// to get the index for this key (which is also a node iterator).
il.append(classGen.loadTranslet());
il.append(new PUSH(cpg,_index));
il.append(new INVOKEVIRTUAL(getKeyIndex));
// Now use the value in the second argument to determine what nodes
// the iterator should return.
il.append(SWAP);
il.append(new PUSH(cpg,_value));
if (this instanceof IdPattern)
{
il.append(new INVOKEVIRTUAL(lookupId));
}
else
{
il.append(new INVOKEVIRTUAL(lookupKey));
}
_trueList.add(il.append(new IFNE(null)));
_falseList.add(il.append(new GOTO(null)));
}