1 16 19 20 package org.apache.xalan.xsltc.compiler; 21 22 import org.apache.bcel.generic.ConstantPoolGen; 23 import org.apache.bcel.generic.ILOAD; 24 import org.apache.bcel.generic.INVOKEINTERFACE; 25 import org.apache.bcel.generic.InstructionList; 26 import org.apache.xalan.xsltc.compiler.util.ClassGenerator; 27 import org.apache.xalan.xsltc.compiler.util.CompareGenerator; 28 import org.apache.xalan.xsltc.compiler.util.MethodGenerator; 29 import org.apache.xalan.xsltc.compiler.util.TestGenerator; 30 31 35 final class LastCall extends FunctionCall { 36 37 public LastCall(QName fname) { 38 super(fname); 39 } 40 41 public boolean hasPositionCall() { 42 return true; 43 } 44 45 public boolean hasLastCall() { 46 return true; 47 } 48 49 public void translate(ClassGenerator classGen, MethodGenerator methodGen) { 50 final InstructionList il = methodGen.getInstructionList(); 51 52 if (methodGen instanceof CompareGenerator) { 53 il.append(((CompareGenerator)methodGen).loadLastNode()); 54 } 55 else if (methodGen instanceof TestGenerator) { 56 il.append(new ILOAD(LAST_INDEX)); 57 } 58 else { 59 final ConstantPoolGen cpg = classGen.getConstantPool(); 60 final int getLast = cpg.addInterfaceMethodref(NODE_ITERATOR, 61 "getLast", 62 "()I"); 63 il.append(methodGen.loadIterator()); 64 il.append(new INVOKEINTERFACE(getLast, 1)); 65 } 66 } 67 } 68 | Popular Tags |