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.ConstantPoolGen; 26import com.sun.org.apache.bcel.internal.generic.ILOAD; 27import com.sun.org.apache.bcel.internal.generic.ISTORE; 28import com.sun.org.apache.bcel.internal.generic.Instruction; 29import com.sun.org.apache.bcel.internal.generic.InstructionList; 30import com.sun.org.apache.bcel.internal.generic.Type; 31 32/** 33 * @author Jacek Ambroziak 34 * @author Santiago Pericas-Geertsen 35 */ 36public final class MatchGenerator extends MethodGenerator { 37 private static int CURRENT_INDEX = 1; 38 39 private int _iteratorIndex = INVALID_INDEX; 40 41 private final Instruction _iloadCurrent; 42 private final Instruction _istoreCurrent; 43 private Instruction _aloadDom; 44 45 public MatchGenerator(int access_flags, Type return_type, 46 Type[] arg_types, String[] arg_names, 47 String method_name, String class_name, 48 InstructionList il, ConstantPoolGen cp) { 49 super(access_flags, return_type, arg_types, arg_names, method_name, 50 class_name, il, cp); 51 52 _iloadCurrent = new ILOAD(CURRENT_INDEX); 53 _istoreCurrent = new ISTORE(CURRENT_INDEX); 54 } 55 56 public Instruction loadCurrentNode() { 57 return _iloadCurrent; 58 } 59 60 public Instruction storeCurrentNode() { 61 return _istoreCurrent; 62 } 63 64 public int getHandlerIndex() { 65 return INVALID_INDEX; // not available 66 } 67 68 /** 69 * Get index of the register where the DOM is stored. 70 */ 71 public Instruction loadDOM() { 72 return _aloadDom; 73 } 74 75 /** 76 * Set index where the reference to the DOM is stored. 77 */ 78 public void setDomIndex(int domIndex) { 79 _aloadDom = new ALOAD(domIndex); 80 } 81 82 /** 83 * Get index of the register where the current iterator is stored. 84 */ 85 public int getIteratorIndex() { 86 return _iteratorIndex; 87 } 88 89 /** 90 * Set index of the register where the current iterator is stored. 91 */ 92 public void setIteratorIndex(int iteratorIndex) { 93 _iteratorIndex = iteratorIndex; 94 } 95 96 public int getLocalIndex(String name) { 97 if (name.equals("current")) { 98 return CURRENT_INDEX; 99 } 100 return super.getLocalIndex(name); 101 } 102} 103