1 16 19 20 package org.apache.xalan.xsltc.compiler; 21 22 import java.util.Vector ; 23 24 import org.apache.bcel.generic.ConstantPoolGen; 25 import org.apache.bcel.generic.IFLT; 26 import org.apache.bcel.generic.INVOKEVIRTUAL; 27 import org.apache.bcel.generic.InstructionList; 28 import org.apache.xalan.xsltc.compiler.util.ClassGenerator; 29 import org.apache.xalan.xsltc.compiler.util.ErrorMsg; 30 import org.apache.xalan.xsltc.compiler.util.MethodGenerator; 31 import org.apache.xalan.xsltc.compiler.util.Type; 32 import org.apache.xalan.xsltc.compiler.util.TypeCheckError; 33 34 39 final class ContainsCall extends FunctionCall { 40 41 private Expression _base = null; 42 private Expression _token = null; 43 44 47 public ContainsCall(QName fname, Vector arguments) { 48 super(fname, arguments); 49 } 50 51 54 public boolean isBoolean() { 55 return true; 56 } 57 58 61 public Type typeCheck(SymbolTable stable) throws TypeCheckError { 62 63 if (argumentCount() != 2) { 65 throw new TypeCheckError(ErrorMsg.ILLEGAL_ARG_ERR, getName(), this); 66 } 67 68 _base = argument(0); 70 Type baseType = _base.typeCheck(stable); 71 if (baseType != Type.String) 72 _base = new CastExpr(_base, Type.String); 73 74 _token = argument(1); 76 Type tokenType = _token.typeCheck(stable); 77 if (tokenType != Type.String) 78 _token = new CastExpr(_token, Type.String); 79 80 return _type = Type.Boolean; 81 } 82 83 86 public void translate(ClassGenerator classGen, MethodGenerator methodGen) { 87 translateDesynthesized(classGen, methodGen); 88 synthesize(classGen, methodGen); 89 } 90 91 94 public void translateDesynthesized(ClassGenerator classGen, 95 MethodGenerator methodGen) { 96 final ConstantPoolGen cpg = classGen.getConstantPool(); 97 final InstructionList il = methodGen.getInstructionList(); 98 _base.translate(classGen, methodGen); 99 _token.translate(classGen, methodGen); 100 il.append(new INVOKEVIRTUAL(cpg.addMethodref(STRING_CLASS, 101 "indexOf", 102 "("+STRING_SIG+")I"))); 103 _falseList.add(il.append(new IFLT(null))); 104 } 105 } 106 | Popular Tags |