FileDocCategorySizeDatePackage
If.javaAPI DocJava SE 6 API3633Tue Jun 10 00:22:28 BST 2008com.sun.org.apache.xalan.internal.xsltc.compiler

If

public final class If extends Instruction
author
Jacek Ambroziak
author
Santiago Pericas-Geertsen
author
Morten Jorgensen

Fields Summary
private Expression
_test
private boolean
_ignore
Constructors Summary
Methods Summary
public voiddisplay(int indent)
Display the contents of this element


               
        
	indent(indent);
	Util.println("If");
	indent(indent + IndentIncrement);
	System.out.print("test ");
	Util.println(_test.toString());
	displayContents(indent + IndentIncrement);
    
public voidparseContents(com.sun.org.apache.xalan.internal.xsltc.compiler.Parser parser)
Parse the "test" expression and contents of this element.

	// Parse the "test" expression
	_test = parser.parseExpression(this, "test", null);

        // Make sure required attribute(s) have been set
        if (_test.isDummy()) {
	    reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "test");
	    return;
        }

	// Ignore xsl:if when test is false (function-available() and
	// element-available())
	Object result = _test.evaluateAtCompileTime();
	if (result != null && result instanceof Boolean) {
	    _ignore = !((Boolean) result).booleanValue();
	}

	parseChildren(parser);
    
public voidtranslate(com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator classGen, com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator methodGen)
Translate the "test" expression and contents of this element. The contents will be ignored if we know the test will always fail.

	final InstructionList il = methodGen.getInstructionList();
	_test.translateDesynthesized(classGen, methodGen);
	// remember end of condition
	final InstructionHandle truec = il.getEnd();
	if (!_ignore) {
	    translateContents(classGen, methodGen);
	}
	_test.backPatchFalseList(il.append(NOP));
	_test.backPatchTrueList(truec.getNext());
    
public com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypetypeCheck(com.sun.org.apache.xalan.internal.xsltc.compiler.SymbolTable stable)
Type-check the "test" expression and contents of this element. The contents will be ignored if we know the test will always fail.

	// Type-check the "test" expression
	if (_test.typeCheck(stable) instanceof BooleanType == false) {
	    _test = new CastExpr(_test, Type.Boolean);
	}
	// Type check the element contents
	if (!_ignore) {
	    typeCheckContents(stable);
	}
	return Type.Void;