Index: src/js/harmony-sharedarraybuffer.js |
diff --git a/src/js/harmony-sharedarraybuffer.js b/src/js/harmony-sharedarraybuffer.js |
index 10ceb70d27b739d434eb3dc1c5f88755a81ddfbb..37480617b51c7bea70c14e3f3ea1140e0f9cc51b 100644 |
--- a/src/js/harmony-sharedarraybuffer.js |
+++ b/src/js/harmony-sharedarraybuffer.js |
@@ -9,13 +9,26 @@ |
%CheckIsBootstrapping(); |
var GlobalSharedArrayBuffer = global.SharedArrayBuffer; |
+var GlobalObject = global.Object; |
var MakeTypeError; |
+var ToPositiveInteger; |
+var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); |
utils.Import(function(from) { |
MakeTypeError = from.MakeTypeError; |
+ ToPositiveInteger = from.ToPositiveInteger; |
}) |
// ------------------------------------------------------------------- |
+ |
+function SharedArrayBufferConstructor(length) { // length = 1 |
+ if (!IS_UNDEFINED(new.target)) { |
+ var byteLength = ToPositiveInteger(length, kInvalidArrayBufferLength); |
+ %ArrayBufferInitialize(this, byteLength, kShared); |
+ } else { |
+ throw MakeTypeError(kConstructorNotFunction, "SharedArrayBuffer"); |
+ } |
+} |
function SharedArrayBufferGetByteLen() { |
if (!IS_SHAREDARRAYBUFFER(this)) { |
@@ -25,7 +38,27 @@ |
return %_ArrayBufferGetByteLength(this); |
} |
+function SharedArrayBufferIsViewJS(obj) { |
+ return %ArrayBufferIsView(obj); |
+} |
+ |
+ |
+// Set up the SharedArrayBuffer constructor function. |
+%SetCode(GlobalSharedArrayBuffer, SharedArrayBufferConstructor); |
+%FunctionSetPrototype(GlobalSharedArrayBuffer, new GlobalObject()); |
+ |
+// Set up the constructor property on the SharedArrayBuffer prototype object. |
+%AddNamedProperty(GlobalSharedArrayBuffer.prototype, "constructor", |
+ GlobalSharedArrayBuffer, DONT_ENUM); |
+ |
+%AddNamedProperty(GlobalSharedArrayBuffer.prototype, |
+ toStringTagSymbol, "SharedArrayBuffer", DONT_ENUM | READ_ONLY); |
+ |
utils.InstallGetter(GlobalSharedArrayBuffer.prototype, "byteLength", |
SharedArrayBufferGetByteLen); |
+utils.InstallFunctions(GlobalSharedArrayBuffer, DONT_ENUM, [ |
+ "isView", SharedArrayBufferIsViewJS |
+]); |
+ |
}) |