List of usage examples for org.eclipse.jdt.internal.compiler.ast Expression optimizedBooleanConstant
public Constant optimizedBooleanConstant()
From source file:com.google.gwt.dev.jjs.impl.GenerateJavaAST.java
License:Apache License
/** * Returns <code>true</code> if JDT optimized the condition to * <code>false</code>.//from ww w . j a va 2s. co m */ private static boolean isOptimizedFalse(Expression condition) { if (condition != null) { Constant cst = condition.optimizedBooleanConstant(); if (cst != Constant.NotAConstant) { if (cst.booleanValue() == false) { return true; } } } return false; }
From source file:com.google.gwt.dev.jjs.impl.GenerateJavaAST.java
License:Apache License
/** * Returns <code>true</code> if JDT optimized the condition to * <code>true</code>.//from w w w . j a v a 2 s . c om */ private static boolean isOptimizedTrue(Expression condition) { if (condition != null) { Constant cst = condition.optimizedBooleanConstant(); if (cst != Constant.NotAConstant) { if (cst.booleanValue()) { return true; } } } return false; }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.util.AstGenerator.java
License:Open Source License
/** * Assemble an ifstatement with negated condition, that hides the branch instruction from the debugger, * even when stepping into the condition. *//*from w w w. ja v a 2 s. co m*/ public IfStatement stealthIfNotStatement(final Expression condition, Statement thenStatement) { // mark step-over after the condition: Expression recordingCondition = new Expression() { public StringBuffer printExpression(int indent, StringBuffer output) { return condition.print(indent, output); } public TypeBinding resolveType(BlockScope scope) { return condition.resolveType(scope); } public void computeConversion(Scope scope, TypeBinding runtimeType, TypeBinding compileTimeType) { condition.computeConversion(scope, runtimeType, compileTimeType); this.constant = condition.constant; this.bits = condition.bits; } public Constant optimizedBooleanConstant() { this.constant = condition.optimizedBooleanConstant(); this.bits = condition.bits; return this.constant; } public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo, boolean valueRequired) { return condition.analyseCode(currentScope, flowContext, flowInfo, valueRequired); } public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) { return condition.analyseCode(currentScope, flowContext, flowInfo); } public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) { condition.generateCode(currentScope, codeStream, valueRequired); // payload: codeStream.pcToSourceMap[codeStream.pcToSourceMapSize++] = codeStream.position; codeStream.pcToSourceMap[codeStream.pcToSourceMapSize++] = STEP_OVER_LINENUMBER; } }; return new IfStatement(new UnaryExpression( // NOT recordingCondition, OperatorIds.NOT), thenStatement, this.sourceStart, this.sourceEnd); }