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 37 final class AbsoluteLocationPath extends Expression { 38 private Expression _path; 40 public AbsoluteLocationPath() { 41 _path = null; 42 } 43 44 public AbsoluteLocationPath(Expression path) { 45 _path = path; 46 if (path != null) { 47 _path.setParent(this); 48 } 49 } 50 51 public void setParser(Parser parser) { 52 super.setParser(parser); 53 if (_path != null) { 54 _path.setParser(parser); 55 } 56 } 57 58 public Expression getPath() { 59 return(_path); 60 } 61 62 public String toString() { 63 return "AbsoluteLocationPath(" + 64 (_path != null ? _path.toString() : "null") + ')'; 65 } 66 67 public Type typeCheck(SymbolTable stable) throws TypeCheckError { 68 if (_path != null) { 69 final Type ptype = _path.typeCheck(stable); 70 if (ptype instanceof NodeType) { _path = new CastExpr(_path, Type.NodeSet); 72 } 73 } 74 return _type = Type.NodeSet; 75 } 76 77 public void translate(ClassGenerator classGen, MethodGenerator methodGen) { 78 final ConstantPoolGen cpg = classGen.getConstantPool(); 79 final InstructionList il = methodGen.getInstructionList(); 80 if (_path != null) { 81 final int initAI = cpg.addMethodref(ABSOLUTE_ITERATOR, 82 "<init>", 83 "(" 84 + NODE_ITERATOR_SIG 85 + ")V"); 86 il.append(new NEW(cpg.addClass(ABSOLUTE_ITERATOR))); 88 il.append(DUP); 89 90 _path.translate(classGen, methodGen); 92 93 il.append(new INVOKESPECIAL(initAI)); 95 } 96 else { 97 final int gitr = cpg.addInterfaceMethodref(DOM_INTF, 98 "getIterator", 99 "()"+NODE_ITERATOR_SIG); 100 il.append(methodGen.loadDOM()); 101 il.append(new INVOKEINTERFACE(gitr, 1)); 102 } 103 } 104 } 105 | Popular Tags |