View Javadoc
1   /*
2    * reserved comment block
3    * DO NOT REMOVE OR ALTER!
4    */
5   /*
6    * Copyright 2001-2004 The Apache Software Foundation.
7    *
8    * Licensed under the Apache License, Version 2.0 (the "License");
9    * you may not use this file except in compliance with the License.
10   * You may obtain a copy of the License at
11   *
12   *     http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS,
16   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17   * See the License for the specific language governing permissions and
18   * limitations under the License.
19   */
20  /*
21   * $Id: Pattern.java,v 1.2.4.1 2005/09/12 11:00:31 pvedula Exp $
22   */
23  
24  package com.sun.org.apache.xalan.internal.xsltc.compiler;
25  
26  import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator;
27  import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator;
28  import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type;
29  import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError;
30  
31  /**
32   * @author Jacek Ambroziak
33   * @author Santiago Pericas-Geertsen
34   */
35  public abstract class Pattern extends Expression {
36      /**
37       * Returns the type of a pattern, which is always a <code>NodeType</code>.
38       * A <code>NodeType</code> has a number of subtypes defined by
39       * <code>NodeType._type</code> corresponding to each type of node.
40       */
41      public abstract Type typeCheck(SymbolTable stable) throws TypeCheckError;
42  
43      /**
44       * Translate this node into JVM bytecodes. Patterns are translated as
45       * boolean expressions with true/false lists. Before calling
46       * <code>translate</code> on a pattern, make sure that the node being
47       * matched is on top of the stack. After calling <code>translate</code>,
48       * make sure to backpatch both true and false lists. True lists are the
49       * default, in the sense that they always <em>"fall through"</em>. If this
50       * is not the intended semantics (e.g., see
51       * {@link com.sun.org.apache.xalan.internal.xsltc.compiler.AlternativePattern#translate})
52       * then a GOTO must be appended to the instruction list after calling
53       * <code>translate</code>.
54       */
55      public abstract void translate(ClassGenerator classGen,
56                                     MethodGenerator methodGen);
57  
58      /**
59       * Returns the priority of this pattern (section 5.5 in the XSLT spec).
60       */
61      public abstract double getPriority();
62  }