@Test public void checkForVariableInScope() throws Exception { final String program = "" + "struct _GLF_struct_1 {\n" + " float dist;\n" + "};\n" + "void main() {\n" + " int dist;\n" + " _GLF_struct_1 _GLF_struct_replacement_2 = _GLF_struct_1(1.0);\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(0, ops.size()); }
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);  }