1 16 19 20 package com.sun.org.apache.xalan.internal.xsltc.compiler; 21 22 import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; 23 import com.sun.org.apache.bcel.internal.generic.ILOAD; 24 import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE; 25 import com.sun.org.apache.bcel.internal.generic.InstructionList; 26 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; 27 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.CompareGenerator; 28 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; 29 import com.sun.org.apache.xalan.internal.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 |