<commit_before>/* Soot - a J*va Optimization Framework
 * Copyright (C) 2002 <NAME>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

package soot.jimple.spark.builder;
import soot.jimple.spark.*;
import soot.jimple.spark.pag.*;
import soot.jimple.toolkits.callgraph.*;
import soot.jimple.toolkits.pointer.util.NativeMethodDriver;
import soot.jimple.toolkits.pointer.util.NativeHelper;
import soot.jimple.toolkits.pointer.DumbPointerAnalysis;
import soot.*;
import java.util.*;
import soot.jimple.*;
import soot.jimple.spark.internal.*;
import soot.jimple.spark.sets.PointsToSetInternal;
import soot.jimple.spark.solver.OnFlyCallGraph;
import soot.util.queue.*;
import soot.options.*;

/** A context insensitive pointer assignment graph builder.
 * @author <NAME>
 */
public class ContextInsensitiveBuilder {
    public void preJimplify() {
        for( Iterator cIt = Scene.v().getClasses().iterator(); cIt.hasNext(); ) {
            final SootClass c = (SootClass) cIt.next();
            for( Iterator mIt = c.methodIterator(); mIt.hasNext(); ) {
                final SootMethod m = (SootMethod) mIt.next();
                if( !m.isConcrete() ) continue;
                if( m.isNative() ) continue;
                if( m.isPhantom() ) continue;
                m.retrieveActiveBody();
            }
        }
    }
    /** Creates an empty pointer assignment graph. */
    public AbstractPAG setup( AbstractSparkOptions opts ) {
        if( opts instanceof SparkOptions ) {
            pag = new PAG( (SparkOptions) opts );
        } else if( opts instanceof BDDSparkOptions ) {
            pag = new BDDPAG( (BDDSparkOptions) opts );
        } else throw new RuntimeException();
        if( opts.simulate_natives() ) {<commit_msg>Spark pre-jimplify option would crash with ConcurrentModificationException because retrieving a method caused classes to get loaded and added to the list of classes. Fix is to take a snapshot of the loaded classes, and iterate the pre-jimplification until no more methods are retrieved.<commit_after>/* Soot - a J*va Optimization Framework
 * Copyright (C) 2002 <NAME>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

package soot.jimple.spark.builder;
import soot.jimple.spark.*;
import soot.jimple.spark.pag.*;
import soot.jimple.toolkits.callgraph.*;
import soot.jimple.toolkits.pointer.util.NativeMethodDriver;
import soot.jimple.toolkits.pointer.util.NativeHelper;
import soot.jimple.toolkits.pointer.DumbPointerAnalysis;
import soot.*;
import java.util.*;
import soot.jimple.*;
import soot.jimple.spark.internal.*;
import soot.jimple.spark.sets.PointsToSetInternal;
import soot.jimple.spark.solver.OnFlyCallGraph;
import soot.util.queue.*;
import soot.options.*;

/** A context insensitive pointer assignment graph builder.
 * @author <NAME>
 */
public class ContextInsensitiveBuilder {
    public void preJimplify() {
        boolean change = true;
        while( change ) {
            change = false;
            for( Iterator cIt = new ArrayList(Scene.v().getClasses()).iterator(); cIt.hasNext(); ) {
                final SootClass c = (SootClass) cIt.next();
                for( Iterator mIt = c.methodIterator(); mIt.hasNext(); ) {
                    final SootMethod m = (SootMethod) mIt.next();
                    if( !m.isConcrete() ) continue;
                    if( m.isNative() ) continue;
                    if( m.isPhantom() ) continue;
                    if( !m.hasActiveBody() ) {
                        change = true;
                        m.retrieveActiveBody();
                    }
                }
            }
        }
    }
    /** Creates an empty pointer assignment graph. */
    public AbstractPAG setup( AbstractSparkOptions opts ) {
        if( opts instanceof SparkOptions ) {
            pag = new PAG( (SparkOptions) opts );
        } else if( opts instanceof BDDSparkOptions ) {
            pag = new BDDPAG( (BDDSparkOptions) opts );
        } else throw new RuntimeException();
        if( opts.simulate_natives() ) {
{'fraction_non_alphanumeric': 0.0963922294172063, 'fraction_numerical': 0.0074005550416281225, 'mean_word_length': 2.8422174840085286, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6959206', 'n_tokens_mistral': 1566, 'n_tokens_neox': 1433, 'n_words': 528}