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