本文整理汇总了Java中com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator.getConstantPool方法的典型用法代码示例。如果您正苦于以下问题:Java ClassGenerator.getConstantPool方法的具体用法?Java ClassGenerator.getConstantPool怎么用?Java ClassGenerator.getConstantPool使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator
的用法示例。
在下文中一共展示了ClassGenerator.getConstantPool方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: translate
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; //导入方法依赖的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));
}
示例2: translateValue
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; //导入方法依赖的package包/类
/**
* Compile the value of the parameter, which is either in an expression in
* a 'select' attribute, or in the with-param element's body
*/
public void translateValue(ClassGenerator classGen,
MethodGenerator methodGen) {
// Compile expression is 'select' attribute if present
if (_select != null) {
_select.translate(classGen, methodGen);
_select.startIterator(classGen, methodGen);
}
// If not, compile result tree from parameter body if present.
else if (hasContents()) {
compileResultTree(classGen, methodGen);
}
// If neither are present then store empty string in parameter slot
else {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
il.append(new PUSH(cpg, Constants.EMPTYSTRING));
}
}
示例3: translate
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; //导入方法依赖的package包/类
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
final InstructionList il = methodGen.getInstructionList();
if (methodGen instanceof CompareGenerator) {
il.append(((CompareGenerator)methodGen).loadCurrentNode());
}
else if (methodGen instanceof TestGenerator) {
il.append(new ILOAD(POSITION_INDEX));
}
else {
final ConstantPoolGen cpg = classGen.getConstantPool();
final int index = cpg.addInterfaceMethodref(NODE_ITERATOR,
"getPosition",
"()I");
il.append(methodGen.loadIterator());
il.append(new INVOKEINTERFACE(index,1));
}
}
示例4: translate
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; //导入方法依赖的package包/类
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
if (hasPredicates()) {
switch (_contextCase) {
case NO_CONTEXT:
translateNoContext(classGen, methodGen);
break;
case SIMPLE_CONTEXT:
translateSimpleContext(classGen, methodGen);
break;
default:
translateGeneralContext(classGen, methodGen);
break;
}
}
else if (isWildcard()) {
il.append(POP); // true list falls through
}
else {
translateKernel(classGen, methodGen);
}
}
示例5: translate
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; //导入方法依赖的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 name of a node in the DOM
final int getNodeName = cpg.addInterfaceMethodref(DOM_INTF,
"getNodeName",
"(I)"+STRING_SIG);
final int getLocalName = cpg.addMethodref(BASIS_LIBRARY_CLASS,
"getLocalName",
"(Ljava/lang/String;)"+
"Ljava/lang/String;");
super.translate(classGen, methodGen);
il.append(new INVOKEINTERFACE(getNodeName, 2));
il.append(new INVOKESTATIC(getLocalName));
}
示例6: translate
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; //导入方法依赖的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));
}
示例7: translate
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; //导入方法依赖的package包/类
/**
* Translate code that leaves a node's namespace URI (as a String)
* on the stack
*/
public void translate(ClassGenerator classGen,
MethodGenerator methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
// Returns the string value for a node in the DOM
final int getNamespace = cpg.addInterfaceMethodref(DOM_INTF,
"getNamespaceName",
"(I)"+STRING_SIG);
super.translate(classGen, methodGen);
il.append(new INVOKEINTERFACE(getNamespace, 2));
}
示例8: translate
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; //导入方法依赖的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: translate
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; //导入方法依赖的package包/类
/**
* Translate the code required for getting the node for which the
* QName, local-name or namespace URI should be extracted.
*/
public void translate(ClassGenerator classGen,
MethodGenerator methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
il.append(methodGen.loadDOM());
// Function was called with no parameters
if (argumentCount() == 0) {
il.append(methodGen.loadContextNode());
}
// Function was called with node parameter
else if (_paramType == Type.Node) {
_param.translate(classGen, methodGen);
}
else if (_paramType == Type.Reference) {
_param.translate(classGen, methodGen);
il.append(new INVOKESTATIC(cpg.addMethodref
(BASIS_LIBRARY_CLASS,
"referenceToNodeSet",
"("
+ OBJECT_SIG
+ ")"
+ NODE_ITERATOR_SIG)));
il.append(methodGen.nextNode());
}
// Function was called with node-set parameter
else {
_param.translate(classGen, methodGen);
_param.startIterator(classGen, methodGen);
il.append(methodGen.nextNode());
}
}
示例10: translate
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; //导入方法依赖的package包/类
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
_right.translate(classGen, methodGen);
il.append(new CHECKCAST(cpg.addClass(_className)));
}
示例11: translate
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; //导入方法依赖的package包/类
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
final LocalVariableGen name =
methodGen.addLocalVariable2("name",
Util.getJCRefType(STRING_SIG),
null);
final LocalVariableGen length =
methodGen.addLocalVariable2("length",
Util.getJCRefType("I"),
null);
// Get the name of the node to copy and save for later
il.append(methodGen.loadDOM());
il.append(methodGen.loadCurrentNode());
il.append(methodGen.loadHandler());
final int cpy = cpg.addInterfaceMethodref(DOM_INTF,
"shallowCopy",
"("
+ NODE_SIG
+ TRANSLET_OUTPUT_SIG
+ ")" + STRING_SIG);
il.append(new INVOKEINTERFACE(cpy, 3));
il.append(DUP);
name.setStart(il.append(new ASTORE(name.getIndex())));
final BranchHandle ifBlock1 = il.append(new IFNULL(null));
// Get the length of the node name and save for later
il.append(new ALOAD(name.getIndex()));
final int lengthMethod = cpg.addMethodref(STRING_CLASS,"length","()I");
il.append(new INVOKEVIRTUAL(lengthMethod));
il.append(DUP);
length.setStart(il.append(new ISTORE(length.getIndex())));
// Ignore attribute sets if current node is ROOT. DOM.shallowCopy()
// returns "" for ROOT, so skip attribute sets if length == 0
final BranchHandle ifBlock4 = il.append(new IFEQ(null));
// Copy in attribute sets if specified
if (_useSets != null) {
// If the parent of this element will result in an element being
// output then we know that it is safe to copy out the attributes
final SyntaxTreeNode parent = getParent();
if ((parent instanceof LiteralElement) ||
(parent instanceof LiteralElement)) {
_useSets.translate(classGen, methodGen);
}
// If not we have to check to see if the copy will result in an
// element being output.
else {
// check if element; if not skip to translate body
il.append(new ILOAD(length.getIndex()));
final BranchHandle ifBlock2 = il.append(new IFEQ(null));
// length != 0 -> element -> do attribute sets
_useSets.translate(classGen, methodGen);
// not an element; root
ifBlock2.setTarget(il.append(NOP));
}
}
// Instantiate body of xsl:copy
ifBlock4.setTarget(il.append(NOP));
translateContents(classGen, methodGen);
// Call the output handler's endElement() if we copied an element
// (The DOM.shallowCopy() method calls startElement().)
length.setEnd(il.append(new ILOAD(length.getIndex())));
final BranchHandle ifBlock3 = il.append(new IFEQ(null));
il.append(methodGen.loadHandler());
name.setEnd(il.append(new ALOAD(name.getIndex())));
il.append(methodGen.endElement());
final InstructionHandle end = il.append(NOP);
ifBlock1.setTarget(end);
ifBlock3.setTarget(end);
methodGen.removeLocalVariable(name);
methodGen.removeLocalVariable(length);
}
示例12: compileNamedTemplate
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; //导入方法依赖的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: translateSortIterator
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; //导入方法依赖的package包/类
/**
* Compiles code that instantiates a SortingIterator object.
* This object's constructor needs referencdes to the current iterator
* and a node sort record producing objects as its parameters.
*/
public static void translateSortIterator(ClassGenerator classGen,
MethodGenerator methodGen,
Expression nodeSet,
Vector<Sort> sortObjects)
{
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
// SortingIterator.SortingIterator(NodeIterator,NodeSortRecordFactory);
final int init = cpg.addMethodref(SORT_ITERATOR, "<init>",
"("
+ NODE_ITERATOR_SIG
+ NODE_SORT_FACTORY_SIG
+ ")V");
// Backwards branches are prohibited if an uninitialized object is
// on the stack by section 4.9.4 of the JVM Specification, 2nd Ed.
// We don't know whether this code might contain backwards branches
// so we mustn't create the new object until after we've created
// the suspect arguments to its constructor. Instead we calculate
// the values of the arguments to the constructor first, store them
// in temporary variables, create the object and reload the
// arguments from the temporaries to avoid the problem.
LocalVariableGen nodesTemp =
methodGen.addLocalVariable("sort_tmp1",
Util.getJCRefType(NODE_ITERATOR_SIG),
null, null);
LocalVariableGen sortRecordFactoryTemp =
methodGen.addLocalVariable("sort_tmp2",
Util.getJCRefType(NODE_SORT_FACTORY_SIG),
null, null);
// Get the current node iterator
if (nodeSet == null) { // apply-templates default
final int children = cpg.addInterfaceMethodref(DOM_INTF,
"getAxisIterator",
"(I)"+
NODE_ITERATOR_SIG);
il.append(methodGen.loadDOM());
il.append(new PUSH(cpg, Axis.CHILD));
il.append(new INVOKEINTERFACE(children, 2));
}
else {
nodeSet.translate(classGen, methodGen);
}
nodesTemp.setStart(il.append(new ASTORE(nodesTemp.getIndex())));
// Compile the code for the NodeSortRecord producing class and pass
// that as the last argument to the SortingIterator constructor.
compileSortRecordFactory(sortObjects, classGen, methodGen);
sortRecordFactoryTemp.setStart(
il.append(new ASTORE(sortRecordFactoryTemp.getIndex())));
il.append(new NEW(cpg.addClass(SORT_ITERATOR)));
il.append(DUP);
nodesTemp.setEnd(il.append(new ALOAD(nodesTemp.getIndex())));
sortRecordFactoryTemp.setEnd(
il.append(new ALOAD(sortRecordFactoryTemp.getIndex())));
il.append(new INVOKESPECIAL(init));
}
示例14: translateDefaultDFS
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; //导入方法依赖的package包/类
/**
* Creates the default, nameless, DecimalFormat object in
* AbstractTranslet's format_symbols hashtable.
* This should be called for every stylesheet, and the entry
* may be overridden by later nameless xsl:decimal-format instructions.
*/
public static void translateDefaultDFS(ClassGenerator classGen,
MethodGenerator methodGen) {
ConstantPoolGen cpg = classGen.getConstantPool();
InstructionList il = methodGen.getInstructionList();
final int init = cpg.addMethodref(DFS_CLASS, "<init>",
"("+LOCALE_SIG+")V");
// Push the format name, which is empty, on the stack
// for call to addDecimalFormat()
il.append(classGen.loadTranslet());
il.append(new PUSH(cpg, EMPTYSTRING));
// Manufacture a DecimalFormatSymbols on the stack for
// call to addDecimalFormat(). Use the US Locale as the
// default, as most of its settings are equivalent to
// the default settings required of xsl:decimal-format -
// except for the NaN and infinity attributes.
il.append(new NEW(cpg.addClass(DFS_CLASS)));
il.append(DUP);
il.append(new GETSTATIC(cpg.addFieldref(LOCALE_CLASS, "US",
LOCALE_SIG)));
il.append(new INVOKESPECIAL(init));
int nan = cpg.addMethodref(DFS_CLASS,
"setNaN", "(Ljava/lang/String;)V");
il.append(DUP);
il.append(new PUSH(cpg, "NaN"));
il.append(new INVOKEVIRTUAL(nan));
int inf = cpg.addMethodref(DFS_CLASS,
"setInfinity",
"(Ljava/lang/String;)V");
il.append(DUP);
il.append(new PUSH(cpg, "Infinity"));
il.append(new INVOKEVIRTUAL(inf));
final int put = cpg.addMethodref(TRANSLET_CLASS,
"addDecimalFormat",
"("+STRING_SIG+DFS_SIG+")V");
il.append(new INVOKEVIRTUAL(put));
}
示例15: translate
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; //导入方法依赖的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());
}
}