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

StartsWithCall

public final class StartsWithCall extends FunctionCall
author
Jacek Ambroziak
author
Santiago Pericas-Geertsen
author
Morten Jorgensen

Fields Summary
private Expression
_base
private Expression
_token
Constructors Summary
public StartsWithCall(QName fname, Vector arguments)
Create a starts-with() call - two arguments, both strings


                  
         
	super(fname, arguments);
    
Methods Summary
public voidtranslate(com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator classGen, com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator methodGen)
Compile the expression - leave boolean expression on stack

	final ConstantPoolGen cpg = classGen.getConstantPool();
	final InstructionList il = methodGen.getInstructionList();
	_base.translate(classGen, methodGen);
	_token.translate(classGen, methodGen);
	il.append(new INVOKEVIRTUAL(cpg.addMethodref(STRING_CLASS,
						     "startsWith", 
						     "("+STRING_SIG+")Z")));
    
public com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypetypeCheck(com.sun.org.apache.xalan.internal.xsltc.compiler.SymbolTable stable)
Type check the two parameters for this function


	// Check that the function was passed exactly two arguments
	if (argumentCount() != 2) {
	    ErrorMsg err = new ErrorMsg(ErrorMsg.ILLEGAL_ARG_ERR,
					getName(), this);
	    throw new TypeCheckError(err);
	}

	// The first argument must be a String, or cast to a String
	_base = argument(0);
	Type baseType = _base.typeCheck(stable);	
	if (baseType != Type.String)
	    _base = new CastExpr(_base, Type.String);

	// The second argument must also be a String, or cast to a String
	_token = argument(1);
	Type tokenType = _token.typeCheck(stable);	
	if (tokenType != Type.String)
	    _token = new CastExpr(_token, Type.String);

	return _type = Type.Boolean;