// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+var $iteratorCreateResultObject;
+var $arrayValues;
+
+(function() {
+
"use strict";
+%CheckIsBootstrapping();
-// This file relies on the fact that the following declaration has been made
-// in runtime.js:
-// var $Array = global.Array;
+var GlobalArray = global.Array;
+var GlobalObject = global.Object;
+macro TYPED_ARRAYS(FUNCTION)
+ FUNCTION(Uint8Array)
+ FUNCTION(Int8Array)
+ FUNCTION(Uint16Array)
+ FUNCTION(Int16Array)
+ FUNCTION(Uint32Array)
+ FUNCTION(Int32Array)
+ FUNCTION(Float32Array)
+ FUNCTION(Float64Array)
+ FUNCTION(Uint8ClampedArray)
+endmacro
+
+macro COPY_FROM_GLOBAL(NAME)
+ var GlobalNAME = global.NAME;
+endmacro
+
+TYPED_ARRAYS(COPY_FROM_GLOBAL)
var arrayIteratorObjectSymbol = GLOBAL_PRIVATE("ArrayIterator#object");
var arrayIteratorNextIndexSymbol = GLOBAL_PRIVATE("ArrayIterator#next");
}
-function SetUpArrayIterator() {
- %CheckIsBootstrapping();
-
- %FunctionSetPrototype(ArrayIterator, new $Object());
- %FunctionSetInstanceClassName(ArrayIterator, 'Array Iterator');
-
- InstallFunctions(ArrayIterator.prototype, DONT_ENUM, [
- 'next', ArrayIteratorNext
- ]);
- %FunctionSetName(ArrayIteratorIterator, '[Symbol.iterator]');
- %AddNamedProperty(ArrayIterator.prototype, symbolIterator,
- ArrayIteratorIterator, DONT_ENUM);
- %AddNamedProperty(ArrayIterator.prototype, symbolToStringTag,
- "Array Iterator", READ_ONLY | DONT_ENUM);
-}
-SetUpArrayIterator();
-
-
-function ExtendArrayPrototype() {
- %CheckIsBootstrapping();
+%FunctionSetPrototype(ArrayIterator, new GlobalObject());
+%FunctionSetInstanceClassName(ArrayIterator, 'Array Iterator');
- InstallFunctions($Array.prototype, DONT_ENUM, [
- // No 'values' since it breaks webcompat: http://crbug.com/409858
- 'entries', ArrayEntries,
- 'keys', ArrayKeys
- ]);
+InstallFunctions(ArrayIterator.prototype, DONT_ENUM, [
+ 'next', ArrayIteratorNext
+]);
+%FunctionSetName(ArrayIteratorIterator, '[Symbol.iterator]');
+%AddNamedProperty(ArrayIterator.prototype, symbolIterator,
+ ArrayIteratorIterator, DONT_ENUM);
+%AddNamedProperty(ArrayIterator.prototype, symbolToStringTag,
+ "Array Iterator", READ_ONLY | DONT_ENUM);
- %AddNamedProperty($Array.prototype, symbolIterator, ArrayValues, DONT_ENUM);
-}
-ExtendArrayPrototype();
+InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
+ // No 'values' since it breaks webcompat: http://crbug.com/409858
+ 'entries', ArrayEntries,
+ 'keys', ArrayKeys
+]);
-
-function ExtendTypedArrayPrototypes() {
- %CheckIsBootstrapping();
-
-macro TYPED_ARRAYS(FUNCTION)
- FUNCTION(Uint8Array)
- FUNCTION(Int8Array)
- FUNCTION(Uint16Array)
- FUNCTION(Int16Array)
- FUNCTION(Uint32Array)
- FUNCTION(Int32Array)
- FUNCTION(Float32Array)
- FUNCTION(Float64Array)
- FUNCTION(Uint8ClampedArray)
-endmacro
+%AddNamedProperty(GlobalArray.prototype, symbolIterator, ArrayValues,
+ DONT_ENUM);
macro EXTEND_TYPED_ARRAY(NAME)
- %AddNamedProperty($NAME.prototype, 'entries', ArrayEntries, DONT_ENUM);
- %AddNamedProperty($NAME.prototype, 'values', ArrayValues, DONT_ENUM);
- %AddNamedProperty($NAME.prototype, 'keys', ArrayKeys, DONT_ENUM);
- %AddNamedProperty($NAME.prototype, symbolIterator, ArrayValues, DONT_ENUM);
+ %AddNamedProperty(GlobalNAME.prototype, 'entries', ArrayEntries, DONT_ENUM);
+ %AddNamedProperty(GlobalNAME.prototype, 'values', ArrayValues, DONT_ENUM);
+ %AddNamedProperty(GlobalNAME.prototype, 'keys', ArrayKeys, DONT_ENUM);
+ %AddNamedProperty(GlobalNAME.prototype, symbolIterator, ArrayValues,
+ DONT_ENUM);
endmacro
- TYPED_ARRAYS(EXTEND_TYPED_ARRAY)
-}
-ExtendTypedArrayPrototypes();
+TYPED_ARRAYS(EXTEND_TYPED_ARRAY)
+
+$iteratorCreateResultObject = CreateIteratorResultObject;
+$arrayValues = ArrayValues;
+
+})();
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+(function() {
+
"use strict";
-var $ArrayBuffer = global.ArrayBuffer;
+%CheckIsBootstrapping();
+
+var GlobalArrayBuffer = global.ArrayBuffer;
+var GlobalObject = global.Object;
// -------------------------------------------------------------------
}
var newLen = fin - first;
// TODO(dslomov): implement inheritance
- var result = new $ArrayBuffer(newLen);
+ var result = new GlobalArrayBuffer(newLen);
%ArrayBufferSliceImpl(this, result, first);
return result;
return %ArrayBufferIsView(obj);
}
-function SetUpArrayBuffer() {
- %CheckIsBootstrapping();
- // Set up the ArrayBuffer constructor function.
- %SetCode($ArrayBuffer, ArrayBufferConstructor);
- %FunctionSetPrototype($ArrayBuffer, new $Object());
+// Set up the ArrayBuffer constructor function.
+%SetCode(GlobalArrayBuffer, ArrayBufferConstructor);
+%FunctionSetPrototype(GlobalArrayBuffer, new GlobalObject());
- // Set up the constructor property on the ArrayBuffer prototype object.
- %AddNamedProperty(
- $ArrayBuffer.prototype, "constructor", $ArrayBuffer, DONT_ENUM);
+// Set up the constructor property on the ArrayBuffer prototype object.
+%AddNamedProperty(
+ GlobalArrayBuffer.prototype, "constructor", GlobalArrayBuffer, DONT_ENUM);
- %AddNamedProperty($ArrayBuffer.prototype,
- symbolToStringTag, "ArrayBuffer", DONT_ENUM | READ_ONLY);
+%AddNamedProperty(GlobalArrayBuffer.prototype,
+ symbolToStringTag, "ArrayBuffer", DONT_ENUM | READ_ONLY);
- InstallGetter($ArrayBuffer.prototype, "byteLength", ArrayBufferGetByteLen);
+InstallGetter(GlobalArrayBuffer.prototype, "byteLength", ArrayBufferGetByteLen);
- InstallFunctions($ArrayBuffer, DONT_ENUM, [
- "isView", ArrayBufferIsViewJS
- ]);
+InstallFunctions(GlobalArrayBuffer, DONT_ENUM, [
+ "isView", ArrayBufferIsViewJS
+]);
- InstallFunctions($ArrayBuffer.prototype, DONT_ENUM, [
- "slice", ArrayBufferSlice
- ]);
-}
+InstallFunctions(GlobalArrayBuffer.prototype, DONT_ENUM, [
+ "slice", ArrayBufferSlice
+]);
-SetUpArrayBuffer();
+})();
native_object_get_notifier);
INSTALL_NATIVE(JSFunction, "NativeObjectNotifierPerformChange",
native_object_notifier_perform_change);
- INSTALL_NATIVE(JSFunction, "ArrayValues", array_values_iterator);
+ INSTALL_NATIVE(JSFunction, "$arrayValues", array_values_iterator);
}
var s = GET_PRIVATE(iterator, stringIteratorIteratedStringSymbol);
if (IS_UNDEFINED(s)) {
- return CreateIteratorResultObject(UNDEFINED, true);
+ return $iteratorCreateResultObject(UNDEFINED, true);
}
var position = GET_PRIVATE(iterator, stringIteratorNextIndexSymbol);
if (position >= length) {
SET_PRIVATE(iterator, stringIteratorIteratedStringSymbol,
UNDEFINED);
- return CreateIteratorResultObject(UNDEFINED, true);
+ return $iteratorCreateResultObject(UNDEFINED, true);
}
var first = %_StringCharCodeAt(s, position);
SET_PRIVATE(iterator, stringIteratorNextIndexSymbol, position);
- return CreateIteratorResultObject(resultString, false);
+ return $iteratorCreateResultObject(resultString, false);
}
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+(function() {
+
"use strict";
-// This file relies on the fact that the following declaration has been made
-// in runtime.js:
-// var $Array = global.Array;
-var $ArrayBuffer = global.ArrayBuffer;
+%CheckIsBootstrapping();
+var GlobalArray = global.Array;
+var GlobalArrayBuffer = global.ArrayBuffer;
// --------------- Typed Arrays ---------------------
macro TYPED_ARRAYS(FUNCTION)
}
var byteLength = l * ELEMENT_SIZE;
if (byteLength > %_TypedArrayMaxSizeInHeap()) {
- var buffer = new $ArrayBuffer(byteLength);
+ var buffer = new GlobalArrayBuffer(byteLength);
%_TypedArrayInitialize(obj, ARRAY_ID, buffer, 0, byteLength);
} else {
%_TypedArrayInitialize(obj, ARRAY_ID, null, 0, byteLength);
}
var rightIndex = CopyRightPart();
- var temp = new $Array(rightIndex + 1 - leftIndex);
+ var temp = new GlobalArray(rightIndex + 1 - leftIndex);
for (var i = leftIndex; i <= rightIndex; i++) {
temp[i - leftIndex] = source[i];
}
// -------------------------------------------------------------------
-function SetupTypedArrays() {
macro SETUP_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE)
- %CheckIsBootstrapping();
%SetCode(global.NAME, NAMEConstructor);
%FunctionSetPrototype(global.NAME, new $Object());
endmacro
TYPED_ARRAYS(SETUP_TYPED_ARRAY)
-}
-
-SetupTypedArrays();
// --------------------------- DataView -----------------------------
DATA_VIEW_TYPES(DATA_VIEW_GETTER_SETTER)
-function SetupDataView() {
- %CheckIsBootstrapping();
+// Setup the DataView constructor.
+%SetCode($DataView, DataViewConstructor);
+%FunctionSetPrototype($DataView, new $Object);
- // Setup the DataView constructor.
- %SetCode($DataView, DataViewConstructor);
- %FunctionSetPrototype($DataView, new $Object);
+// Set up constructor property on the DataView prototype.
+%AddNamedProperty($DataView.prototype, "constructor", $DataView, DONT_ENUM);
+%AddNamedProperty(
+ $DataView.prototype, symbolToStringTag, "DataView", READ_ONLY|DONT_ENUM);
- // Set up constructor property on the DataView prototype.
- %AddNamedProperty($DataView.prototype, "constructor", $DataView, DONT_ENUM);
- %AddNamedProperty(
- $DataView.prototype, symbolToStringTag, "DataView", READ_ONLY|DONT_ENUM);
+InstallGetter($DataView.prototype, "buffer", DataViewGetBufferJS);
+InstallGetter($DataView.prototype, "byteOffset", DataViewGetByteOffset);
+InstallGetter($DataView.prototype, "byteLength", DataViewGetByteLength);
- InstallGetter($DataView.prototype, "buffer", DataViewGetBufferJS);
- InstallGetter($DataView.prototype, "byteOffset", DataViewGetByteOffset);
- InstallGetter($DataView.prototype, "byteLength", DataViewGetByteLength);
+InstallFunctions($DataView.prototype, DONT_ENUM, [
+ "getInt8", DataViewGetInt8JS,
+ "setInt8", DataViewSetInt8JS,
- InstallFunctions($DataView.prototype, DONT_ENUM, [
- "getInt8", DataViewGetInt8JS,
- "setInt8", DataViewSetInt8JS,
+ "getUint8", DataViewGetUint8JS,
+ "setUint8", DataViewSetUint8JS,
- "getUint8", DataViewGetUint8JS,
- "setUint8", DataViewSetUint8JS,
+ "getInt16", DataViewGetInt16JS,
+ "setInt16", DataViewSetInt16JS,
- "getInt16", DataViewGetInt16JS,
- "setInt16", DataViewSetInt16JS,
+ "getUint16", DataViewGetUint16JS,
+ "setUint16", DataViewSetUint16JS,
- "getUint16", DataViewGetUint16JS,
- "setUint16", DataViewSetUint16JS,
+ "getInt32", DataViewGetInt32JS,
+ "setInt32", DataViewSetInt32JS,
- "getInt32", DataViewGetInt32JS,
- "setInt32", DataViewSetInt32JS,
+ "getUint32", DataViewGetUint32JS,
+ "setUint32", DataViewSetUint32JS,
- "getUint32", DataViewGetUint32JS,
- "setUint32", DataViewSetUint32JS,
+ "getFloat32", DataViewGetFloat32JS,
+ "setFloat32", DataViewSetFloat32JS,
- "getFloat32", DataViewGetFloat32JS,
- "setFloat32", DataViewSetFloat32JS,
-
- "getFloat64", DataViewGetFloat64JS,
- "setFloat64", DataViewSetFloat64JS
- ]);
-}
+ "getFloat64", DataViewGetFloat64JS,
+ "setFloat64", DataViewSetFloat64JS
+]);
-SetupDataView();
+})();