@Test public void testUsedStructIsNotRemoved() throws Exception { final String program = "struct S { float x; };\n" + "void main() {\n" + " gl_FragColor = vec4(S(3.0).x);\n" + "}\n"; final TranslationUnit tu = ParseHelper.parse(program); final List<GlobalVariablesDeclarationReductionOpportunity> ops = GlobalVariablesDeclarationReductionOpportunities .findOpportunities(MakeShaderJobFromFragmentShader.make(tu), new ReducerContext(false, ShadingLanguageVersion.ESSL_100, new RandomWrapper(0), new IdGenerator())); assertEquals(0, ops.size()); }
static List<GlobalVariablesDeclarationReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Arrays.asList(), ListConcat::concatenate); }
GlobalVariablesDeclarationReductionOpportunities extends ReductionOpportunitiesBase<GlobalVariablesDeclarationReductionOpportunity> { static List<GlobalVariablesDeclarationReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Arrays.asList(), ListConcat::concatenate); } }
GlobalVariablesDeclarationReductionOpportunities extends ReductionOpportunitiesBase<GlobalVariablesDeclarationReductionOpportunity> { static List<GlobalVariablesDeclarationReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Arrays.asList(), ListConcat::concatenate); } private  GlobalVariablesDeclarationReductionOpportunities(TranslationUnit tu,
                                                           ReducerContext context); }
GlobalVariablesDeclarationReductionOpportunities extends ReductionOpportunitiesBase<GlobalVariablesDeclarationReductionOpportunity> { static List<GlobalVariablesDeclarationReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Arrays.asList(), ListConcat::concatenate); } private  GlobalVariablesDeclarationReductionOpportunities(TranslationUnit tu,
                                                           ReducerContext context); @Override void visitVariablesDeclaration(VariablesDeclaration variablesDeclaration); @Override void visitFunctionDefinition(FunctionDefinition functionDefinition); }
GlobalVariablesDeclarationReductionOpportunities extends ReductionOpportunitiesBase<GlobalVariablesDeclarationReductionOpportunity> { static List<GlobalVariablesDeclarationReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Arrays.asList(), ListConcat::concatenate); } private  GlobalVariablesDeclarationReductionOpportunities(TranslationUnit tu,
                                                           ReducerContext context); @Override void visitVariablesDeclaration(VariablesDeclaration variablesDeclaration); @Override void visitFunctionDefinition(FunctionDefinition functionDefinition);  }