use of com.github.anba.es6draft.runtime.types.Intrinsics in project es6draft by anba.
the class AsyncGeneratorFunctionConstructor method CreateDynamicFunction.
/**
* 19.2.1.1.1 RuntimeSemantics: CreateDynamicFunction(constructor, newTarget, kind, args)
*
* @param callerContext
* the caller execution context
* @param cx
* the execution context
* @param newTarget
* the newTarget constructor function
* @param args
* the function arguments
* @return the new async generator function object
*/
private static FunctionObject CreateDynamicFunction(ExecutionContext callerContext, ExecutionContext cx, Constructor newTarget, Object... args) {
/* step 1 (not applicable) */
/* step 2 (not applicable) */
/* step 3 */
Intrinsics fallbackProto = Intrinsics.AsyncGenerator;
/* steps 4-10 */
String[] sourceText = functionSourceText(cx, args);
String parameters = sourceText[0], bodyText = sourceText[1];
/* steps 11, 13-20 */
Source source = functionSource(SourceKind.AsyncGenerator, cx.getRealm(), callerContext);
RuntimeInfo.Function function;
try {
ScriptLoader scriptLoader = cx.getRealm().getScriptLoader();
function = scriptLoader.asyncGenerator(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 */
OrdinaryAsyncGenerator f = 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.AsyncGeneratorPrototype);
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 initializeBinaryModule.
/**
* <h1>22.2 TypedArray Objects, 24.1 ArrayBuffer Objects, 24.2 DataView Objects</h1>
*
* @param realm
* the realm instance
*/
private static void initializeBinaryModule(Realm realm) {
EnumMap<Intrinsics, OrdinaryObject> intrinsics = realm.intrinsics;
// allocation phase
ArrayBufferConstructor arrayBufferConstructor = new ArrayBufferConstructor(realm);
ArrayBufferPrototype arrayBufferPrototype = new ArrayBufferPrototype(realm);
TypedArrayConstructorPrototype typedArrayConstructor = new TypedArrayConstructorPrototype(realm);
TypedArrayPrototypePrototype typedArrayPrototype = new TypedArrayPrototypePrototype(realm);
TypedArrayConstructor int8ArrayConstructor = new TypedArrayConstructor(realm, ElementType.Int8);
TypedArrayPrototype int8ArrayPrototype = new TypedArrayPrototype(realm, ElementType.Int8);
TypedArrayConstructor uint8ArrayConstructor = new TypedArrayConstructor(realm, ElementType.Uint8);
TypedArrayPrototype uint8ArrayPrototype = new TypedArrayPrototype(realm, ElementType.Uint8);
TypedArrayConstructor uint8CArrayConstructor = new TypedArrayConstructor(realm, ElementType.Uint8C);
TypedArrayPrototype uint8CArrayPrototype = new TypedArrayPrototype(realm, ElementType.Uint8C);
TypedArrayConstructor int16ArrayConstructor = new TypedArrayConstructor(realm, ElementType.Int16);
TypedArrayPrototype int16ArrayPrototype = new TypedArrayPrototype(realm, ElementType.Int16);
TypedArrayConstructor uint16ArrayConstructor = new TypedArrayConstructor(realm, ElementType.Uint16);
TypedArrayPrototype uint16ArrayPrototype = new TypedArrayPrototype(realm, ElementType.Uint16);
TypedArrayConstructor int32ArrayConstructor = new TypedArrayConstructor(realm, ElementType.Int32);
TypedArrayPrototype int32ArrayPrototype = new TypedArrayPrototype(realm, ElementType.Int32);
TypedArrayConstructor uint32ArrayConstructor = new TypedArrayConstructor(realm, ElementType.Uint32);
TypedArrayPrototype uint32ArrayPrototype = new TypedArrayPrototype(realm, ElementType.Uint32);
TypedArrayConstructor float32ArrayConstructor = new TypedArrayConstructor(realm, ElementType.Float32);
TypedArrayPrototype float32ArrayPrototype = new TypedArrayPrototype(realm, ElementType.Float32);
TypedArrayConstructor float64ArrayConstructor = new TypedArrayConstructor(realm, ElementType.Float64);
TypedArrayPrototype float64ArrayPrototype = new TypedArrayPrototype(realm, ElementType.Float64);
DataViewConstructor dataViewConstructor = new DataViewConstructor(realm);
DataViewPrototype dataViewPrototype = new DataViewPrototype(realm);
// registration phase
intrinsics.put(Intrinsics.ArrayBuffer, arrayBufferConstructor);
intrinsics.put(Intrinsics.ArrayBufferPrototype, arrayBufferPrototype);
intrinsics.put(Intrinsics.TypedArray, typedArrayConstructor);
intrinsics.put(Intrinsics.TypedArrayPrototype, typedArrayPrototype);
intrinsics.put(Intrinsics.Int8Array, int8ArrayConstructor);
intrinsics.put(Intrinsics.Int8ArrayPrototype, int8ArrayPrototype);
intrinsics.put(Intrinsics.Uint8Array, uint8ArrayConstructor);
intrinsics.put(Intrinsics.Uint8ArrayPrototype, uint8ArrayPrototype);
intrinsics.put(Intrinsics.Uint8ClampedArray, uint8CArrayConstructor);
intrinsics.put(Intrinsics.Uint8ClampedArrayPrototype, uint8CArrayPrototype);
intrinsics.put(Intrinsics.Int16Array, int16ArrayConstructor);
intrinsics.put(Intrinsics.Int16ArrayPrototype, int16ArrayPrototype);
intrinsics.put(Intrinsics.Uint16Array, uint16ArrayConstructor);
intrinsics.put(Intrinsics.Uint16ArrayPrototype, uint16ArrayPrototype);
intrinsics.put(Intrinsics.Int32Array, int32ArrayConstructor);
intrinsics.put(Intrinsics.Int32ArrayPrototype, int32ArrayPrototype);
intrinsics.put(Intrinsics.Uint32Array, uint32ArrayConstructor);
intrinsics.put(Intrinsics.Uint32ArrayPrototype, uint32ArrayPrototype);
intrinsics.put(Intrinsics.Float32Array, float32ArrayConstructor);
intrinsics.put(Intrinsics.Float32ArrayPrototype, float32ArrayPrototype);
intrinsics.put(Intrinsics.Float64Array, float64ArrayConstructor);
intrinsics.put(Intrinsics.Float64ArrayPrototype, float64ArrayPrototype);
intrinsics.put(Intrinsics.DataView, dataViewConstructor);
intrinsics.put(Intrinsics.DataViewPrototype, dataViewPrototype);
// initialization phase
arrayBufferConstructor.initialize(realm);
arrayBufferPrototype.initialize(realm);
typedArrayConstructor.initialize(realm);
typedArrayPrototype.initialize(realm);
int8ArrayConstructor.initialize(realm);
int8ArrayPrototype.initialize(realm);
uint8ArrayConstructor.initialize(realm);
uint8ArrayPrototype.initialize(realm);
uint8CArrayConstructor.initialize(realm);
uint8CArrayPrototype.initialize(realm);
int16ArrayConstructor.initialize(realm);
int16ArrayPrototype.initialize(realm);
uint16ArrayConstructor.initialize(realm);
uint16ArrayPrototype.initialize(realm);
int32ArrayConstructor.initialize(realm);
int32ArrayPrototype.initialize(realm);
uint32ArrayConstructor.initialize(realm);
uint32ArrayPrototype.initialize(realm);
float32ArrayConstructor.initialize(realm);
float32ArrayPrototype.initialize(realm);
float64ArrayConstructor.initialize(realm);
float64ArrayPrototype.initialize(realm);
dataViewConstructor.initialize(realm);
dataViewPrototype.initialize(realm);
}
use of com.github.anba.es6draft.runtime.types.Intrinsics in project es6draft by anba.
the class Realm method initializeAsyncModule.
/**
* <h1>Extension: Async Function Declaration</h1>
*
* @param realm
* the realm instance
*/
private static void initializeAsyncModule(Realm realm) {
EnumMap<Intrinsics, OrdinaryObject> intrinsics = realm.intrinsics;
// allocation phase
AsyncFunctionConstructor asyncFunctionConstructor = new AsyncFunctionConstructor(realm);
AsyncFunctionPrototype asyncFunctionPrototype = new AsyncFunctionPrototype(realm);
// registration phase
intrinsics.put(Intrinsics.AsyncFunction, asyncFunctionConstructor);
intrinsics.put(Intrinsics.AsyncFunctionPrototype, asyncFunctionPrototype);
// initialization phase
asyncFunctionConstructor.initialize(realm);
asyncFunctionPrototype.initialize(realm);
}
use of com.github.anba.es6draft.runtime.types.Intrinsics in project es6draft by anba.
the class Realm method initializeInternationalisation.
/**
* <h1>Internationalisation API (ECMA-402)</h1><br>
* <h2>8 The Intl Object - 12 DateTimeFormat Objects</h2>
*
* Additional built-in objects from the Internationalisation API
*
* @param realm
* the realm instance
*/
private static void initializeInternationalisation(Realm realm) {
EnumMap<Intrinsics, OrdinaryObject> intrinsics = realm.intrinsics;
// allocation phase
IntlObject intlObject = new IntlObject(realm);
CollatorConstructor collatorConstructor = new CollatorConstructor(realm);
CollatorPrototype collatorPrototype = new CollatorPrototype(realm);
NumberFormatConstructor numberFormatConstructor = new NumberFormatConstructor(realm);
NumberFormatPrototype numberFormatPrototype = new NumberFormatPrototype(realm);
DateTimeFormatConstructor dateTimeFormatConstructor = new DateTimeFormatConstructor(realm);
DateTimeFormatPrototype dateTimeFormatPrototype = new DateTimeFormatPrototype(realm);
PluralRulesConstructor pluralRulesConstructor = null;
PluralRulesPrototype pluralRulesPrototype = null;
if (realm.isEnabled(CompatibilityOption.PluralRules)) {
pluralRulesConstructor = new PluralRulesConstructor(realm);
pluralRulesPrototype = new PluralRulesPrototype(realm);
}
// registration phase
intrinsics.put(Intrinsics.Intl, intlObject);
intrinsics.put(Intrinsics.Intl_Collator, collatorConstructor);
intrinsics.put(Intrinsics.Intl_CollatorPrototype, collatorPrototype);
intrinsics.put(Intrinsics.Intl_NumberFormat, numberFormatConstructor);
intrinsics.put(Intrinsics.Intl_NumberFormatPrototype, numberFormatPrototype);
intrinsics.put(Intrinsics.Intl_DateTimeFormat, dateTimeFormatConstructor);
intrinsics.put(Intrinsics.Intl_DateTimeFormatPrototype, dateTimeFormatPrototype);
if (pluralRulesConstructor != null) {
intrinsics.put(Intrinsics.Intl_PluralRules, pluralRulesConstructor);
intrinsics.put(Intrinsics.Intl_PluralRulesPrototype, pluralRulesPrototype);
}
// initialization phase
intlObject.initialize(realm);
collatorConstructor.initialize(realm);
collatorPrototype.initialize(realm);
numberFormatConstructor.initialize(realm);
numberFormatPrototype.initialize(realm);
dateTimeFormatConstructor.initialize(realm);
dateTimeFormatPrototype.initialize(realm);
if (pluralRulesConstructor != null) {
pluralRulesConstructor.initialize(realm);
pluralRulesPrototype.initialize(realm);
}
}
use of com.github.anba.es6draft.runtime.types.Intrinsics in project es6draft by anba.
the class Realm method initializeAsyncIterationModule.
/**
* <h1>Extension: Async Generator Function Declaration</h1>
*
* @param realm
* the realm instance
*/
private static void initializeAsyncIterationModule(Realm realm) {
EnumMap<Intrinsics, OrdinaryObject> intrinsics = realm.intrinsics;
// allocation phase
AsyncGeneratorFunctionConstructor asyncGenFunctionConstructor = new AsyncGeneratorFunctionConstructor(realm);
AsyncGeneratorPrototype asyncGeneratorPrototype = new AsyncGeneratorPrototype(realm);
AsyncGeneratorFunctionPrototype asyncGenerator = new AsyncGeneratorFunctionPrototype(realm);
AsyncIteratorPrototype asyncIteratorPrototype = new AsyncIteratorPrototype(realm);
// registration phase
intrinsics.put(Intrinsics.AsyncGeneratorFunction, asyncGenFunctionConstructor);
intrinsics.put(Intrinsics.AsyncGeneratorPrototype, asyncGeneratorPrototype);
intrinsics.put(Intrinsics.AsyncGenerator, asyncGenerator);
intrinsics.put(Intrinsics.AsyncIteratorPrototype, asyncIteratorPrototype);
// initialization phase
asyncGenFunctionConstructor.initialize(realm);
asyncGeneratorPrototype.initialize(realm);
asyncGenerator.initialize(realm);
asyncIteratorPrototype.initialize(realm);
}
Aggregations