01: /*
02: * Copyright 2001-2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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: NodeCounterGenerator.java,v 1.6 2004/02/16 22:26:45 minchau Exp $
18: */
19:
20: package org.apache.xalan.xsltc.compiler.util;
21:
22: import org.apache.bcel.generic.ALOAD;
23: import org.apache.bcel.generic.Instruction;
24: import org.apache.xalan.xsltc.compiler.Stylesheet;
25:
26: /**
27: * This class implements auxiliary classes needed to compile
28: * patterns in <tt>xsl:number</tt>. These classes inherit from
29: * {Any,Single,Multiple}NodeCounter and override the
30: * <tt>matchFrom</tt> and <tt>matchCount</tt> methods.
31: * @author Jacek Ambroziak
32: * @author Santiago Pericas-Geertsen
33: */
34: public final class NodeCounterGenerator extends ClassGenerator {
35: private Instruction _aloadTranslet;
36:
37: public NodeCounterGenerator(String className,
38: String super ClassName, String fileName, int accessFlags,
39: String[] interfaces, Stylesheet stylesheet) {
40: super (className, super ClassName, fileName, accessFlags,
41: interfaces, stylesheet);
42: }
43:
44: /**
45: * Set the index of the register where "this" (the pointer to
46: * the translet) is stored.
47: */
48: public void setTransletIndex(int index) {
49: _aloadTranslet = new ALOAD(index);
50: }
51:
52: /**
53: * The index of the translet pointer within the execution of
54: * matchFrom or matchCount.
55: * Overridden from ClassGenerator.
56: */
57: public Instruction loadTranslet() {
58: return _aloadTranslet;
59: }
60:
61: /**
62: * Returns <tt>true</tt> since this class is external to the
63: * translet.
64: */
65: public boolean isExternal() {
66: return true;
67: }
68: }
|