FileDocCategorySizeDatePackage
BooleanType.javaAPI DocJava SE 5 API7745Fri Aug 26 14:55:38 BST 2005com.sun.org.apache.xalan.internal.xsltc.compiler.util

BooleanType

public final class BooleanType extends Type
author
Jacek Ambroziak
author
Santiago Pericas-Geertsen

Fields Summary
Constructors Summary
protected BooleanType()

Methods Summary
public com.sun.org.apache.bcel.internal.generic.BranchInstructionGE(boolean tozero)

	return tozero ? (BranchInstruction) new IFGE(null) : 
	    (BranchInstruction) new IF_ICMPGE(null);
    
public com.sun.org.apache.bcel.internal.generic.BranchInstructionGT(boolean tozero)

	return tozero ? (BranchInstruction) new IFGT(null) : 
	    (BranchInstruction) new IF_ICMPGT(null);
    
public com.sun.org.apache.bcel.internal.generic.BranchInstructionLE(boolean tozero)

	return tozero ? (BranchInstruction) new IFLE(null) : 
	    (BranchInstruction) new IF_ICMPLE(null);
    
public com.sun.org.apache.bcel.internal.generic.InstructionLOAD(int slot)

	return new ILOAD(slot);
    
public com.sun.org.apache.bcel.internal.generic.BranchInstructionLT(boolean tozero)

	return tozero ? (BranchInstruction) new IFLT(null) : 
	    (BranchInstruction) new IF_ICMPLT(null);
    
public com.sun.org.apache.bcel.internal.generic.InstructionSTORE(int slot)

	return new ISTORE(slot);
    
public booleanidenticalTo(com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type other)

	return this == other;
    
public booleanisSimple()

	return true;
    
public com.sun.org.apache.bcel.internal.generic.TypetoJCType()

	return com.sun.org.apache.bcel.internal.generic.Type.BOOLEAN;
    
public java.lang.StringtoSignature()

	return "Z";
    
public java.lang.StringtoString()

	return "boolean";
    
public voidtranslateBox(com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator classGen, com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator methodGen)
Translates an object of this type to its boxed representation.

	translateTo(classGen, methodGen, Type.Reference);
    
public voidtranslateFrom(com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator classGen, com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator methodGen, java.lang.Class clazz)
Translates an external (Java) boolean into internal boolean.

	translateTo(classGen, methodGen, clazz);
    
public voidtranslateTo(com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator classGen, com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator methodGen, com.sun.org.apache.xalan.internal.xsltc.compiler.util.ReferenceType type)
Expects a boolean on the stack and pushes a boxed boolean. Boxed booleans are represented by an instance of java.lang.Boolean.

see
com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo

	final ConstantPoolGen cpg = classGen.getConstantPool();
	final InstructionList il = methodGen.getInstructionList();
	il.append(new NEW(cpg.addClass(BOOLEAN_CLASS)));
	il.append(DUP_X1);
	il.append(SWAP);
	il.append(new INVOKESPECIAL(cpg.addMethodref(BOOLEAN_CLASS,
						     "<init>",
						     "(Z)V")));
    
public voidtranslateTo(com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator classGen, com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator methodGen, java.lang.Class clazz)
Translates an internal boolean into an external (Java) boolean.

	if (clazz == java.lang.Boolean.TYPE) {
	    methodGen.getInstructionList().append(NOP);
	}
        // Is Boolean <: clazz? I.e. clazz in { Boolean, Object }
        else if (clazz.isAssignableFrom(java.lang.Boolean.class)) {
            translateTo(classGen, methodGen, Type.Reference);
        }
	else {
	    ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
					toString(), clazz.getName());
	    classGen.getParser().reportError(Constants.FATAL, err);
	}
    
public voidtranslateTo(com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator classGen, com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator methodGen, com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type type)
Translates a real into an object of internal type type. The translation to int is undefined since booleans are always converted to reals in arithmetic expressions.

see
com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo

	if (type == Type.String) {
	    translateTo(classGen, methodGen, (StringType) type);
	}
	else if (type == Type.Real) {
	    translateTo(classGen, methodGen, (RealType) type);
	}
	else if (type == Type.Reference) {
	    translateTo(classGen, methodGen, (ReferenceType) type);
	}
	else {
	    ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
					toString(), type.toString());
	    classGen.getParser().reportError(Constants.FATAL, err);
	}
    
public voidtranslateTo(com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator classGen, com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator methodGen, com.sun.org.apache.xalan.internal.xsltc.compiler.util.StringType type)
Expects a boolean on the stack and pushes a string. If the value on the stack is zero, then the string 'false' is pushed. Otherwise, the string 'true' is pushed.

see
com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo

	final ConstantPoolGen cpg = classGen.getConstantPool();
	final InstructionList il = methodGen.getInstructionList();
	final BranchHandle falsec = il.append(new IFEQ(null));
	il.append(new PUSH(cpg, "true"));
	final BranchHandle truec = il.append(new GOTO(null));
	falsec.setTarget(il.append(new PUSH(cpg, "false")));
	truec.setTarget(il.append(NOP));
    
public voidtranslateTo(com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator classGen, com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator methodGen, com.sun.org.apache.xalan.internal.xsltc.compiler.util.RealType type)
Expects a boolean on the stack and pushes a real. The value "true" is converted to 1.0 and the value "false" to 0.0.

see
com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo

	methodGen.getInstructionList().append(I2D);
    
public voidtranslateUnBox(com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator classGen, com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator methodGen)
Translates an object of this type to its unboxed representation.

	final ConstantPoolGen cpg = classGen.getConstantPool();
	final InstructionList il = methodGen.getInstructionList();
	il.append(new CHECKCAST(cpg.addClass(BOOLEAN_CLASS)));
	il.append(new INVOKEVIRTUAL(cpg.addMethodref(BOOLEAN_CLASS,
						     BOOLEAN_VALUE, 
						     BOOLEAN_VALUE_SIG)));