@Test public void testDoNotReduceIfPreservingSemantics() throws Exception { final String original = "void main() {\n" + " if (" + Constants.GLF_DEAD + "(false)) {\n" + " switch (0) {\n" + " case 0:\n" + " return;\n" + " }\n" + " }\n" + "}\n"; final TranslationUnit tu = ParseHelper.parse(original); final List<VariableDeclToExprReductionOpportunity> ops = VariableDeclToExprReductionOpportunities .findOpportunities(MakeShaderJobFromFragmentShader.make(tu), new ReducerContext(false, ShadingLanguageVersion.ESSL_320, new RandomWrapper(0), new IdGenerator())); assertTrue(ops.isEmpty()); }
static List<SwitchToLoopReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Collections.emptyList(), ListConcat::concatenate); }
SwitchToLoopReductionOpportunities extends
    ReductionOpportunitiesBase<SwitchToLoopReductionOpportunity> { static List<SwitchToLoopReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Collections.emptyList(), ListConcat::concatenate); } }
SwitchToLoopReductionOpportunities extends
    ReductionOpportunitiesBase<SwitchToLoopReductionOpportunity> { static List<SwitchToLoopReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Collections.emptyList(), ListConcat::concatenate); } private  SwitchToLoopReductionOpportunities(TranslationUnit tu, ReducerContext context); }
SwitchToLoopReductionOpportunities extends
    ReductionOpportunitiesBase<SwitchToLoopReductionOpportunity> { static List<SwitchToLoopReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Collections.emptyList(), ListConcat::concatenate); } private  SwitchToLoopReductionOpportunities(TranslationUnit tu, ReducerContext context); @Override void visitSwitchStmt(SwitchStmt switchStmt); }
SwitchToLoopReductionOpportunities extends
    ReductionOpportunitiesBase<SwitchToLoopReductionOpportunity> { static List<SwitchToLoopReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Collections.emptyList(), ListConcat::concatenate); } private  SwitchToLoopReductionOpportunities(TranslationUnit tu, ReducerContext context); @Override void visitSwitchStmt(SwitchStmt switchStmt);  }