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: NodeCounterGenerator.java,v 1.6 2004/02/16 22:26:45 minchau Exp $
  18. */
  19. package com.sun.org.apache.xalan.internal.xsltc.compiler.util;
  20. import com.sun.org.apache.bcel.internal.generic.ALOAD;
  21. import com.sun.org.apache.bcel.internal.generic.Instruction;
  22. import com.sun.org.apache.xalan.internal.xsltc.compiler.Stylesheet;
  23. /**
  24. * This class implements auxiliary classes needed to compile
  25. * patterns in <tt>xsl:number</tt>. These classes inherit from
  26. * {Any,Single,Multiple}NodeCounter and override the
  27. * <tt>matchFrom</tt> and <tt>matchCount</tt> methods.
  28. * @author Jacek Ambroziak
  29. * @author Santiago Pericas-Geertsen
  30. */
  31. public final class NodeCounterGenerator extends ClassGenerator {
  32. private Instruction _aloadTranslet;
  33. public NodeCounterGenerator(String className,
  34. String superClassName,
  35. String fileName,
  36. int accessFlags,
  37. String[] interfaces,
  38. Stylesheet stylesheet) {
  39. super(className, superClassName, fileName,
  40. accessFlags, interfaces, stylesheet);
  41. }
  42. /**
  43. * Set the index of the register where "this" (the pointer to
  44. * the translet) is stored.
  45. */
  46. public void setTransletIndex(int index) {
  47. _aloadTranslet = new ALOAD(index);
  48. }
  49. /**
  50. * The index of the translet pointer within the execution of
  51. * matchFrom or matchCount.
  52. * Overridden from ClassGenerator.
  53. */
  54. public Instruction loadTranslet() {
  55. return _aloadTranslet;
  56. }
  57. /**
  58. * Returns <tt>true</tt> since this class is external to the
  59. * translet.
  60. */
  61. public boolean isExternal() {
  62. return true;
  63. }
  64. }