// Push parameter frame
final int push = cpg.addMethodref(TRANSLET_CLASS,
PUSH_PARAM_FRAME,
PUSH_PARAM_FRAME_SIG);
il.append(classGen.loadTranslet());
il.append(new INVOKEVIRTUAL(push));
translateContents(classGen, methodGen);
}
}
// Generate a valid Java method name
final String className = stylesheet.getClassName();
String methodName = Util.escape(_name.toString());
// Load standard arguments
il.append(classGen.loadTranslet());
il.append(methodGen.loadDOM());
il.append(methodGen.loadIterator());
il.append(methodGen.loadHandler());
il.append(methodGen.loadCurrentNode());
// Initialize prefix of method signature
StringBuffer methodSig = new StringBuffer("(" + DOM_INTF_SIG
+ NODE_ITERATOR_SIG + TRANSLET_OUTPUT_SIG + NODE_SIG);
// If calling a simply named template, push actual arguments
if (_calleeTemplate != null) {
Vector calleeParams = _calleeTemplate.getParameters();
int numParams = _parameters.length;
for (int i = 0; i < numParams; i++) {
SyntaxTreeNode node = (SyntaxTreeNode)_parameters[i];
methodSig.append(OBJECT_SIG); // append Object to signature
// Push 'null' if Param to indicate no actual parameter specified
if (node instanceof Param) {
il.append(ACONST_NULL);
}
else { // translate WithParam
node.translate(classGen, methodGen);
}
}
}
// Complete signature and generate invokevirtual call
methodSig.append(")V");
il.append(new INVOKEVIRTUAL(cpg.addMethodref(className,
methodName,
methodSig.toString())));
// Do not need to call Translet.popParamFrame() if we are
// calling a simple named template.
if (_calleeTemplate == null && (stylesheet.hasLocalParams() || hasContents())) {
// Pop parameter frame
final int pop = cpg.addMethodref(TRANSLET_CLASS,
POP_PARAM_FRAME,
POP_PARAM_FRAME_SIG);
il.append(classGen.loadTranslet());
il.append(new INVOKEVIRTUAL(pop));
}
}