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.ILOAD; 26 import com.sun.org.apache.bcel.internal.generic.INVOKESTATIC; 27 import com.sun.org.apache.bcel.internal.generic.InstructionList; 28 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; 29 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.FilterGenerator; 30 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; 31 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.StringType; 32 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; 33 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; 34 35 38 final class LangCall extends FunctionCall { 39 private Expression _lang; 40 private Type _langType; 41 42 46 public LangCall(QName fname, Vector arguments) { 47 super(fname, arguments); 48 _lang = argument(0); 49 } 50 51 54 public Type typeCheck(SymbolTable stable) throws TypeCheckError { 55 _langType = _lang.typeCheck(stable); 56 if (!(_langType instanceof StringType)) { 57 _lang = new CastExpr(_lang, Type.String); 58 } 59 return Type.Boolean; 60 } 61 62 65 public Type getType() { 66 return(Type.Boolean); 67 } 68 69 73 public void translate(ClassGenerator classGen, 74 MethodGenerator methodGen) { 75 final ConstantPoolGen cpg = classGen.getConstantPool(); 76 final InstructionList il = methodGen.getInstructionList(); 77 78 final int tst = cpg.addMethodref(BASIS_LIBRARY_CLASS, 79 "testLanguage", 80 "("+STRING_SIG+DOM_INTF_SIG+"I)Z"); 81 _lang.translate(classGen,methodGen); 82 il.append(methodGen.loadDOM()); 83 if (classGen instanceof FilterGenerator) 84 il.append(new ILOAD(1)); 85 else 86 il.append(methodGen.loadContextNode()); 87 il.append(new INVOKESTATIC(tst)); 88 } 89 } 90 | Popular Tags |