Index: src/typedarray.js |
diff --git a/src/typedarray.js b/src/typedarray.js |
index 79791515541f166844f018a7575d9da0f8deb659..4e3b9385863a20c94234d3dc63bafb31191e31f1 100644 |
--- a/src/typedarray.js |
+++ b/src/typedarray.js |
@@ -10,9 +10,8 @@ |
var GlobalArray = global.Array; |
var GlobalArrayBuffer = global.ArrayBuffer; |
-var GlobalDataView = global.DataView; |
-var GlobalObject = global.Object; |
- |
+ |
+// --------------- Typed Arrays --------------------- |
macro TYPED_ARRAYS(FUNCTION) |
// arrayIds below should be synchronized with Runtime_TypedArrayInitialize. |
FUNCTION(1, Uint8Array, 1) |
@@ -26,14 +25,6 @@ |
FUNCTION(9, Uint8ClampedArray, 1) |
endmacro |
-macro DECLARE_GLOBALS(INDEX, NAME, SIZE) |
-var GlobalNAME = global.NAME; |
-endmacro |
- |
-TYPED_ARRAYS(DECLARE_GLOBALS) |
- |
-// --------------- Typed Arrays --------------------- |
- |
macro TYPED_ARRAY_CONSTRUCTOR(ARRAY_ID, NAME, ELEMENT_SIZE) |
function NAMEConstructByArrayBuffer(obj, buffer, byteOffset, length) { |
if (!IS_UNDEFINED(byteOffset)) { |
@@ -154,6 +145,8 @@ |
return %_TypedArrayGetLength(this); |
} |
+var $NAME = global.NAME; |
+ |
function NAMESubArray(begin, end) { |
if (!(%_ClassOf(this) === 'NAME')) { |
throw MakeTypeError(kIncompatibleMethodReceiver, "NAME.subarray", this); |
@@ -182,8 +175,8 @@ |
var newLength = endInt - beginInt; |
var beginByteOffset = |
%_ArrayBufferViewGetByteOffset(this) + beginInt * ELEMENT_SIZE; |
- return new GlobalNAME(%TypedArrayGetBuffer(this), |
- beginByteOffset, newLength); |
+ return new $NAME(%TypedArrayGetBuffer(this), |
+ beginByteOffset, newLength); |
} |
endmacro |
@@ -304,26 +297,26 @@ |
// ------------------------------------------------------------------- |
macro SETUP_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE) |
- %SetCode(GlobalNAME, NAMEConstructor); |
- %FunctionSetPrototype(GlobalNAME, new GlobalObject()); |
- |
- %AddNamedProperty(GlobalNAME, "BYTES_PER_ELEMENT", ELEMENT_SIZE, |
+ %SetCode(global.NAME, NAMEConstructor); |
+ %FunctionSetPrototype(global.NAME, new $Object()); |
+ |
+ %AddNamedProperty(global.NAME, "BYTES_PER_ELEMENT", ELEMENT_SIZE, |
READ_ONLY | DONT_ENUM | DONT_DELETE); |
- %AddNamedProperty(GlobalNAME.prototype, |
+ %AddNamedProperty(global.NAME.prototype, |
"constructor", global.NAME, DONT_ENUM); |
- %AddNamedProperty(GlobalNAME.prototype, |
+ %AddNamedProperty(global.NAME.prototype, |
"BYTES_PER_ELEMENT", ELEMENT_SIZE, |
READ_ONLY | DONT_ENUM | DONT_DELETE); |
- $installGetter(GlobalNAME.prototype, "buffer", NAME_GetBuffer); |
- $installGetter(GlobalNAME.prototype, "byteOffset", NAME_GetByteOffset, |
- DONT_ENUM | DONT_DELETE); |
- $installGetter(GlobalNAME.prototype, "byteLength", NAME_GetByteLength, |
- DONT_ENUM | DONT_DELETE); |
- $installGetter(GlobalNAME.prototype, "length", NAME_GetLength, |
- DONT_ENUM | DONT_DELETE); |
- $installGetter(GlobalNAME.prototype, symbolToStringTag, |
- TypedArrayGetToStringTag); |
- $installFunctions(GlobalNAME.prototype, DONT_ENUM, [ |
+ InstallGetter(global.NAME.prototype, "buffer", NAME_GetBuffer); |
+ InstallGetter(global.NAME.prototype, "byteOffset", NAME_GetByteOffset, |
+ DONT_ENUM | DONT_DELETE); |
+ InstallGetter(global.NAME.prototype, "byteLength", NAME_GetByteLength, |
+ DONT_ENUM | DONT_DELETE); |
+ InstallGetter(global.NAME.prototype, "length", NAME_GetLength, |
+ DONT_ENUM | DONT_DELETE); |
+ InstallGetter(global.NAME.prototype, symbolToStringTag, |
+ TypedArrayGetToStringTag); |
+ InstallFunctions(global.NAME.prototype, DONT_ENUM, [ |
"subarray", NAMESubArray, |
"set", TypedArraySet |
]); |
@@ -332,6 +325,8 @@ |
TYPED_ARRAYS(SETUP_TYPED_ARRAY) |
// --------------------------- DataView ----------------------------- |
+ |
+var $DataView = global.DataView; |
function DataViewConstructor(buffer, byteOffset, byteLength) { // length = 3 |
if (%_IsConstructCall()) { |
@@ -435,20 +430,19 @@ |
DATA_VIEW_TYPES(DATA_VIEW_GETTER_SETTER) |
// Setup the DataView constructor. |
-%SetCode(GlobalDataView, DataViewConstructor); |
-%FunctionSetPrototype(GlobalDataView, new GlobalObject); |
+%SetCode($DataView, DataViewConstructor); |
+%FunctionSetPrototype($DataView, new $Object); |
// Set up constructor property on the DataView prototype. |
-%AddNamedProperty(GlobalDataView.prototype, "constructor", GlobalDataView, |
- DONT_ENUM); |
-%AddNamedProperty(GlobalDataView.prototype, symbolToStringTag, "DataView", |
- READ_ONLY|DONT_ENUM); |
- |
-$installGetter(GlobalDataView.prototype, "buffer", DataViewGetBufferJS); |
-$installGetter(GlobalDataView.prototype, "byteOffset", DataViewGetByteOffset); |
-$installGetter(GlobalDataView.prototype, "byteLength", DataViewGetByteLength); |
- |
-$installFunctions(GlobalDataView.prototype, DONT_ENUM, [ |
+%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); |
+ |
+InstallFunctions($DataView.prototype, DONT_ENUM, [ |
"getInt8", DataViewGetInt8JS, |
"setInt8", DataViewSetInt8JS, |