@Test public void misc() throws Exception { final String program = "struct _GLF_struct_65 {\n" + " vec3 GLF_live6p2;\n" + " mat2 _f1;\n" + " bvec3 _f2;\n" + " bvec3 _f3;\n" + "};\n" + "void main() {\n" + " float GLF_live6formuparam = 31.97;\n" + " _GLF_struct_65 _GLF_struct_replacement_66 = _GLF_struct_65(vec3(1.0), mat2(1.0), " + "bvec3(true), bvec3(true));\n" + " _GLF_struct_replacement_66.GLF_live6p2 = abs(_GLF_struct_replacement_66.GLF_live6p2)" + " / dot(_GLF_struct_replacement_66.GLF_live6p2, _GLF_struct_replacement_66" + ".GLF_live6p2) - GLF_live6formuparam;\n" + "}\n"; final String expected = "struct _GLF_struct_65 {\n" + " vec3 GLF_live6p2;\n" + " mat2 _f1;\n" + " bvec3 _f2;\n" + " bvec3 _f3;\n" + "};\n" + "void main() {\n" + " float GLF_live6formuparam = 31.97;\n" + " vec3 GLF_live6p2 = vec3(1.0);\n" + " GLF_live6p2 = abs(GLF_live6p2) / dot(GLF_live6p2, GLF_live6p2) - " + "GLF_live6formuparam;\n" + "}\n"; final TranslationUnit tu = ParseHelper.parse(program); final List<DestructifyReductionOpportunity> ops = DestructifyReductionOpportunities .findOpportunities(MakeShaderJobFromFragmentShader.make(tu), new ReducerContext(false, ShadingLanguageVersion.ESSL_100, new RandomWrapper(0), new IdGenerator())); assertEquals(1, ops.size()); ops.get(0).applyReduction(); assertEquals(PrettyPrinterVisitor.prettyPrintAsString(ParseHelper.parse(expected)), PrettyPrinterVisitor.prettyPrintAsString(tu)); }
static List<DestructifyReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(DestructifyReductionOpportunities::findOpportunitiesForShader) .reduce(Arrays.asList(), ListConcat::concatenate); }
DestructifyReductionOpportunities extends ScopeTrackingVisitor { static List<DestructifyReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(DestructifyReductionOpportunities::findOpportunitiesForShader) .reduce(Arrays.asList(), ListConcat::concatenate); } }
DestructifyReductionOpportunities extends ScopeTrackingVisitor { static List<DestructifyReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(DestructifyReductionOpportunities::findOpportunitiesForShader) .reduce(Arrays.asList(), ListConcat::concatenate); } private  DestructifyReductionOpportunities(TranslationUnit tu); }
DestructifyReductionOpportunities extends ScopeTrackingVisitor { static List<DestructifyReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(DestructifyReductionOpportunities::findOpportunitiesForShader) .reduce(Arrays.asList(), ListConcat::concatenate); } private  DestructifyReductionOpportunities(TranslationUnit tu); @Override void visitDeclarationStmt(DeclarationStmt declarationStmt); }
DestructifyReductionOpportunities extends ScopeTrackingVisitor { static List<DestructifyReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(DestructifyReductionOpportunities::findOpportunitiesForShader) .reduce(Arrays.asList(), ListConcat::concatenate); } private  DestructifyReductionOpportunities(TranslationUnit tu); @Override void visitDeclarationStmt(DeclarationStmt declarationStmt);  }