InjectionPoint(FunctionDefinition enclosingFunction, boolean inLoop, Scope scope) { this.enclosingFunction = enclosingFunction; this.inLoop = inLoop; this.scope = scope.shallowClone(); }
/** * Clones the scope, recursively cloning all parents, but does not deep-clone the mappings. * @return Cloned scope */ public Scope shallowClone() { Scope result = new Scope(parent == null ? null : parent.shallowClone()); for (Entry<String, ScopeEntry> entry : variableMapping.entrySet()) { result.variableMapping.put(entry.getKey(), entry.getValue()); } for (Entry<String, StructDefinitionType> entry : structMapping.entrySet()) { result.structMapping.put(entry.getKey(), entry.getValue()); } return result; }
private void identifyMutationPoints(Expr expr, Set<Integer> indicesToSkip) { if (insideLValueCount == 0) { for (int i = 0; i < expr.getNumChildren(); i++) { if (indicesToSkip.contains(i)) { continue; } if (typer.hasType(expr.getChild(i))) { Scope clonedScope = currentScope.shallowClone(); if (shadingLanguageVersion.restrictedForLoops()) { for (Set<String> iterators : forLoopIterators) { iterators.forEach(clonedScope::remove); } } mutationPoints.add(new MutationPoint(expr, i, typer.lookupType(expr.getChild(i)), clonedScope, isConstContext(), shadingLanguageVersion, generator, generationParams)); } } } }
.shallowClone()), shadingLanguageVersion, generator,
final Scope scopeForFuzzing = injectionPoint.scopeAtInjectionPoint().shallowClone(); for (StructDefinitionType sdt : donationContext.getAvailableStructs()) { scopeForFuzzing.addStructDefinition(sdt);