@Test public void testEmptyBlock() throws Exception { final String program = "void main() {" + " {" + " }" + "}"; final String reducedProgram = "void main() {" + "}"; final TranslationUnit tu = ParseHelper.parse(program); List<? extends IReductionOpportunity> ops = StmtReductionOpportunities.findOpportunities(MakeShaderJobFromFragmentShader.make(tu), new ReducerContext(false, ShadingLanguageVersion.ESSL_100, new RandomWrapper(0), new IdGenerator())); assertEquals(1, ops.size()); assertTrue(ops.get(0) instanceof StmtReductionOpportunity); ops.get(0).applyReduction(); assertEquals(PrettyPrinterVisitor.prettyPrintAsString(ParseHelper.parse(reducedProgram)), PrettyPrinterVisitor.prettyPrintAsString(tu)); }
static List<StmtReductionOpportunity> findOpportunities(ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Arrays.asList(), ListConcat::concatenate); }
StmtReductionOpportunities extends ReductionOpportunitiesBase<StmtReductionOpportunity> { static List<StmtReductionOpportunity> findOpportunities(ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Arrays.asList(), ListConcat::concatenate); } }
StmtReductionOpportunities extends ReductionOpportunitiesBase<StmtReductionOpportunity> { static List<StmtReductionOpportunity> findOpportunities(ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Arrays.asList(), ListConcat::concatenate); } private  StmtReductionOpportunities(TranslationUnit tu,
        ReducerContext context); }
StmtReductionOpportunities extends ReductionOpportunitiesBase<StmtReductionOpportunity> { static List<StmtReductionOpportunity> findOpportunities(ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Arrays.asList(), ListConcat::concatenate); } private  StmtReductionOpportunities(TranslationUnit tu,
        ReducerContext context);  }
StmtReductionOpportunities extends ReductionOpportunitiesBase<StmtReductionOpportunity> { static List<StmtReductionOpportunity> findOpportunities(ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Arrays.asList(), ListConcat::concatenate); } private  StmtReductionOpportunities(TranslationUnit tu,
        ReducerContext context);   }