001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one
003     * or more contributor license agreements. See the NOTICE file
004     * distributed with this work for additional information
005     * regarding copyright ownership. The ASF licenses this file
006     * to you under the Apache License, Version 2.0 (the  "License");
007     * you may not use this file except in compliance with the License.
008     * You may obtain a copy of the License at
009     *
010     *     http://www.apache.org/licenses/LICENSE-2.0
011     *
012     * Unless required by applicable law or agreed to in writing, software
013     * distributed under the License is distributed on an "AS IS" BASIS,
014     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015     * See the License for the specific language governing permissions and
016     * limitations under the License.
017     */
018    /*
019     * $Id: AttributeSetMethodGenerator.java 468649 2006-10-28 07:00:55Z minchau $
020     */
021    
022    package org.apache.xalan.xsltc.compiler.util;
023    
024    import org.apache.bcel.generic.ALOAD;
025    import org.apache.bcel.generic.ASTORE;
026    import org.apache.bcel.generic.ClassGen;
027    import org.apache.bcel.generic.Instruction;
028    import org.apache.bcel.generic.InstructionList;
029    
030    /**
031     * @author Jacek Ambroziak
032     * @author Santiago Pericas-Geertsen
033     */
034    public final class AttributeSetMethodGenerator extends MethodGenerator {
035        private static final int DOM_INDEX       = 1;
036        private static final int ITERATOR_INDEX  = 2;
037        private static final int HANDLER_INDEX   = 3;
038    
039        private static final org.apache.bcel.generic.Type[] argTypes =
040       new org.apache.bcel.generic.Type[3];
041        private static final String[] argNames = new String[3];
042        
043        static {
044           argTypes[0] = Util.getJCRefType(DOM_INTF_SIG);
045           argNames[0] = DOM_PNAME;
046           argTypes[1] = Util.getJCRefType(NODE_ITERATOR_SIG);
047           argNames[1] = ITERATOR_PNAME;
048           argTypes[2] = Util.getJCRefType(TRANSLET_OUTPUT_SIG);
049           argNames[2] = TRANSLET_OUTPUT_PNAME;
050        }
051    
052        
053        private final Instruction _aloadDom;
054        private final Instruction _astoreDom;
055        private final Instruction _astoreIterator;
056        private final Instruction _aloadIterator;
057        private final Instruction _astoreHandler;
058        private final Instruction _aloadHandler;
059        
060        public AttributeSetMethodGenerator(String methodName, ClassGen classGen) {
061            super(org.apache.bcel.Constants.ACC_PRIVATE,
062                  org.apache.bcel.generic.Type.VOID,
063                  argTypes, argNames, methodName, 
064                  classGen.getClassName(),
065                  new InstructionList(),
066                  classGen.getConstantPool());
067            
068            _aloadDom       = new ALOAD(DOM_INDEX);
069            _astoreDom      = new ASTORE(DOM_INDEX);
070            _astoreIterator = new ASTORE(ITERATOR_INDEX);
071            _aloadIterator  = new ALOAD(ITERATOR_INDEX);
072            _astoreHandler  = new ASTORE(HANDLER_INDEX);
073            _aloadHandler   = new ALOAD(HANDLER_INDEX);
074        }
075    
076        public Instruction storeIterator() {
077            return _astoreIterator;
078        }
079        
080        public Instruction loadIterator() {
081            return _aloadIterator;
082        }
083    
084        public int getIteratorIndex() {
085            return ITERATOR_INDEX;
086        }
087    
088        public Instruction storeHandler() {
089            return _astoreHandler;
090        }
091    
092        public Instruction loadHandler() {
093            return _aloadHandler;
094        }
095    
096        public int getLocalIndex(String name) {
097            return INVALID_INDEX;   // not available
098        }
099    }