private List<Stmt> regionStackToStmts(List<List<Stmt>> regionStack) { if (regionStack.size() == 1) { return regionStack.get(0); } final List<Stmt> result = new ArrayList<>(); result.addAll(regionStack.get(0)); // Check that the remainder actually contains some statements if (regionStack.subList(1, regionStack.size()).stream().anyMatch(item -> !item.isEmpty())) { result.add(new IfStmt( new UnaryExpr(makeHasReturned(), UnOp.LNOT), new BlockStmt(regionStackToStmts( regionStack.subList(1, regionStack.size())), true), null)); } return result; }
private void handleRestrictedForLoop(ForStmt forStmt) { if (containsReturn(forStmt)) { forStmt.setBody(new BlockStmt( Arrays.asList( new IfStmt( makeHasReturned(), new BlockStmt(Arrays.asList(BreakStmt.INSTANCE), true), null), forStmt.getBody()), false)); } }
@Override public IfStmt clone() { return new IfStmt(condition.clone(), thenStmt.clone(), elseStmt == null ? null : elseStmt.clone()); }
private IfStmt fuzzIfStmt() { final Expr condition = fuzzExpr(BasicType.BOOL, false, false, 0); final Stmt thenStmt = fuzzBlockStmt(true); Stmt elseStmt = null; if (generator.nextBoolean()) { elseStmt = fuzzBlockStmt(true); } return new IfStmt(condition, thenStmt, elseStmt); }
@Override public IfStmt visitSelection_statement(Selection_statementContext ctx) { Stmt thenStmt = visitStatement(ctx.selection_rest_statement().statement(0)); StatementContext maybeElseBranch = ctx.selection_rest_statement().statement(1); Stmt elseStmt = (maybeElseBranch == null ? null : visitStatement(maybeElseBranch)); return new IfStmt(visitExpression(ctx.expression()), thenStmt, elseStmt); }
IfStmt donatedStmt = new IfStmt( new OpaqueExpressionGenerator(generator, generationParams, shadingLanguageVersion) .makeDeadCondition(
static IfStmt makeDeadConditional(IInjectionPoint injectionPoint, Stmt thenStmt, IRandom generator, ShadingLanguageVersion shadingLanguageVersion, GenerationParams generationParams) { return new IfStmt( new OpaqueExpressionGenerator(generator, generationParams, shadingLanguageVersion) .makeDeadCondition( new Fuzzer(new FuzzingContext(injectionPoint.scopeAtInjectionPoint()), shadingLanguageVersion, generator, generationParams)), thenStmt, null); }
return new IfStmt( makeWrappedIfCondition(opaqueExpressionGenerator.makeOpaqueBoolean(true, BasicType.BOOL, false, 0, fuzzer), true), stmt, emptyBlock()); case 1: // if(false) { } else { stmt; } return new IfStmt( makeWrappedIfCondition(opaqueExpressionGenerator.makeOpaqueBoolean(false, BasicType.BOOL, false, 0, fuzzer), false),
new IfStmt( new BinaryExpr( new VariableIdentifierExpr(limiterName),
generationParams, shadingLanguageVersion); stmts.add(new IfStmt(AddWrappingConditionalStmts.makeWrappedIfCondition( opaqueExpressionGenerator.makeOpaqueBoolean(true, BasicType.BOOL, false, 0, fuzzer), true),