Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(684)

Unified Diff: src/js/arraybuffer.js

Issue 1501673002: Revert of [es6] Correctify and unify ArrayBuffer and SharedArrayBuffer constructors. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/builtins.cc ('k') | src/js/harmony-sharedarraybuffer.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/arraybuffer.js
diff --git a/src/js/arraybuffer.js b/src/js/arraybuffer.js
index 1ee68ca291b0ccc6c6affc79af5c7bcc6b90c493..1e405638d582936b83461502706d0b6b9310f920 100644
--- a/src/js/arraybuffer.js
+++ b/src/js/arraybuffer.js
@@ -12,17 +12,30 @@
// Imports
var GlobalArrayBuffer = global.ArrayBuffer;
+var GlobalObject = global.Object;
var MakeTypeError;
var MaxSimple;
var MinSimple;
+var ToPositiveInteger;
+var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
utils.Import(function(from) {
MakeTypeError = from.MakeTypeError;
MaxSimple = from.MaxSimple;
MinSimple = from.MinSimple;
+ ToPositiveInteger = from.ToPositiveInteger;
});
// -------------------------------------------------------------------
+
+function ArrayBufferConstructor(length) { // length = 1
+ if (!IS_UNDEFINED(new.target)) {
+ var byteLength = ToPositiveInteger(length, kInvalidArrayBufferLength);
+ %ArrayBufferInitialize(this, byteLength, kNotShared);
+ } else {
+ throw MakeTypeError(kConstructorNotFunction, "ArrayBuffer");
+ }
+}
function ArrayBufferGetByteLen() {
if (!IS_ARRAYBUFFER(this)) {
@@ -69,8 +82,28 @@
return result;
}
+function ArrayBufferIsViewJS(obj) {
+ return %ArrayBufferIsView(obj);
+}
+
+
+// Set up the ArrayBuffer constructor function.
+%SetCode(GlobalArrayBuffer, ArrayBufferConstructor);
+%FunctionSetPrototype(GlobalArrayBuffer, new GlobalObject());
+
+// Set up the constructor property on the ArrayBuffer prototype object.
+%AddNamedProperty(
+ GlobalArrayBuffer.prototype, "constructor", GlobalArrayBuffer, DONT_ENUM);
+
+%AddNamedProperty(GlobalArrayBuffer.prototype,
+ toStringTagSymbol, "ArrayBuffer", DONT_ENUM | READ_ONLY);
+
utils.InstallGetter(GlobalArrayBuffer.prototype, "byteLength",
ArrayBufferGetByteLen);
+
+utils.InstallFunctions(GlobalArrayBuffer, DONT_ENUM, [
+ "isView", ArrayBufferIsViewJS
+]);
utils.InstallFunctions(GlobalArrayBuffer.prototype, DONT_ENUM, [
"slice", ArrayBufferSlice
« no previous file with comments | « src/builtins.cc ('k') | src/js/harmony-sharedarraybuffer.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698