DonationContext getDonationContext() { final Stmt donorFragment = donorFragments.get(generator.nextInt(donorFragments.size())); final FreeVariablesCollector fvCollector = new FreeVariablesCollector(donor, donorFragment); final AvailableStructsCollector asCollector = new AvailableStructsCollector(donor, donorFragment); final Stmt clonedDonorFragment = donorFragment.clone(); if (clonedDonorFragment instanceof BlockStmt) { // If we got the donor fragment from a function body, it may not introduce a new scope. // We ensure that the donor fragment to be used in the // com.graphicsfuzz.generator.transformation.donation context does. ((BlockStmt) clonedDonorFragment).setIntroducesNewScope(true); } return new DonationContext(clonedDonorFragment, fvCollector.getFreeVariables(), asCollector.getStructDefinitionTypes(), enclosingFunction.get(donorFragment)); }