private Stream<IExprTemplate> availableTemplatesFromContext() { List<IExprTemplate> available = new LinkedList<>(); for (String name : fuzzingContext.getCurrentScope().namesOfAllVariablesInScope()) { available.add(new VariableIdentifierExprTemplate(name, fuzzingContext.getCurrentScope().lookupType(name))); } for (FunctionPrototype proto : fuzzingContext.getFunctionPrototypes()) { available.add(new FunctionCallExprTemplate(proto)); } return available.stream(); }
private boolean incompatible(IInjectionPoint injectionPoint, DonationContext donationContext, ShadingLanguageVersion shadingLanguageVersion) { // It is a problem if the injection point has an available variable that has the same name // as a function called from the donation context if (injectionPoint.scopeAtInjectionPoint().namesOfAllVariablesInScope().stream().anyMatch( item -> getCalledFunctions(donationContext.getDonorFragment()).contains(item))) { return true; } if (shadingLanguageVersion.isWebGl()) { // TODO: revisit in case this was just a WebGL 1 restriction; maybe it is OK in WebGL 2 if (donationContext.indexesArrayUsingFreeVariable()) { return true; } } return false; }
private Map<String,Type> getAvailableOutVars(Scope scope, ShadingLanguageVersion shadingLanguageVersion, GenerationParams generationParams) { final Map<String, Type> result = new HashMap<>(); if (generationParams.getShaderKind() == ShaderKind.FRAGMENT) { if (shadingLanguageVersion.supportedGlFragColor()) { result.put(OpenGlConstants.GL_FRAG_COLOR, BasicType.VEC4); } } if (generationParams.getShaderKind() == ShaderKind.VERTEX) { result.put(OpenGlConstants.GL_POSITION, BasicType.VEC4); result.put(OpenGlConstants.GL_POINT_SIZE, BasicType.FLOAT); } for (String name : scope.namesOfAllVariablesInScope()) { final Type type = scope.lookupType(name); if (type instanceof QualifiedType && ((QualifiedType) type) .hasQualifier(TypeQualifier.SHADER_OUTPUT)) { result.put(name, type.getWithoutQualifiers()); } } return result; }
if (probabilities.substituteFreeVariable(generator)) { List<String> options = injectionPoint.scopeAtInjectionPoint().namesOfAllVariablesInScope() .stream() .filter(x -> injectionPoint.scopeAtInjectionPoint().lookupType(x).equals(type))