本文整理汇总了Java中com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator类的典型用法代码示例。如果您正苦于以下问题:Java ClassGenerator类的具体用法?Java ClassGenerator怎么用?Java ClassGenerator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClassGenerator类属于com.sun.org.apache.xalan.internal.xsltc.compiler.util包,在下文中一共展示了ClassGenerator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compileDefaultRecursion
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; //导入依赖的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;
}
示例2: 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));
}
示例3: translateContents
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; //导入依赖的package包/类
/**
* Call translate() on all child syntax tree nodes.
* @param classGen BCEL Java class generator
* @param methodGen BCEL Java method generator
*/
protected void translateContents(ClassGenerator classGen,
MethodGenerator methodGen) {
// Call translate() on all child nodes
final int n = elementCount();
for (int i = 0; i < n; i++) {
methodGen.markChunkStart();
final SyntaxTreeNode item = (SyntaxTreeNode)_contents.elementAt(i);
item.translate(classGen, methodGen);
methodGen.markChunkEnd();
}
// After translation, unmap any registers for any variables/parameters
// that were declared in this scope. Performing this unmapping in the
// same AST scope as the declaration deals with the problems of
// references falling out-of-scope inside the for-each element.
// (the cause of which being 'lazy' register allocation for references)
for (int i = 0; i < n; i++) {
if( _contents.elementAt(i) instanceof VariableBase) {
final VariableBase var = (VariableBase)_contents.elementAt(i);
var.unmapRegister(methodGen);
}
}
}
示例4: 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();
Type targ;
if (argumentCount() == 0) {
il.append(methodGen.loadContextNode());
targ = Type.Node;
}
else {
final Expression arg = argument();
arg.translate(classGen, methodGen);
arg.startIterator(classGen, methodGen);
targ = arg.getType();
}
if (!targ.identicalTo(Type.Real)) {
targ.translateTo(classGen, methodGen, Type.Real);
}
}
示例5: loadAsArrayOffsetLength
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; //导入依赖的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()));
}
示例6: 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).loadLastNode());
}
else if (methodGen instanceof TestGenerator) {
il.append(new ILOAD(LAST_INDEX));
}
else {
final ConstantPoolGen cpg = classGen.getConstantPool();
final int getLast = cpg.addInterfaceMethodref(NODE_ITERATOR,
"getLast",
"()I");
il.append(methodGen.loadIterator());
il.append(new INVOKEINTERFACE(getLast, 1));
}
}
示例7: translateLiteral
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; //导入依赖的package包/类
/**
* This method is called when the name of the element is known at compile time.
* In this case, there is no need to inspect the element name at runtime to
* determine if a prefix exists, needs to be generated, etc.
*/
public void translateLiteral(ClassGenerator classGen, MethodGenerator methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
if (!_ignore) {
il.append(methodGen.loadHandler());
_name.translate(classGen, methodGen);
il.append(DUP2);
il.append(methodGen.startElement());
if (_namespace != null) {
il.append(methodGen.loadHandler());
il.append(new PUSH(cpg, _prefix));
_namespace.translate(classGen,methodGen);
il.append(methodGen.namespace());
}
}
translateContents(classGen, methodGen);
if (!_ignore) {
il.append(methodGen.endElement());
}
}
示例8: compileTemplateCalls
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; //导入依赖的package包/类
private void compileTemplateCalls(ClassGenerator classGen,
MethodGenerator methodGen,
InstructionHandle next, int min, int max){
_neededTemplates.keySet().stream().forEach((template) -> {
final int prec = template.getImportPrecedence();
if ((prec >= min) && (prec < max)) {
if (template.hasContents()) {
InstructionList til = template.compile(classGen, methodGen);
til.append(new GOTO_W(next));
_templateILs.put(template, til);
_templateIHs.put(template, til.getStart());
}
else {
// empty template
_templateIHs.put(template, next);
}
}
});
}
示例9: translateContents
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; //导入依赖的package包/类
/**
* Call translate() on all child syntax tree nodes.
* @param classGen BCEL Java class generator
* @param methodGen BCEL Java method generator
*/
protected void translateContents(ClassGenerator classGen,
MethodGenerator methodGen) {
// Call translate() on all child nodes
final int n = elementCount();
for (SyntaxTreeNode item : _contents) {
methodGen.markChunkStart();
item.translate(classGen, methodGen);
methodGen.markChunkEnd();
}
// After translation, unmap any registers for any variables/parameters
// that were declared in this scope. Performing this unmapping in the
// same AST scope as the declaration deals with the problems of
// references falling out-of-scope inside the for-each element.
// (the cause of which being 'lazy' register allocation for references)
for (int i = 0; i < n; i++) {
if ( _contents.get(i) instanceof VariableBase) {
final VariableBase var = (VariableBase)_contents.get(i);
var.unmapRegister(classGen, methodGen);
}
}
}
示例10: compileDefaultText
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; //导入依赖的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;
}
示例11: translate
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; //导入依赖的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));
}
}
示例12: 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();
Type targ;
if (argumentCount() == 0) {
il.append(methodGen.loadContextNode());
targ = Type.Node;
}
else {
final Expression arg = argument();
arg.translate(classGen, methodGen);
arg.startIterator(classGen, methodGen);
targ = arg.getType();
}
if (!targ.identicalTo(Type.String)) {
targ.translateTo(classGen, methodGen, Type.String);
}
}
示例13: 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();
_value.translate(classGen, methodGen);
_format.translate(classGen, methodGen);
final int fn3arg = cpg.addMethodref(BASIS_LIBRARY_CLASS,
"formatNumber",
"(DLjava/lang/String;"+
"Ljava/text/DecimalFormat;)"+
"Ljava/lang/String;");
final int get = cpg.addMethodref(TRANSLET_CLASS,
"getDecimalFormat",
"(Ljava/lang/String;)"+
"Ljava/text/DecimalFormat;");
il.append(classGen.loadTranslet());
if (_name == null) {
il.append(new PUSH(cpg, EMPTYSTRING));
}
else if (_resolvedQName != null) {
il.append(new PUSH(cpg, _resolvedQName.toString()));
}
else {
_name.translate(classGen, methodGen);
}
il.append(new INVOKEVIRTUAL(get));
il.append(new INVOKESTATIC(fn3arg));
}
示例14: compileGetChildren
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; //导入依赖的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));
}
示例15: translate
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; //导入依赖的package包/类
/**
* Translate contents only if this fallback element is put in place of
* some unsupported element or non-XSLTC extension element
*/
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
if (_active) translateContents(classGen, methodGen);
}