1 16 19 20 package com.sun.org.apache.xalan.internal.xsltc.compiler; 21 22 import java.util.Vector ; 23 24 import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; 25 import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; 26 import com.sun.org.apache.bcel.internal.generic.InstructionList; 27 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; 28 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; 29 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; 30 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; 31 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; 32 33 38 final class StartsWithCall extends FunctionCall { 39 40 private Expression _base = null; 41 private Expression _token = null; 42 43 46 public StartsWithCall(QName fname, Vector arguments) { 47 super(fname, arguments); 48 } 49 50 53 public Type typeCheck(SymbolTable stable) throws TypeCheckError { 54 55 if (argumentCount() != 2) { 57 ErrorMsg err = new ErrorMsg(ErrorMsg.ILLEGAL_ARG_ERR, 58 getName(), this); 59 throw new TypeCheckError(err); 60 } 61 62 _base = argument(0); 64 Type baseType = _base.typeCheck(stable); 65 if (baseType != Type.String) 66 _base = new CastExpr(_base, Type.String); 67 68 _token = argument(1); 70 Type tokenType = _token.typeCheck(stable); 71 if (tokenType != Type.String) 72 _token = new CastExpr(_token, Type.String); 73 74 return _type = Type.Boolean; 75 } 76 77 80 public void translate(ClassGenerator classGen, MethodGenerator methodGen) { 81 final ConstantPoolGen cpg = classGen.getConstantPool(); 82 final InstructionList il = methodGen.getInstructionList(); 83 _base.translate(classGen, methodGen); 84 _token.translate(classGen, methodGen); 85 il.append(new INVOKEVIRTUAL(cpg.addMethodref(STRING_CLASS, 86 "startsWith", 87 "("+STRING_SIG+")Z"))); 88 } 89 } 90 | Popular Tags |