@Test public void testNotInjected() throws Exception { final String program = "void foo(int x) { switch(x) { case 0: default: break; } }"; final TranslationUnit tu = ParseHelper.parse(program); List<UnswitchifyReductionOpportunity> ops = UnswitchifyReductionOpportunities .findOpportunities(MakeShaderJobFromFragmentShader.make(tu), new ReducerContext(false, ShadingLanguageVersion.GLSL_130, new RandomWrapper(0), new IdGenerator())); assertEquals(0, ops.size()); }
static List<UnswitchifyReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Arrays.asList(), ListConcat::concatenate); }
UnswitchifyReductionOpportunities extends ReductionOpportunitiesBase<UnswitchifyReductionOpportunity> { static List<UnswitchifyReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Arrays.asList(), ListConcat::concatenate); } }
UnswitchifyReductionOpportunities extends ReductionOpportunitiesBase<UnswitchifyReductionOpportunity> { static List<UnswitchifyReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Arrays.asList(), ListConcat::concatenate); } private  UnswitchifyReductionOpportunities(
        TranslationUnit tu,
        ReducerContext context); }
UnswitchifyReductionOpportunities extends ReductionOpportunitiesBase<UnswitchifyReductionOpportunity> { static List<UnswitchifyReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Arrays.asList(), ListConcat::concatenate); } private  UnswitchifyReductionOpportunities(
        TranslationUnit tu,
        ReducerContext context); @Override void visitSwitchStmt(SwitchStmt switchStmt); }
UnswitchifyReductionOpportunities extends ReductionOpportunitiesBase<UnswitchifyReductionOpportunity> { static List<UnswitchifyReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Arrays.asList(), ListConcat::concatenate); } private  UnswitchifyReductionOpportunities(
        TranslationUnit tu,
        ReducerContext context); @Override void visitSwitchStmt(SwitchStmt switchStmt);  }