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