FileDocCategorySizeDatePackage
NameBase.javaAPI DocJava SE 5 API3678Fri Aug 26 14:55:36 BST 2005com.sun.org.apache.xalan.internal.xsltc.compiler

NameBase

public class NameBase extends FunctionCall
author
Morten Jorgensen
author
Erwin Bolwidt

Fields Summary
private Expression
_param
private Type
_paramType
Constructors Summary
public NameBase(QName fname)
Handles calls with no parameter (current node is implicit parameter).


                   
       
	super(fname);
    
public NameBase(QName fname, Vector arguments)
Handles calls with one parameter (either node or node-set).

	super(fname, arguments);
	_param = argument(0);
    
Methods Summary
public com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypegetType()

	return _type;
    
public voidtranslate(com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator classGen, com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator methodGen)
Translate the code required for getting the node for which the QName, local-name or namespace URI should be extracted.

	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());
	}
    
public com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypetypeCheck(com.sun.org.apache.xalan.internal.xsltc.compiler.SymbolTable stable)
Check that we either have no parameters or one parameter that is either a node or a node-set.


	// Check the argument type (if any)
	switch(argumentCount()) {
	case 0:
	    _paramType = Type.Node;
	    break;
	case 1:
	    _paramType = _param.typeCheck(stable);
	    break;
	default:
	    throw new TypeCheckError(this);
	}

	// The argument has to be a node, a node-set or a node reference
	if ((_paramType != Type.NodeSet) &&
	    (_paramType != Type.Node) &&
	    (_paramType != Type.Reference)) {
	    throw new TypeCheckError(this);
	}

	return (_type = Type.String);