286N/A/*
286N/A * reserved comment block
286N/A * DO NOT REMOVE OR ALTER!
286N/A */
286N/A/*
286N/A * Copyright 2001-2004 The Apache Software Foundation.
286N/A *
286N/A * Licensed under the Apache License, Version 2.0 (the "License");
286N/A * you may not use this file except in compliance with the License.
286N/A * You may obtain a copy of the License at
286N/A *
286N/A * http://www.apache.org/licenses/LICENSE-2.0
286N/A *
286N/A * Unless required by applicable law or agreed to in writing, software
286N/A * distributed under the License is distributed on an "AS IS" BASIS,
286N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
286N/A * See the License for the specific language governing permissions and
286N/A * limitations under the License.
286N/A */
286N/A/*
286N/A * $Id: BooleanExpr.java,v 1.2.4.1 2005/09/01 11:44:57 pvedula Exp $
286N/A */
286N/A
286N/Apackage com.sun.org.apache.xalan.internal.xsltc.compiler;
286N/A
286N/Aimport com.sun.org.apache.bcel.internal.generic.ConstantPoolGen;
286N/Aimport com.sun.org.apache.bcel.internal.generic.GOTO;
286N/Aimport com.sun.org.apache.bcel.internal.generic.InstructionList;
286N/Aimport com.sun.org.apache.bcel.internal.generic.PUSH;
286N/Aimport com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator;
286N/Aimport com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator;
286N/Aimport com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type;
286N/Aimport com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError;
286N/A
286N/A/**
286N/A * This class implements inlined calls to the XSLT standard functions
286N/A * true() and false().
286N/A * @author Jacek Ambroziak
286N/A * @author Santiago Pericas-Geertsen
286N/A */
286N/Afinal class BooleanExpr extends Expression {
286N/A private boolean _value;
286N/A
286N/A public BooleanExpr(boolean value) {
286N/A _value = value;
286N/A }
286N/A
286N/A public Type typeCheck(SymbolTable stable) throws TypeCheckError {
286N/A _type = Type.Boolean;
286N/A return _type;
286N/A }
286N/A
286N/A public String toString() {
286N/A return _value ? "true()" : "false()";
286N/A }
286N/A
286N/A public boolean getValue() {
286N/A return _value;
286N/A }
286N/A
286N/A public boolean contextDependent() {
286N/A return false;
286N/A }
286N/A
286N/A public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
286N/A ConstantPoolGen cpg = classGen.getConstantPool();
286N/A InstructionList il = methodGen.getInstructionList();
286N/A il.append(new PUSH(cpg, _value));
286N/A }
286N/A
286N/A public void translateDesynthesized(ClassGenerator classGen,
286N/A MethodGenerator methodGen) {
286N/A final InstructionList il = methodGen.getInstructionList();
286N/A if (_value) {
286N/A il.append(NOP); // true list falls through
286N/A }
286N/A else {
286N/A _falseList.add(il.append(new GOTO(null)));
286N/A }
286N/A }
286N/A}