use of com.github.anba.es6draft.runtime.types.Intrinsics in project es6draft by anba.
the class GeneratorFunctionConstructor method CreateDynamicGenerator.
private static OrdinaryGenerator CreateDynamicGenerator(ExecutionContext callerContext, ExecutionContext cx, Constructor newTarget, Object... args) {
/* step 1 (not applicable) */
/* step 2 (not applicable) */
/* step 3 */
Intrinsics fallbackProto = Intrinsics.Generator;
/* steps 4-10 */
String[] sourceText = functionSourceText(cx, args);
String parameters = sourceText[0], bodyText = sourceText[1];
/* steps 11, 13-20 */
Source source = functionSource(SourceKind.Generator, cx.getRealm(), callerContext);
RuntimeInfo.Function function;
try {
ScriptLoader scriptLoader = cx.getRealm().getScriptLoader();
function = scriptLoader.generator(source, parameters, bodyText).getFunction();
} catch (ParserException | CompilationException e) {
throw e.toScriptException(cx);
}
/* step 12 */
boolean strict = function.isStrict();
/* steps 21-22 */
ScriptObject proto = GetPrototypeFromConstructor(cx, newTarget, fallbackProto);
/* step 23 */
OrdinaryGenerator f = OrdinaryGenerator.FunctionAllocate(cx, proto, strict, FunctionKind.Normal);
/* steps 24-25 */
LexicalEnvironment<GlobalEnvironmentRecord> scope = f.getRealm().getGlobalEnv();
/* step 26 */
FunctionInitialize(f, FunctionKind.Normal, function, scope, newFunctionExecutable(source));
/* step 27 */
OrdinaryObject prototype = ObjectCreate(cx, Intrinsics.GeneratorPrototype);
f.infallibleDefineOwnProperty("prototype", new Property(prototype, true, false, false));
/* step 28 (not applicable) */
/* step 29 */
SetFunctionName(f, "anonymous");
/* step 30 */
return f;
}
use of com.github.anba.es6draft.runtime.types.Intrinsics in project es6draft by anba.
the class Realm method initializeReflectModule.
/**
* <h1>26 Reflection</h1>
*
* @param realm
* the realm instance
*/
private static void initializeReflectModule(Realm realm) {
EnumMap<Intrinsics, OrdinaryObject> intrinsics = realm.intrinsics;
// allocation phase
ProxyConstructor proxy = new ProxyConstructor(realm);
ReflectObject reflect = new ReflectObject(realm);
// registration phase
intrinsics.put(Intrinsics.Proxy, proxy);
intrinsics.put(Intrinsics.Reflect, reflect);
// initialization phase
proxy.initialize(realm);
if (realm.isEnabled(CompatibilityOption.Realm)) {
RealmConstructor realmConstructor = new RealmConstructor(realm);
RealmPrototype realmPrototype = new RealmPrototype(realm);
intrinsics.put(Intrinsics.Realm, realmConstructor);
intrinsics.put(Intrinsics.RealmPrototype, realmPrototype);
realmConstructor.initialize(realm);
realmPrototype.initialize(realm);
}
if (realm.isEnabled(CompatibilityOption.Loader)) {
LoaderConstructor loaderConstructor = new LoaderConstructor(realm);
LoaderPrototype loaderPrototype = new LoaderPrototype(realm);
intrinsics.put(Intrinsics.Loader, loaderConstructor);
intrinsics.put(Intrinsics.LoaderPrototype, loaderPrototype);
loaderConstructor.initialize(realm);
loaderPrototype.initialize(realm);
}
if (realm.isEnabled(CompatibilityOption.System) || realm.isEnabled(CompatibilityOption.SystemGlobal)) {
SystemObject systemObject = new SystemObject(realm);
intrinsics.put(Intrinsics.System, systemObject);
systemObject.initialize(realm);
}
reflect.initialize(realm);
}
use of com.github.anba.es6draft.runtime.types.Intrinsics in project es6draft by anba.
the class Realm method initializeObservableModule.
/**
* <h1>Extension: Observable</h1>
*
* @param realm
* the realm instance
*/
private static void initializeObservableModule(Realm realm) {
EnumMap<Intrinsics, OrdinaryObject> intrinsics = realm.intrinsics;
// allocation phase
ObservableConstructor observableConstructor = new ObservableConstructor(realm);
ObservablePrototype observablePrototype = new ObservablePrototype(realm);
SubscriptionPrototype subscriptionPrototype = new SubscriptionPrototype(realm);
SubscriptionObserverPrototype subscriptionObserverPrototype = new SubscriptionObserverPrototype(realm);
// registration phase
intrinsics.put(Intrinsics.Observable, observableConstructor);
intrinsics.put(Intrinsics.ObservablePrototype, observablePrototype);
intrinsics.put(Intrinsics.SubscriptionPrototype, subscriptionPrototype);
intrinsics.put(Intrinsics.SubscriptionObserverPrototype, subscriptionObserverPrototype);
// initialization phase
observableConstructor.initialize(realm);
observablePrototype.initialize(realm);
subscriptionPrototype.initialize(realm);
subscriptionObserverPrototype.initialize(realm);
}
use of com.github.anba.es6draft.runtime.types.Intrinsics in project es6draft by anba.
the class Realm method initializeFundamentalObjects.
/**
* <h1>19.1 Object Objects - 19.2 Function Objects</h1>
*
* Fundamental built-in objects which must be initialized early
*
* @param realm
* the realm instance
*/
private static void initializeFundamentalObjects(Realm realm) {
EnumMap<Intrinsics, OrdinaryObject> intrinsics = realm.intrinsics;
// allocation phase
ObjectConstructor objectConstructor = new ObjectConstructor(realm);
ObjectPrototype objectPrototype = new ObjectPrototype(realm);
FunctionConstructor functionConstructor = new FunctionConstructor(realm);
FunctionPrototype functionPrototype = new FunctionPrototype(realm);
// registration phase
intrinsics.put(Intrinsics.Object, objectConstructor);
intrinsics.put(Intrinsics.ObjectPrototype, objectPrototype);
intrinsics.put(Intrinsics.Function, functionConstructor);
intrinsics.put(Intrinsics.FunctionPrototype, functionPrototype);
// Create [[ThrowTypeError]] function before initializing intrinsics.
realm.throwTypeError = new TypeErrorThrower(realm);
// Also stored in intrinsics table.
intrinsics.put(Intrinsics.ThrowTypeError, realm.throwTypeError);
// initialization phase
objectConstructor.initialize(realm);
objectPrototype.initialize(realm);
functionConstructor.initialize(realm);
functionPrototype.initialize(realm);
AddRestrictedFunctionProperties(functionPrototype, realm);
// Object.prototype.toString is also an intrinsic
Object objectPrototypeToString = objectPrototype.lookupOwnProperty("toString").getValue();
intrinsics.put(Intrinsics.ObjProto_toString, (OrdinaryObject) objectPrototypeToString);
}
use of com.github.anba.es6draft.runtime.types.Intrinsics in project es6draft by anba.
the class Realm method initializePromiseObjects.
/**
* <h1>25 Control Abstraction Objects</h1><br>
* <h2>25.4 Promise Objects</h2>
*
* @param realm
* the realm instance
*/
private static void initializePromiseObjects(Realm realm) {
EnumMap<Intrinsics, OrdinaryObject> intrinsics = realm.intrinsics;
// allocation phase
PromiseConstructor promiseConstructor = new PromiseConstructor(realm);
PromisePrototype promisePrototype = new PromisePrototype(realm);
// registration phase
intrinsics.put(Intrinsics.Promise, promiseConstructor);
intrinsics.put(Intrinsics.PromisePrototype, promisePrototype);
// initialization phase
promiseConstructor.initialize(realm);
promisePrototype.initialize(realm);
}
Aggregations