@Test public void testNamedStruct() throws Exception { final String program = "struct A { int x; } b; void main() { A c; c.x = 2; }\n"; final String reducedProgram = "struct A { int x; }; void main() { A c; c.x = 2; }\n"; final TranslationUnit tu = ParseHelper.parse(program); List<VariableDeclReductionOpportunity> ops = VariableDeclReductionOpportunities .findOpportunities(MakeShaderJobFromFragmentShader.make(tu), new ReducerContext(false, ShadingLanguageVersion.ESSL_100, new RandomWrapper(0), new IdGenerator())); assertEquals(1, ops.size()); ops.get(0).applyReduction(); CompareAsts.assertEqualAsts(reducedProgram, tu); }
static List<VariableDeclReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Arrays.asList(), ListConcat::concatenate); }
VariableDeclReductionOpportunities extends ReductionOpportunitiesBase<VariableDeclReductionOpportunity> { static List<VariableDeclReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Arrays.asList(), ListConcat::concatenate); } }
VariableDeclReductionOpportunities extends ReductionOpportunitiesBase<VariableDeclReductionOpportunity> { static List<VariableDeclReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Arrays.asList(), ListConcat::concatenate); } private  VariableDeclReductionOpportunities(TranslationUnit tu,
                                             ReducerContext context); }
VariableDeclReductionOpportunities extends ReductionOpportunitiesBase<VariableDeclReductionOpportunity> { static List<VariableDeclReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Arrays.asList(), ListConcat::concatenate); } private  VariableDeclReductionOpportunities(TranslationUnit tu,
                                             ReducerContext context); @Override void visitVariableIdentifierExpr(VariableIdentifierExpr variableIdentifierExpr); }
VariableDeclReductionOpportunities extends ReductionOpportunitiesBase<VariableDeclReductionOpportunity> { static List<VariableDeclReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Arrays.asList(), ListConcat::concatenate); } private  VariableDeclReductionOpportunities(TranslationUnit tu,
                                             ReducerContext context); @Override void visitVariableIdentifierExpr(VariableIdentifierExpr variableIdentifierExpr);  }