use of com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject in project es6draft by anba.
the class Realm method initializeStandardObjects.
/**
* <h1>19.3, 19.4, 19.5, 20, 21, 22.1, 24.3</h1>
*
* Standard built-in objects
*
* @param realm
* the realm instance
*/
private static void initializeStandardObjects(Realm realm) {
EnumMap<Intrinsics, OrdinaryObject> intrinsics = realm.intrinsics;
// allocation phase
ArrayConstructor arrayConstructor = new ArrayConstructor(realm);
ArrayPrototype arrayPrototype = new ArrayPrototype(realm);
ArrayIteratorPrototype arrayIteratorPrototype = new ArrayIteratorPrototype(realm);
StringConstructor stringConstructor = new StringConstructor(realm);
StringPrototype stringPrototype = new StringPrototype(realm);
StringIteratorPrototype stringIteratorPrototype = new StringIteratorPrototype(realm);
SymbolConstructor symbolConstructor = new SymbolConstructor(realm);
SymbolPrototype symbolPrototype = new SymbolPrototype(realm);
BooleanConstructor booleanConstructor = new BooleanConstructor(realm);
BooleanPrototype booleanPrototype = new BooleanPrototype(realm);
NumberConstructor numberConstructor = new NumberConstructor(realm);
NumberPrototype numberPrototype = new NumberPrototype(realm);
MathObject mathObject = new MathObject(realm);
DateConstructor dateConstructor = new DateConstructor(realm);
DatePrototype datePrototype = new DatePrototype(realm);
RegExpConstructor regExpConstructor = new RegExpConstructor(realm);
RegExpPrototype regExpPrototype = new RegExpPrototype(realm);
ErrorConstructor errorConstructor = new ErrorConstructor(realm);
ErrorPrototype errorPrototype = new ErrorPrototype(realm);
JSONObject jsonObject = new JSONObject(realm);
IteratorPrototype iteratorPrototype = new IteratorPrototype(realm);
// registration phase
intrinsics.put(Intrinsics.Array, arrayConstructor);
intrinsics.put(Intrinsics.ArrayPrototype, arrayPrototype);
intrinsics.put(Intrinsics.ArrayIteratorPrototype, arrayIteratorPrototype);
intrinsics.put(Intrinsics.String, stringConstructor);
intrinsics.put(Intrinsics.StringPrototype, stringPrototype);
intrinsics.put(Intrinsics.StringIteratorPrototype, stringIteratorPrototype);
intrinsics.put(Intrinsics.Symbol, symbolConstructor);
intrinsics.put(Intrinsics.SymbolPrototype, symbolPrototype);
intrinsics.put(Intrinsics.Boolean, booleanConstructor);
intrinsics.put(Intrinsics.BooleanPrototype, booleanPrototype);
intrinsics.put(Intrinsics.Number, numberConstructor);
intrinsics.put(Intrinsics.NumberPrototype, numberPrototype);
intrinsics.put(Intrinsics.Math, mathObject);
intrinsics.put(Intrinsics.Date, dateConstructor);
intrinsics.put(Intrinsics.DatePrototype, datePrototype);
intrinsics.put(Intrinsics.RegExp, regExpConstructor);
intrinsics.put(Intrinsics.RegExpPrototype, regExpPrototype);
intrinsics.put(Intrinsics.Error, errorConstructor);
intrinsics.put(Intrinsics.ErrorPrototype, errorPrototype);
intrinsics.put(Intrinsics.JSON, jsonObject);
intrinsics.put(Intrinsics.IteratorPrototype, iteratorPrototype);
// initialization phase
arrayConstructor.initialize(realm);
arrayPrototype.initialize(realm);
arrayIteratorPrototype.initialize(realm);
stringConstructor.initialize(realm);
stringPrototype.initialize(realm);
stringIteratorPrototype.initialize(realm);
symbolConstructor.initialize(realm);
symbolPrototype.initialize(realm);
booleanConstructor.initialize(realm);
booleanPrototype.initialize(realm);
numberConstructor.initialize(realm);
numberPrototype.initialize(realm);
mathObject.initialize(realm);
dateConstructor.initialize(realm);
datePrototype.initialize(realm);
regExpConstructor.initialize(realm);
regExpPrototype.initialize(realm);
errorConstructor.initialize(realm);
errorPrototype.initialize(realm);
jsonObject.initialize(realm);
iteratorPrototype.initialize(realm);
// Array.prototype.values is also an intrinsic
Object arrayPrototypeValues = arrayPrototype.lookupOwnProperty("values").getValue();
intrinsics.put(Intrinsics.ArrayProto_values, (OrdinaryObject) arrayPrototypeValues);
if (realm.isEnabled(CompatibilityOption.StringMatchAll)) {
RegExpStringIteratorPrototype regExpStringIteratorPrototype = new RegExpStringIteratorPrototype(realm);
intrinsics.put(Intrinsics.RegExpStringIteratorPrototype, regExpStringIteratorPrototype);
regExpStringIteratorPrototype.initialize(realm);
}
}
use of com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject in project es6draft by anba.
the class Realm method initializeIterationModule.
/**
* <h1>25 Control Abstraction Objects</h1>
*
* @param realm
* the realm instance
*/
private static void initializeIterationModule(Realm realm) {
EnumMap<Intrinsics, OrdinaryObject> intrinsics = realm.intrinsics;
// allocation phase
GeneratorFunctionConstructor generatorFunctionConstructor = new GeneratorFunctionConstructor(realm);
GeneratorPrototype generatorPrototype = new GeneratorPrototype(realm);
GeneratorFunctionPrototype generator = new GeneratorFunctionPrototype(realm);
// registration phase
intrinsics.put(Intrinsics.GeneratorFunction, generatorFunctionConstructor);
intrinsics.put(Intrinsics.GeneratorPrototype, generatorPrototype);
intrinsics.put(Intrinsics.Generator, generator);
// initialization phase
generatorFunctionConstructor.initialize(realm);
generatorPrototype.initialize(realm);
generator.initialize(realm);
if (realm.isEnabled(CompatibilityOption.LegacyGenerator)) {
OrdinaryObject legacyGeneratorPrototype = ObjectCreate(realm, Intrinsics.ObjectPrototype);
intrinsics.put(Intrinsics.LegacyGeneratorPrototype, legacyGeneratorPrototype);
}
}
use of com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject in project es6draft by anba.
the class Realm method initializeAtomicsModule.
/**
* <h1>Extension: Shared Memory and Atomics</h1>
*
* @param realm
* the realm instance
*/
private static void initializeAtomicsModule(Realm realm) {
EnumMap<Intrinsics, OrdinaryObject> intrinsics = realm.intrinsics;
// allocation phase
AtomicsObject atomicsObject = new AtomicsObject(realm);
SharedArrayBufferConstructor sharedArrayBufferConstructor = new SharedArrayBufferConstructor(realm);
SharedArrayBufferPrototype sharedArrayBufferPrototype = new SharedArrayBufferPrototype(realm);
// registration phase
intrinsics.put(Intrinsics.Atomics, atomicsObject);
intrinsics.put(Intrinsics.SharedArrayBuffer, sharedArrayBufferConstructor);
intrinsics.put(Intrinsics.SharedArrayBufferPrototype, sharedArrayBufferPrototype);
// initialization phase
atomicsObject.initialize(realm);
sharedArrayBufferConstructor.initialize(realm);
sharedArrayBufferPrototype.initialize(realm);
}
use of com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject in project es6draft by anba.
the class Properties method createExternalClass.
private static Constructor createExternalClass(ExecutionContext cx, String className, Class<?> constructorProperties, Class<?> prototypeProperties) {
ObjectLayout ctorLayout = externalClassLayouts.get(constructorProperties);
ObjectLayout protoLayout = externalClassLayouts.get(prototypeProperties);
Converter converter = new Converter(cx);
ScriptObject[] objects = ScriptRuntime.getDefaultClassProto(cx);
ScriptObject constructorParent = objects[0];
OrdinaryObject proto = (OrdinaryObject) objects[1];
assert constructorParent == cx.getIntrinsic(Intrinsics.FunctionPrototype);
OrdinaryObject constructor = createConstructor(cx, className, proto, converter, protoLayout);
assert constructor instanceof Constructor;
if (ctorLayout.functions != null) {
createExternalFunctions(cx, constructor, ctorLayout, converter);
}
if (ctorLayout.accessors != null) {
createExternalAccessors(cx, constructor, ctorLayout, converter);
}
if (protoLayout.functions != null) {
createExternalFunctions(cx, proto, protoLayout, converter);
}
if (protoLayout.accessors != null) {
createExternalAccessors(cx, proto, protoLayout, converter);
}
return (Constructor) constructor;
}
use of com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject in project es6draft by anba.
the class ArrayPrototype method inheritedKeys.
private static long[] inheritedKeys(OrdinaryObject array, long from, long to) {
long[] indices = array.indices(from, to);
for (ScriptObject prototype = array.getPrototype(); prototype != null; ) {
assert prototype instanceof OrdinaryObject : "Wrong class " + prototype.getClass();
OrdinaryObject proto = (OrdinaryObject) prototype;
if (proto.hasIndexedProperties()) {
long[] protoIndices = proto.indices(from, to);
long[] newIndices = new long[indices.length + protoIndices.length];
System.arraycopy(indices, 0, newIndices, 0, indices.length);
System.arraycopy(protoIndices, 0, newIndices, indices.length, protoIndices.length);
indices = newIndices;
}
prototype = proto.getPrototype();
}
Arrays.sort(indices);
return indices;
}
Aggregations