use of com.github.anba.es6draft.runtime.internal.RuntimeContext in project es6draft by anba.
the class TestGlobals method newGlobal.
public final GLOBAL newGlobal(Console console, TEST test) throws MalformedNameException, ResolutionException, IOException, URISyntaxException {
RuntimeContext context = createContext(console, test);
World world = new World(context);
Realm realm = world.newInitializedRealm();
// Evaluate additional initialization scripts and modules
TestModuleLoader<?> moduleLoader = (TestModuleLoader<?>) world.getModuleLoader();
for (ModuleRecord module : modules.allModules) {
moduleLoader.defineFromTemplate(module, realm);
}
for (ModuleRecord module : modules.mainModules) {
ModuleRecord testModule = moduleLoader.get(module.getSourceCodeId(), realm);
testModule.instantiate();
testModule.evaluate();
}
for (Script script : scripts) {
script.evaluate(realm);
}
@SuppressWarnings("unchecked") GLOBAL global = (GLOBAL) realm.getGlobalObject();
return global;
}
use of com.github.anba.es6draft.runtime.internal.RuntimeContext in project es6draft by anba.
the class TestGlobals method compileScripts.
private List<Script> compileScripts() throws IOException {
List<?> scriptNames = configuration.getList("scripts", emptyList());
if (scriptNames.isEmpty()) {
return Collections.emptyList();
}
Path basedir = getBaseDirectory();
RuntimeContext context = createContext();
ScriptLoader scriptLoader = new ScriptLoader(context);
ArrayList<Script> scripts = new ArrayList<>();
for (String scriptName : nonEmpty(scriptNames)) {
Source source = new Source(Resources.resourcePath(scriptName, basedir), scriptName, 1);
Script script = scriptLoader.script(source, Resources.resource(scriptName, basedir));
scripts.add(script);
}
return scripts;
}
Aggregations