Search in sources :

Example 1 with ScriptCache

use of com.github.anba.es6draft.runtime.internal.ScriptCache in project es6draft by anba.

the class ShellGlobalObject method include.

/**
     * Parses, compiles and executes the javascript file. (Uses the script cache.)
     * 
     * @param file
     *            the path to the script file
     * @throws IOException
     *             if there was any I/O error
     * @throws ParserException
     *             if the source contains any syntax errors
     * @throws CompilationException
     *             if the parsed source could not be compiled
     */
public void include(Path file) throws IOException, ParserException, CompilationException {
    Realm realm = getRealm();
    ScriptCache scriptCache = getRuntimeContext().getScriptCache();
    Path path = getRuntimeContext().getBaseDirectory().resolve(file);
    Script script = scriptCache.get(realm.getScriptLoader(), path);
    script.evaluate(realm);
}
Also used : Path(java.nio.file.Path) Script(com.github.anba.es6draft.Script) ScriptCache(com.github.anba.es6draft.runtime.internal.ScriptCache) Realm(com.github.anba.es6draft.runtime.Realm)

Example 2 with ScriptCache

use of com.github.anba.es6draft.runtime.internal.ScriptCache in project es6draft by anba.

the class TestGlobals method before.

@Override
protected void before() throws Throwable {
    if (!Resources.isEnabled(configuration)) {
        // skip initialization if test suite not enabled
        return;
    }
    scriptCache = new ScriptCache();
    // read options ...
    EnumSet<CompatibilityOption> compatibilityOptions = EnumSet.noneOf(CompatibilityOption.class);
    optionsFromMode(compatibilityOptions, configuration.getString("mode", DEFAULT_MODE));
    optionsFromVersion(compatibilityOptions, configuration.getString("version", DEFAULT_VERSION));
    optionsFromStage(compatibilityOptions, configuration.getString("stage", DEFAULT_STAGE));
    optionsFromFeatures(compatibilityOptions, configuration.getList("features", DEFAULT_FEATURES));
    options = compatibilityOptions;
    // pre-compile initialization scripts and modules
    scripts = compileScripts();
    modules = compileModules();
}
Also used : CompatibilityOption(com.github.anba.es6draft.runtime.internal.CompatibilityOption) ScriptCache(com.github.anba.es6draft.runtime.internal.ScriptCache)

Aggregations

ScriptCache (com.github.anba.es6draft.runtime.internal.ScriptCache)2 Script (com.github.anba.es6draft.Script)1 Realm (com.github.anba.es6draft.runtime.Realm)1 CompatibilityOption (com.github.anba.es6draft.runtime.internal.CompatibilityOption)1 Path (java.nio.file.Path)1