1 16 19 20 package org.apache.xalan.xsltc.compiler; 21 22 import org.apache.bcel.generic.ConstantPoolGen; 23 import org.apache.bcel.generic.INVOKEINTERFACE; 24 import org.apache.bcel.generic.INVOKESPECIAL; 25 import org.apache.bcel.generic.InstructionList; 26 import org.apache.bcel.generic.NEW; 27 import org.apache.xalan.xsltc.compiler.util.ClassGenerator; 28 import org.apache.xalan.xsltc.compiler.util.MethodGenerator; 29 import org.apache.xalan.xsltc.compiler.util.NodeType; 30 import org.apache.xalan.xsltc.compiler.util.Type; 31 import org.apache.xalan.xsltc.compiler.util.TypeCheckError; 32 33 36 final class FilteredAbsoluteLocationPath extends Expression { 37 private Expression _path; 39 public FilteredAbsoluteLocationPath() { 40 _path = null; 41 } 42 43 public FilteredAbsoluteLocationPath(Expression path) { 44 _path = path; 45 if (path != null) { 46 _path.setParent(this); 47 } 48 } 49 50 public void setParser(Parser parser) { 51 super.setParser(parser); 52 if (_path != null) { 53 _path.setParser(parser); 54 } 55 } 56 57 public Expression getPath() { 58 return(_path); 59 } 60 61 public String toString() { 62 return "FilteredAbsoluteLocationPath(" + 63 (_path != null ? _path.toString() : "null") + ')'; 64 } 65 66 public Type typeCheck(SymbolTable stable) throws TypeCheckError { 67 if (_path != null) { 68 final Type ptype = _path.typeCheck(stable); 69 if (ptype instanceof NodeType) { _path = new CastExpr(_path, Type.NodeSet); 71 } 72 } 73 return _type = Type.NodeSet; 74 } 75 76 public void translate(ClassGenerator classGen, MethodGenerator methodGen) { 77 final ConstantPoolGen cpg = classGen.getConstantPool(); 78 final InstructionList il = methodGen.getInstructionList(); 79 if (_path != null) { 80 final int initDFI = cpg.addMethodref(DUP_FILTERED_ITERATOR, 81 "<init>", 82 "(" 83 + NODE_ITERATOR_SIG 84 + ")V"); 85 il.append(new NEW(cpg.addClass(DUP_FILTERED_ITERATOR))); 87 il.append(DUP); 88 89 _path.translate(classGen, methodGen); 91 92 il.append(new INVOKESPECIAL(initDFI)); 94 } 95 else { 96 final int git = cpg.addInterfaceMethodref(DOM_INTF, 97 "getIterator", 98 "()"+NODE_ITERATOR_SIG); 99 il.append(methodGen.loadDOM()); 100 il.append(new INVOKEINTERFACE(git, 1)); 101 } 102 } 103 } 104 | Popular Tags |