1 16 19 20 package org.apache.xalan.xsltc.compiler; 21 22 import org.apache.bcel.generic.ConstantPoolGen; 23 import org.apache.bcel.generic.GOTO; 24 import org.apache.bcel.generic.InstructionList; 25 import org.apache.bcel.generic.PUSH; 26 import org.apache.xalan.xsltc.compiler.util.ClassGenerator; 27 import org.apache.xalan.xsltc.compiler.util.MethodGenerator; 28 import org.apache.xalan.xsltc.compiler.util.Type; 29 import org.apache.xalan.xsltc.compiler.util.TypeCheckError; 30 31 37 final class BooleanExpr extends Expression { 38 private boolean _value; 39 40 public BooleanExpr(boolean value) { 41 _value = value; 42 } 43 44 public Type typeCheck(SymbolTable stable) throws TypeCheckError { 45 _type = Type.Boolean; 46 return _type; 47 } 48 49 public String toString() { 50 return _value ? "true()" : "false()"; 51 } 52 53 public boolean getValue() { 54 return _value; 55 } 56 57 public boolean contextDependent() { 58 return false; 59 } 60 61 public void translate(ClassGenerator classGen, MethodGenerator methodGen) { 62 ConstantPoolGen cpg = classGen.getConstantPool(); 63 InstructionList il = methodGen.getInstructionList(); 64 il.append(new PUSH(cpg, _value)); 65 } 66 67 public void translateDesynthesized(ClassGenerator classGen, 68 MethodGenerator methodGen) { 69 final InstructionList il = methodGen.getInstructionList(); 70 if (_value) { 71 il.append(NOP); } 73 else { 74 _falseList.add(il.append(new GOTO(null))); 75 } 76 } 77 } 78 | Popular Tags |