com.sun.tools.javac.tree.JCTree.JCWhileLoop Java Examples

The following examples show how to use com.sun.tools.javac.tree.JCTree.JCWhileLoop. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PrettyCommentsPrinter.java    From EasyMPermission with MIT License 6 votes vote down vote up
public void visitWhileLoop(JCWhileLoop tree) {
	try {
		print("while ");
		if (PARENS.equals(treeTag(tree.cond))) {
			printExpr(tree.cond);
		} else {
			print("(");
			printExpr(tree.cond);
			print(")");
		}
		print(" ");
		printStat(tree.body);
	} catch (IOException e) {
		throw new UncheckedIOException(e);
	}
}
 
Example #2
Source File: Flow.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void visitWhileLoop(JCWhileLoop tree) {
    ListBuffer<PendingExit> prevPendingExits = pendingExits;
    pendingExits = new ListBuffer<>();
    scan(tree.cond);
    alive = !tree.cond.type.isFalse();
    scanStat(tree.body);
    alive |= resolveContinues(tree);
    alive = resolveBreaks(tree, prevPendingExits) ||
        !tree.cond.type.isTrue();
}
 
Example #3
Source File: Flow.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void visitWhileLoop(JCWhileLoop tree) {
    ListBuffer<FlowPendingExit> prevPendingExits = pendingExits;
    pendingExits = new ListBuffer<>();
    scan(tree.cond);
    scan(tree.body);
    resolveContinues(tree);
    resolveBreaks(tree, prevPendingExits);
}
 
Example #4
Source File: Flow.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void visitWhileLoop(JCWhileLoop tree) {
    ListBuffer<AssignPendingExit> prevPendingExits = pendingExits;
    FlowKind prevFlowKind = flowKind;
    flowKind = FlowKind.NORMAL;
    final Bits initsSkip = new Bits(true);
    final Bits uninitsSkip = new Bits(true);
    pendingExits = new ListBuffer<>();
    int prevErrors = log.nerrors;
    final Bits uninitsEntry = new Bits(uninits);
    uninitsEntry.excludeFrom(nextadr);
    do {
        scanCond(tree.cond);
        if (!flowKind.isFinal()) {
            initsSkip.assign(initsWhenFalse) ;
            uninitsSkip.assign(uninitsWhenFalse);
        }
        inits.assign(initsWhenTrue);
        uninits.assign(uninitsWhenTrue);
        scan(tree.body);
        resolveContinues(tree);
        if (log.nerrors != prevErrors ||
            flowKind.isFinal() ||
            new Bits(uninitsEntry).diffSet(uninits).nextBit(firstadr) == -1) {
            break;
        }
        uninits.assign(uninitsEntry.andSet(uninits));
        flowKind = FlowKind.SPECULATIVE_LOOP;
    } while (true);
    flowKind = prevFlowKind;
    //a variable is DA/DU after the while statement, if it's DA/DU assuming the
    //branch is not taken AND if it's DA/DU before any break statement
    inits.assign(initsSkip);
    uninits.assign(uninitsSkip);
    resolveBreaks(tree, prevPendingExits);
}
 
Example #5
Source File: CompilationUnitBuilder.java    From j2cl with Apache License 2.0 5 votes vote down vote up
private WhileStatement convertWhileLoop(JCWhileLoop statement) {
  return WhileStatement.newBuilder()
      .setSourcePosition(getSourcePosition(statement))
      .setConditionExpression(convertConditionRemovingOuterParentheses(statement.getCondition()))
      .setBody(convertStatement(statement.getStatement()))
      .build();
}
 
Example #6
Source File: CRTable.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void visitWhileLoop(JCWhileLoop tree) {
    SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
    sr.mergeWith(csp(tree.cond));
    sr.mergeWith(csp(tree.body));
    result = sr;
}
 
Example #7
Source File: TransTypes.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void visitWhileLoop(JCWhileLoop tree) {
    tree.cond = translate(tree.cond, syms.booleanType);
    tree.body = translate(tree.body);
    result = tree;
}
 
Example #8
Source File: Lower.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void visitWhileLoop(JCWhileLoop tree) {
    tree.cond = translate(tree.cond, syms.booleanType);
    tree.body = translate(tree.body);
    result = tree;
}
 
Example #9
Source File: Analyzer.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void visitWhileLoop(JCWhileLoop tree) {
    //skip body (to prevents same statements to be analyzed twice)
    scan(tree.getCondition());
}
 
Example #10
Source File: CompilationUnitBuilder.java    From j2cl with Apache License 2.0 4 votes vote down vote up
private Statement convertStatement(JCStatement jcStatement) {
  switch (jcStatement.getKind()) {
    case ASSERT:
      return convertAssert((JCAssert) jcStatement);
    case BLOCK:
      return convertBlock((JCBlock) jcStatement);
    case BREAK:
      return convertBreak((JCBreak) jcStatement);
    case CLASS:
      convertClassDeclaration((JCClassDecl) jcStatement);
      return null;
    case CONTINUE:
      return convertContinue((JCContinue) jcStatement);
    case DO_WHILE_LOOP:
      return convertDoWhileLoop((JCDoWhileLoop) jcStatement);
    case EMPTY_STATEMENT:
      return new EmptyStatement(getSourcePosition(jcStatement));
    case ENHANCED_FOR_LOOP:
      return convertEnhancedForLoop((JCEnhancedForLoop) jcStatement);
    case EXPRESSION_STATEMENT:
      return convertExpressionStatement((JCExpressionStatement) jcStatement);
    case FOR_LOOP:
      return convertForLoop((JCForLoop) jcStatement);
    case IF:
      return convertIf((JCIf) jcStatement);
    case LABELED_STATEMENT:
      return convertLabeledStatement((JCLabeledStatement) jcStatement);
    case RETURN:
      return convertReturn((JCReturn) jcStatement);
    case SWITCH:
      return convertSwitch((JCSwitch) jcStatement);
    case THROW:
      return convertThrow((JCThrow) jcStatement);
    case TRY:
      return convertTry((JCTry) jcStatement);
    case VARIABLE:
      return convertVariableDeclaration((JCVariableDecl) jcStatement);
    case WHILE_LOOP:
      return convertWhileLoop((JCWhileLoop) jcStatement);
    case SYNCHRONIZED:
      return convertSynchronized((JCSynchronized) jcStatement);
    default:
      throw new AssertionError("Unknown statement node type: " + jcStatement.getKind());
  }
}
 
Example #11
Source File: Analyzer.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void visitWhileLoop(JCWhileLoop tree) {
    scan(tree.getCondition());
}
 
Example #12
Source File: JavacTreeMaker.java    From EasyMPermission with MIT License 4 votes vote down vote up
public JCWhileLoop WhileLoop(JCExpression cond, JCStatement body) {
	return invoke(WhileLoop, cond, body);
}
 
Example #13
Source File: UWhileLoop.java    From Refaster with Apache License 2.0 4 votes vote down vote up
@Override
public JCWhileLoop inline(Inliner inliner) throws CouldNotResolveImportException {
  return inliner.maker().WhileLoop(
      getCondition().inline(inliner),
      getStatement().inline(inliner));
}