use of com.github.anba.es6draft.runtime.internal.RuntimeContext in project es6draft by anba.
the class DefaultLocaleTimezone method newRealm.
private static Realm newRealm(Locale locale) throws Exception {
RuntimeContext context = new RuntimeContext.Builder().setLocale(locale).build();
World world = new World(context);
return Realm.InitializeHostDefinedRealm(world);
}
use of com.github.anba.es6draft.runtime.internal.RuntimeContext in project es6draft by anba.
the class LocaleTest method newRealm.
private static Realm newRealm(String languageTag) throws Exception {
Locale locale = new Locale.Builder().setLanguageTag(languageTag).build();
RuntimeContext context = new RuntimeContext.Builder().setLocale(locale).setOptions(intlExtensions).build();
World world = new World(context);
return Realm.InitializeHostDefinedRealm(world);
}
use of com.github.anba.es6draft.runtime.internal.RuntimeContext in project es6draft by anba.
the class TestRealms method compileModules.
private PreloadModules compileModules() throws IOException, MalformedNameException {
List<String> moduleNames = Resources.list(configuration, "modules", emptyList());
if (moduleNames.isEmpty()) {
return new PreloadModules(Collections.<ModuleRecord>emptyList(), Collections.<ModuleRecord>emptyList());
}
Path basedir = getBaseDirectory();
RuntimeContext context = createContext();
ScriptLoader scriptLoader = new ScriptLoader(context);
TestModuleLoader<?> moduleLoader = getModuleLoader().apply(context, scriptLoader);
ArrayList<ModuleRecord> modules = new ArrayList<>();
for (String moduleName : moduleNames) {
Map.Entry<Path, String> resourceModule = Resources.resourceModule(moduleName);
ModuleRecord module;
if (resourceModule == null) {
SourceIdentifier moduleId = moduleLoader.normalizeName(moduleName, null);
module = moduleLoader.load(moduleId);
} else {
Path modulePath = basedir.resolve(resourceModule.getKey());
String sourceCode = resourceModule.getValue();
ResourceModuleSource moduleSource = new ResourceModuleSource(modulePath, sourceCode);
FileSourceIdentifier sourceId = new FileSourceIdentifier(modulePath);
module = moduleLoader.defineUnlinked(sourceId, moduleSource);
}
modules.add(module);
}
return new PreloadModules(modules, moduleLoader.getModules());
}
use of com.github.anba.es6draft.runtime.internal.RuntimeContext in project es6draft by anba.
the class Test262Parser method runTest.
@Test
public void runTest() throws Throwable {
RuntimeContext context = realms.newContext(new SystemConsole(), test);
ScriptLoader loader = new ScriptLoader(context);
Source source = new Source(test.toFile(), test.getScript().toString(), 1);
String sourceCode = new String(Files.readAllBytes(test.toFile()), StandardCharsets.UTF_8);
if (test.isModule()) {
loader.parseModule(source, sourceCode);
} else {
loader.parseScript(source, sourceCode);
}
}
Aggregations