1. /*
  2. * Copyright 2001-2004 The Apache Software Foundation.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /*
  17. * $Id: AttributeSetMethodGenerator.java,v 1.7 2004/02/16 22:26:44 minchau Exp $
  18. */
  19. package com.sun.org.apache.xalan.internal.xsltc.compiler.util;
  20. import com.sun.org.apache.bcel.internal.generic.ALOAD;
  21. import com.sun.org.apache.bcel.internal.generic.ASTORE;
  22. import com.sun.org.apache.bcel.internal.generic.ClassGen;
  23. import com.sun.org.apache.bcel.internal.generic.Instruction;
  24. import com.sun.org.apache.bcel.internal.generic.InstructionList;
  25. /**
  26. * @author Jacek Ambroziak
  27. * @author Santiago Pericas-Geertsen
  28. */
  29. public final class AttributeSetMethodGenerator extends MethodGenerator {
  30. private static final int DOM_INDEX = 1;
  31. private static final int ITERATOR_INDEX = 2;
  32. private static final int HANDLER_INDEX = 3;
  33. private static final com.sun.org.apache.bcel.internal.generic.Type[] argTypes =
  34. new com.sun.org.apache.bcel.internal.generic.Type[3];
  35. private static final String[] argNames = new String[3];
  36. static {
  37. argTypes[0] = Util.getJCRefType(DOM_INTF_SIG);
  38. argNames[0] = DOM_PNAME;
  39. argTypes[1] = Util.getJCRefType(NODE_ITERATOR_SIG);
  40. argNames[1] = ITERATOR_PNAME;
  41. argTypes[2] = Util.getJCRefType(TRANSLET_OUTPUT_SIG);
  42. argNames[2] = TRANSLET_OUTPUT_PNAME;
  43. }
  44. private final Instruction _aloadDom;
  45. private final Instruction _astoreDom;
  46. private final Instruction _astoreIterator;
  47. private final Instruction _aloadIterator;
  48. private final Instruction _astoreHandler;
  49. private final Instruction _aloadHandler;
  50. public AttributeSetMethodGenerator(String methodName, ClassGen classGen) {
  51. super(com.sun.org.apache.bcel.internal.Constants.ACC_PRIVATE,
  52. com.sun.org.apache.bcel.internal.generic.Type.VOID,
  53. argTypes, argNames, methodName,
  54. classGen.getClassName(),
  55. new InstructionList(),
  56. classGen.getConstantPool());
  57. _aloadDom = new ALOAD(DOM_INDEX);
  58. _astoreDom = new ASTORE(DOM_INDEX);
  59. _astoreIterator = new ASTORE(ITERATOR_INDEX);
  60. _aloadIterator = new ALOAD(ITERATOR_INDEX);
  61. _astoreHandler = new ASTORE(HANDLER_INDEX);
  62. _aloadHandler = new ALOAD(HANDLER_INDEX);
  63. }
  64. public Instruction storeIterator() {
  65. return _astoreIterator;
  66. }
  67. public Instruction loadIterator() {
  68. return _aloadIterator;
  69. }
  70. public int getIteratorIndex() {
  71. return ITERATOR_INDEX;
  72. }
  73. public Instruction storeHandler() {
  74. return _astoreHandler;
  75. }
  76. public Instruction loadHandler() {
  77. return _aloadHandler;
  78. }
  79. public int getLocalIndex(String name) {
  80. return INVALID_INDEX; // not available
  81. }
  82. }