@Test public void testDoNotRemoveConstantUsedToInitializeArray() throws Exception { final String program = "" + "#version 310 es\n" + "const int N = 5;\n" + "const int M = 6;\n" + "int A[N];\n" + "void main() {\n" + " int B[M];\n" + " const int P = 7;\n" + " int C[P];\n" + " A[0] = 1;\n" + " B[0] = 2;\n" + " C[0] = 3;\n" + "}\n"; final TranslationUnit tu = ParseHelper.parse(program); List<VariableDeclReductionOpportunity> ops = VariableDeclReductionOpportunities .findOpportunities( MakeShaderJobFromFragmentShader.make(tu), new ReducerContext( false, ShadingLanguageVersion.ESSL_310, new RandomWrapper(0), new IdGenerator()) ); assertEquals(0, ops.size()); }
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);  }