Search in sources :

Example 1 with ASceneWrapper

use of org.checkerframework.common.wholeprograminference.scenelib.ASceneWrapper in project checker-framework by typetools.

the class WholeProgramInferenceScenesStorage method writeResultsToFile.

@Override
public void writeResultsToFile(WholeProgramInference.OutputFormat outputFormat, BaseTypeChecker checker) {
    if (outputFormat == OutputFormat.AJAVA) {
        throw new BugInCF("WholeProgramInferenceScenes used with format " + outputFormat);
    }
    for (String file : modifiedScenes) {
        ASceneWrapper scene = scenes.get(file);
        prepareSceneForWriting(scene.getAScene());
    }
    writeScenes(outputFormat, checker);
}
Also used : ASceneWrapper(org.checkerframework.common.wholeprograminference.scenelib.ASceneWrapper) BugInCF(org.checkerframework.javacutil.BugInCF)

Example 2 with ASceneWrapper

use of org.checkerframework.common.wholeprograminference.scenelib.ASceneWrapper in project checker-framework by typetools.

the class WholeProgramInferenceScenesStorage method getClassAnnos.

/**
 * Get the annotations for a class.
 *
 * @param className the name of the class, in binary form
 * @param file the path to the file that represents the class
 * @param classSymbol optionally, the ClassSymbol representing the class
 * @return the annotations for the class
 */
private AClass getClassAnnos(@BinaryName String className, String file, @Nullable ClassSymbol classSymbol) {
    // Possibly reads .jaif file to obtain a Scene.
    ASceneWrapper scene = getScene(file);
    AClass aClass = scene.getAScene().classes.getVivify(className);
    scene.updateSymbolInformation(aClass, classSymbol);
    return aClass;
}
Also used : ASceneWrapper(org.checkerframework.common.wholeprograminference.scenelib.ASceneWrapper) AClass(scenelib.annotations.el.AClass)

Example 3 with ASceneWrapper

use of org.checkerframework.common.wholeprograminference.scenelib.ASceneWrapper in project checker-framework by typetools.

the class WholeProgramInferenceScenesStorage method getScene.

/**
 * Reads a Scene from the given .jaif file, or returns an empty Scene if the file does not exist.
 *
 * @param jaifPath the .jaif file
 * @return the Scene read from the file, or an empty Scene if the file does not exist
 */
private ASceneWrapper getScene(String jaifPath) {
    AScene scene;
    if (!scenes.containsKey(jaifPath)) {
        File jaifFile = new File(jaifPath);
        scene = new AScene();
        if (jaifFile.exists()) {
            try {
                IndexFileParser.parseFile(jaifPath, scene);
            } catch (IOException e) {
                throw new UserError("Problem while reading %s: %s", jaifPath, e.getMessage());
            }
        }
        ASceneWrapper wrapper = new ASceneWrapper(scene);
        scenes.put(jaifPath, wrapper);
        return wrapper;
    } else {
        return scenes.get(jaifPath);
    }
}
Also used : AScene(scenelib.annotations.el.AScene) ASceneWrapper(org.checkerframework.common.wholeprograminference.scenelib.ASceneWrapper) UserError(org.checkerframework.javacutil.UserError) IOException(java.io.IOException) File(java.io.File)

Example 4 with ASceneWrapper

use of org.checkerframework.common.wholeprograminference.scenelib.ASceneWrapper in project checker-framework by typetools.

the class WholeProgramInferenceScenesStorage method getAClass.

/**
 * Returns the scene-lib representation of the given className in the scene identified by the
 * given jaifPath.
 *
 * @param className the name of the class to get, in binary form
 * @param jaifPath the path to the jaif file that would represent that class (must end in ".jaif")
 * @param classSymbol optionally, the ClassSymbol representing the class. Used to set the symbol
 *     information stored on an AClass.
 * @return a version of the scene-lib representation of the class, augmented with symbol
 *     information if {@code classSymbol} was non-null
 */
protected AClass getAClass(@BinaryName String className, String jaifPath, @Nullable ClassSymbol classSymbol) {
    // Possibly reads .jaif file to obtain a Scene.
    ASceneWrapper scene = getScene(jaifPath);
    AClass aClass = scene.getAScene().classes.getVivify(className);
    scene.updateSymbolInformation(aClass, classSymbol);
    return aClass;
}
Also used : ASceneWrapper(org.checkerframework.common.wholeprograminference.scenelib.ASceneWrapper) AClass(scenelib.annotations.el.AClass)

Aggregations

ASceneWrapper (org.checkerframework.common.wholeprograminference.scenelib.ASceneWrapper)4 AClass (scenelib.annotations.el.AClass)2 File (java.io.File)1 IOException (java.io.IOException)1 BugInCF (org.checkerframework.javacutil.BugInCF)1 UserError (org.checkerframework.javacutil.UserError)1 AScene (scenelib.annotations.el.AScene)1