@Test public void testDoNotInlineLargeInitializer() throws Exception { final String largeProgram = make1Plus1Plus1Program(100); final String smallProgram = make1Plus1Plus1Program(5); final String smallProgramInlined = make1Plus1Plus1ProgramInlined(5); final TranslationUnit largeProgramTu = ParseHelper.parse(largeProgram); final TranslationUnit smallProgramTu = ParseHelper.parse(smallProgram); List<SimplifyExprReductionOpportunity> ops = InlineInitializerReductionOpportunities .findOpportunities(MakeShaderJobFromFragmentShader.make(largeProgramTu), new ReducerContext(true, ShadingLanguageVersion.ESSL_100, new RandomWrapper(0), new IdGenerator())); assertEquals(0, ops.size()); ops = InlineInitializerReductionOpportunities .findOpportunities(MakeShaderJobFromFragmentShader.make(smallProgramTu), new ReducerContext(true, ShadingLanguageVersion.ESSL_100, new RandomWrapper(0), new IdGenerator())); assertEquals(3, ops.size()); ops.get(0).applyReduction(); ops.get(1).applyReduction(); ops.get(2).applyReduction(); CompareAsts.assertEqualAsts(smallProgramInlined, smallProgramTu); }
static List<SimplifyExprReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Arrays.asList(), ListConcat::concatenate); }
InlineInitializerReductionOpportunities extends ReductionOpportunitiesBase<SimplifyExprReductionOpportunity> { static List<SimplifyExprReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Arrays.asList(), ListConcat::concatenate); } }
InlineInitializerReductionOpportunities extends ReductionOpportunitiesBase<SimplifyExprReductionOpportunity> { static List<SimplifyExprReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Arrays.asList(), ListConcat::concatenate); } private  InlineInitializerReductionOpportunities(
        TranslationUnit tu,
        ReducerContext context); }
InlineInitializerReductionOpportunities extends ReductionOpportunitiesBase<SimplifyExprReductionOpportunity> { static List<SimplifyExprReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Arrays.asList(), ListConcat::concatenate); } private  InlineInitializerReductionOpportunities(
        TranslationUnit tu,
        ReducerContext context); @Override void visitVariableIdentifierExpr(VariableIdentifierExpr variableIdentifierExpr); }
InlineInitializerReductionOpportunities extends ReductionOpportunitiesBase<SimplifyExprReductionOpportunity> { static List<SimplifyExprReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Arrays.asList(), ListConcat::concatenate); } private  InlineInitializerReductionOpportunities(
        TranslationUnit tu,
        ReducerContext context); @Override void visitVariableIdentifierExpr(VariableIdentifierExpr variableIdentifierExpr);  }