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