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: Pattern.java,v 1.4 2004/02/16 22:24:29 minchau Exp $
  18. */
  19. package com.sun.org.apache.xalan.internal.xsltc.compiler;
  20. import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator;
  21. import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator;
  22. import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type;
  23. import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError;
  24. /**
  25. * @author Jacek Ambroziak
  26. * @author Santiago Pericas-Geertsen
  27. */
  28. public abstract class Pattern extends Expression {
  29. /**
  30. * Returns the type of a pattern, which is always a <code>NodeType</code>.
  31. * A <code>NodeType</code> has a number of subtypes defined by
  32. * <code>NodeType._type</code> corresponding to each type of node.
  33. */
  34. public abstract Type typeCheck(SymbolTable stable) throws TypeCheckError;
  35. /**
  36. * Translate this node into JVM bytecodes. Patterns are translated as
  37. * boolean expressions with true/false lists. Before calling
  38. * <code>translate</code> on a pattern, make sure that the node being
  39. * matched is on top of the stack. After calling <code>translate</code>,
  40. * make sure to backpatch both true and false lists. True lists are the
  41. * default, in the sense that they always <em>"fall through"</em>. If this
  42. * is not the intended semantics (e.g., see
  43. * {@link com.sun.org.apache.xalan.internal.xsltc.compiler.AlternativePattern#translate()})
  44. * then a GOTO must be appended to the instruction list after calling
  45. * <code>translate</code>.
  46. */
  47. public abstract void translate(ClassGenerator classGen,
  48. MethodGenerator methodGen);
  49. /**
  50. * Returns the priority of this pattern (section 5.5 in the XSLT spec).
  51. */
  52. public abstract double getPriority();
  53. }