use of com.github.anba.es6draft.runtime.Realm in project es6draft by anba.
the class ReflectParser method parse.
/**
* Parses the given script code and returns the matching Reflect AST nodes.
*
* @param cx
* the execution context
* @param sourceCode
* the source string
* @param location
* if set to {@code true} node locations will be recorded
* @param sourceInfo
* the source info string
* @param line
* the start line offset
* @param builder
* map to customize AST node processing
* @return the parsed node
*/
public static Object parse(ExecutionContext cx, String sourceCode, boolean location, String sourceInfo, int line, EnumMap<Type, Callable> builder) {
Realm realm = cx.getRealm();
ReflectParser reflect = new ReflectParser(cx, location, sourceInfo, builder);
Source source = new Source("<parse>", line);
TopLevelNode<?> parsedNode = null;
try {
parsedNode = realm.getScriptLoader().parseScript(source, sourceCode);
} catch (ParserException ignore) {
// TODO: Reflect.parse() currently accepts scripts and modules...
try {
parsedNode = realm.getScriptLoader().parseModule(source, sourceCode);
} catch (ParserException e) {
throw e.toScriptException(cx);
}
}
return parsedNode.accept(reflect, null);
}
use of com.github.anba.es6draft.runtime.Realm in project es6draft by anba.
the class LegacyConstructorFunction method FunctionAllocate.
/**
* 9.2.3 FunctionAllocate (functionPrototype, strict [,functionKind] )
*
* @param cx
* the execution context
* @param functionPrototype
* the function prototype
* @return the new function object
*/
public static LegacyConstructorFunction FunctionAllocate(ExecutionContext cx, ScriptObject functionPrototype) {
Realm realm = cx.getRealm();
/* steps 1-5 (implicit) */
/* steps 6-9 */
LegacyConstructorFunction f = new LegacyConstructorFunction(realm);
/* steps 10-14 */
f.allocate(realm, functionPrototype, false, FunctionKind.Normal, ConstructorKind.Base);
/* step 15 */
return f;
}
use of com.github.anba.es6draft.runtime.Realm in project es6draft by anba.
the class OrdinaryAsyncGenerator method FunctionAllocate.
/* ***************************************************************************************** */
/**
* 9.2.3 FunctionAllocate (functionPrototype, strict [,functionKind] )
*
* @param cx
* the execution context
* @param functionPrototype
* the function prototype
* @param strict
* the strict mode flag
* @param kind
* the function kind
* @return the new async enerator function object
*/
public static OrdinaryAsyncGenerator FunctionAllocate(ExecutionContext cx, ScriptObject functionPrototype, boolean strict, FunctionKind kind) {
assert kind != FunctionKind.ClassConstructor;
Realm realm = cx.getRealm();
/* steps 1-5 (implicit) */
/* steps 6-9 */
OrdinaryAsyncGenerator f = new OrdinaryAsyncGenerator(realm);
/* steps 10-14 */
f.allocate(realm, functionPrototype, strict, kind, ConstructorKind.Base);
/* step 15 */
return f;
}
use of com.github.anba.es6draft.runtime.Realm in project es6draft by anba.
the class OrdinaryConstructorFunction method FunctionAllocate.
/* ***************************************************************************************** */
/**
* 9.2.3 FunctionAllocate (functionPrototype, strict [,functionKind] )
*
* @param cx
* the execution context
* @param functionPrototype
* the function prototype
* @param strict
* the strict mode flag
* @param functionKind
* the function kind
* @param constructorKind
* the constructor kind
* @return the new function object
*/
public static OrdinaryConstructorFunction FunctionAllocate(ExecutionContext cx, ScriptObject functionPrototype, boolean strict, FunctionKind functionKind, ConstructorKind constructorKind) {
assert (functionKind == FunctionKind.Normal || functionKind == FunctionKind.ClassConstructor);
Realm realm = cx.getRealm();
/* steps 1-5 (implicit) */
/* steps 6-9 */
OrdinaryConstructorFunction f = new OrdinaryConstructorFunction(realm);
/* steps 10-14 */
f.allocate(realm, functionPrototype, strict, functionKind, constructorKind);
/* step 15 */
return f;
}
use of com.github.anba.es6draft.runtime.Realm in project es6draft by anba.
the class LocaleTest method testLookup_de_CH.
@Test
public void testLookup_de_CH() throws Exception {
String languageTag = "de-CH";
Realm realm = newRealm(languageTag);
assertEquals(languageTag, realm.getLocale().toLanguageTag());
assertEquals("de-CH", resolvedLocaleLookup(realm, Intl.Collator));
assertEquals("de-CH", resolvedLocaleLookup(realm, Intl.DateTimeFormat));
assertEquals("de-CH", resolvedLocaleLookup(realm, Intl.NumberFormat));
}
Aggregations