KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > org > apache > xalan > internal > xsltc > compiler > util > MatchGenerator


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: MatchGenerator.java,v 1.5 2004/02/16 22:26:45 minchau Exp $
18  */

19
20 package com.sun.org.apache.xalan.internal.xsltc.compiler.util;
21
22 import com.sun.org.apache.bcel.internal.generic.ALOAD;
23 import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen;
24 import com.sun.org.apache.bcel.internal.generic.ILOAD;
25 import com.sun.org.apache.bcel.internal.generic.ISTORE;
26 import com.sun.org.apache.bcel.internal.generic.Instruction;
27 import com.sun.org.apache.bcel.internal.generic.InstructionList;
28 import com.sun.org.apache.bcel.internal.generic.Type;
29
30 /**
31  * @author Jacek Ambroziak
32  * @author Santiago Pericas-Geertsen
33  */

34 public final class MatchGenerator extends MethodGenerator {
35     private static int CURRENT_INDEX = 1;
36
37     private int _iteratorIndex = INVALID_INDEX;
38
39     private final Instruction _iloadCurrent;
40     private final Instruction _istoreCurrent;
41     private Instruction _aloadDom;
42     
43     public MatchGenerator(int access_flags, Type return_type,
44               Type[] arg_types, String JavaDoc[] arg_names,
45               String JavaDoc method_name, String JavaDoc class_name,
46               InstructionList il, ConstantPoolGen cp) {
47     super(access_flags, return_type, arg_types, arg_names, method_name,
48           class_name, il, cp);
49     
50     _iloadCurrent = new ILOAD(CURRENT_INDEX);
51     _istoreCurrent = new ISTORE(CURRENT_INDEX);
52     }
53
54     public Instruction loadCurrentNode() {
55     return _iloadCurrent;
56     }
57
58     public Instruction storeCurrentNode() {
59     return _istoreCurrent;
60     }
61     
62     public int getHandlerIndex() {
63     return INVALID_INDEX; // not available
64
}
65
66     /**
67      * Get index of the register where the DOM is stored.
68      */

69     public Instruction loadDOM() {
70     return _aloadDom;
71     }
72
73     /**
74      * Set index where the reference to the DOM is stored.
75      */

76     public void setDomIndex(int domIndex) {
77     _aloadDom = new ALOAD(domIndex);
78     }
79
80     /**
81      * Get index of the register where the current iterator is stored.
82      */

83     public int getIteratorIndex() {
84     return _iteratorIndex;
85     }
86
87     /**
88      * Set index of the register where the current iterator is stored.
89      */

90     public void setIteratorIndex(int iteratorIndex) {
91     _iteratorIndex = iteratorIndex;
92     }
93
94     public int getLocalIndex(String JavaDoc name) {
95     if (name.equals("current")) {
96         return CURRENT_INDEX;
97     }
98     return super.getLocalIndex(name);
99     }
100 }
101
Popular Tags