1 16 19 20 package org.apache.xalan.xsltc.compiler.util; 21 22 import org.apache.bcel.generic.ALOAD; 23 import org.apache.bcel.generic.ASTORE; 24 import org.apache.bcel.generic.ConstantPoolGen; 25 import org.apache.bcel.generic.ILOAD; 26 import org.apache.bcel.generic.ISTORE; 27 import org.apache.bcel.generic.Instruction; 28 import org.apache.bcel.generic.InstructionList; 29 import org.apache.bcel.generic.Type; 30 31 36 public final class TestGenerator extends MethodGenerator { 37 private static int CONTEXT_NODE_INDEX = 1; 38 private static int CURRENT_NODE_INDEX = 4; 39 private static int ITERATOR_INDEX = 6; 40 41 private Instruction _aloadDom; 42 private final Instruction _iloadCurrent; 43 private final Instruction _iloadContext; 44 private final Instruction _istoreCurrent; 45 private final Instruction _istoreContext; 46 private final Instruction _astoreIterator; 47 private final Instruction _aloadIterator; 48 49 public TestGenerator(int access_flags, Type return_type, 50 Type[] arg_types, String [] arg_names, 51 String method_name, String class_name, 52 InstructionList il, ConstantPoolGen cp) { 53 super(access_flags, return_type, arg_types, arg_names, method_name, 54 class_name, il, cp); 55 56 _iloadCurrent = new ILOAD(CURRENT_NODE_INDEX); 57 _istoreCurrent = new ISTORE(CURRENT_NODE_INDEX); 58 _iloadContext = new ILOAD(CONTEXT_NODE_INDEX); 59 _istoreContext = new ILOAD(CONTEXT_NODE_INDEX); 60 _astoreIterator = new ASTORE(ITERATOR_INDEX); 61 _aloadIterator = new ALOAD(ITERATOR_INDEX); 62 } 63 64 public int getHandlerIndex() { 65 return INVALID_INDEX; } 67 68 public int getIteratorIndex() { 69 return ITERATOR_INDEX; } 71 72 public void setDomIndex(int domIndex) { 73 _aloadDom = new ALOAD(domIndex); 74 } 75 76 public Instruction loadDOM() { 77 return _aloadDom; 78 } 79 80 public Instruction loadCurrentNode() { 81 return _iloadCurrent; 82 } 83 84 85 public Instruction loadContextNode() { 86 return _iloadContext; 87 } 88 89 public Instruction storeContextNode() { 90 return _istoreContext; 91 } 92 93 public Instruction storeCurrentNode() { 94 return _istoreCurrent; 95 } 96 97 public Instruction storeIterator() { 98 return _astoreIterator; 99 } 100 101 public Instruction loadIterator() { 102 return _aloadIterator; 103 } 104 105 public int getLocalIndex(String name) { 106 if (name.equals("current")) { 107 return CURRENT_NODE_INDEX; 108 } 109 else { 110 return super.getLocalIndex(name); 111 } 112 } 113 } 114 | Popular Tags |