1 16 19 20 package com.sun.org.apache.xalan.internal.xsltc.compiler; 21 22 import com.sun.org.apache.bcel.internal.generic.GOTO; 23 import com.sun.org.apache.bcel.internal.generic.InstructionHandle; 24 import com.sun.org.apache.bcel.internal.generic.InstructionList; 25 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; 26 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; 27 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; 28 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; 29 30 34 final class AlternativePattern extends Pattern { 35 private final Pattern _left; 36 private final Pattern _right; 37 38 42 public AlternativePattern(Pattern left, Pattern right) { 43 _left = left; 44 _right = right; 45 } 46 47 public void setParser(Parser parser) { 48 super.setParser(parser); 49 _left.setParser(parser); 50 _right.setParser(parser); 51 } 52 53 public Pattern getLeft() { 54 return _left; 55 } 56 57 public Pattern getRight() { 58 return _right; 59 } 60 61 64 public Type typeCheck(SymbolTable stable) throws TypeCheckError { 65 _left.typeCheck(stable); 66 _right.typeCheck(stable); 67 return null; 68 } 69 70 public double getPriority() { 71 double left = _left.getPriority(); 72 double right = _right.getPriority(); 73 74 if (left < right) 75 return(left); 76 else 77 return(right); 78 } 79 80 public String toString() { 81 return "alternative(" + _left + ", " + _right + ')'; 82 } 83 84 public void translate(ClassGenerator classGen, MethodGenerator methodGen) { 85 final InstructionList il = methodGen.getInstructionList(); 86 87 _left.translate(classGen, methodGen); 88 final InstructionHandle gotot = il.append(new GOTO(null)); 89 il.append(methodGen.loadContextNode()); 90 _right.translate(classGen, methodGen); 91 92 _left._trueList.backPatch(gotot); 93 _left._falseList.backPatch(gotot.getNext()); 94 95 _trueList.append(_right._trueList.add(gotot)); 96 _falseList.append(_right._falseList); 97 } 98 } 99 | Popular Tags |