1 16 19 20 package com.sun.org.apache.xalan.internal.xsltc.compiler.util; 21 22 import com.sun.org.apache.bcel.internal.generic.ACONST_NULL; 23 import com.sun.org.apache.bcel.internal.generic.ALOAD; 24 import com.sun.org.apache.bcel.internal.generic.ASTORE; 25 import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; 26 import com.sun.org.apache.bcel.internal.generic.ILOAD; 27 import com.sun.org.apache.bcel.internal.generic.ISTORE; 28 import com.sun.org.apache.bcel.internal.generic.Instruction; 29 import com.sun.org.apache.bcel.internal.generic.InstructionList; 30 import com.sun.org.apache.bcel.internal.generic.LocalVariableGen; 31 import com.sun.org.apache.bcel.internal.generic.Type; 32 import com.sun.org.apache.xalan.internal.xsltc.compiler.Constants; 33 34 38 public final class CompareGenerator extends MethodGenerator { 39 40 private static int DOM_INDEX = 1; 41 private static int CURRENT_INDEX = 2; 42 private static int LEVEL_INDEX = 3; 43 private static int TRANSLET_INDEX = 4; 44 private static int LAST_INDEX = 5; 45 private int ITERATOR_INDEX = 6; 46 47 private final Instruction _iloadCurrent; 48 private final Instruction _istoreCurrent; 49 private final Instruction _aloadDom; 50 private final Instruction _iloadLast; 51 private final Instruction _aloadIterator; 52 private final Instruction _astoreIterator; 53 54 public CompareGenerator(int access_flags, Type return_type, 55 Type[] arg_types, String [] arg_names, 56 String method_name, String class_name, 57 InstructionList il, ConstantPoolGen cp) { 58 super(access_flags, return_type, arg_types, arg_names, method_name, 59 class_name, il, cp); 60 61 _iloadCurrent = new ILOAD(CURRENT_INDEX); 62 _istoreCurrent = new ISTORE(CURRENT_INDEX); 63 _aloadDom = new ALOAD(DOM_INDEX); 64 _iloadLast = new ILOAD(LAST_INDEX); 65 66 LocalVariableGen iterator = 67 addLocalVariable("iterator", 68 Util.getJCRefType(Constants.NODE_ITERATOR_SIG), 69 null, null); 70 ITERATOR_INDEX = iterator.getIndex(); 71 _aloadIterator = new ALOAD(ITERATOR_INDEX); 72 _astoreIterator = new ASTORE(ITERATOR_INDEX); 73 il.append(new ACONST_NULL()); 74 il.append(storeIterator()); 75 } 76 77 public Instruction loadLastNode() { 78 return _iloadLast; 79 } 80 81 public Instruction loadCurrentNode() { 82 return _iloadCurrent; 83 } 84 85 public Instruction storeCurrentNode() { 86 return _istoreCurrent; 87 } 88 89 public Instruction loadDOM() { 90 return _aloadDom; 91 } 92 93 public int getHandlerIndex() { 94 return INVALID_INDEX; } 96 97 public int getIteratorIndex() { 98 return INVALID_INDEX; 99 } 100 101 public Instruction storeIterator() { 102 return _astoreIterator; 103 } 104 105 public Instruction loadIterator() { 106 return _aloadIterator; 107 } 108 109 public int getLocalIndex(String name) { 111 if (name.equals("current")) { 112 return CURRENT_INDEX; 113 } 114 return super.getLocalIndex(name); 115 } 116 } 117 | Popular Tags |