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

Side by Side Diff: src/arraybuffer.js

Issue 1082703003: Wrap typed array implementations in functions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 months 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 unified diff | Download patch
« no previous file with comments | « src/array-iterator.js ('k') | src/bootstrapper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 (function() {
6
5 "use strict"; 7 "use strict";
6 8
7 var $ArrayBuffer = global.ArrayBuffer; 9 %CheckIsBootstrapping();
10
11 var GlobalArrayBuffer = global.ArrayBuffer;
12 var GlobalObject = global.Object;
8 13
9 // ------------------------------------------------------------------- 14 // -------------------------------------------------------------------
10 15
11 function ArrayBufferConstructor(length) { // length = 1 16 function ArrayBufferConstructor(length) { // length = 1
12 if (%_IsConstructCall()) { 17 if (%_IsConstructCall()) {
13 var byteLength = ToPositiveInteger(length, 'invalid_array_buffer_length'); 18 var byteLength = ToPositiveInteger(length, 'invalid_array_buffer_length');
14 %ArrayBufferInitialize(this, byteLength); 19 %ArrayBufferInitialize(this, byteLength);
15 } else { 20 } else {
16 throw MakeTypeError('constructor_not_function', ["ArrayBuffer"]); 21 throw MakeTypeError('constructor_not_function', ["ArrayBuffer"]);
17 } 22 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 fin = $max(byte_length + relativeEnd, 0); 54 fin = $max(byte_length + relativeEnd, 0);
50 } else { 55 } else {
51 fin = $min(relativeEnd, byte_length); 56 fin = $min(relativeEnd, byte_length);
52 } 57 }
53 58
54 if (fin < first) { 59 if (fin < first) {
55 fin = first; 60 fin = first;
56 } 61 }
57 var newLen = fin - first; 62 var newLen = fin - first;
58 // TODO(dslomov): implement inheritance 63 // TODO(dslomov): implement inheritance
59 var result = new $ArrayBuffer(newLen); 64 var result = new GlobalArrayBuffer(newLen);
60 65
61 %ArrayBufferSliceImpl(this, result, first); 66 %ArrayBufferSliceImpl(this, result, first);
62 return result; 67 return result;
63 } 68 }
64 69
65 function ArrayBufferIsViewJS(obj) { 70 function ArrayBufferIsViewJS(obj) {
66 return %ArrayBufferIsView(obj); 71 return %ArrayBufferIsView(obj);
67 } 72 }
68 73
69 function SetUpArrayBuffer() {
70 %CheckIsBootstrapping();
71 74
72 // Set up the ArrayBuffer constructor function. 75 // Set up the ArrayBuffer constructor function.
73 %SetCode($ArrayBuffer, ArrayBufferConstructor); 76 %SetCode(GlobalArrayBuffer, ArrayBufferConstructor);
74 %FunctionSetPrototype($ArrayBuffer, new $Object()); 77 %FunctionSetPrototype(GlobalArrayBuffer, new GlobalObject());
75 78
76 // Set up the constructor property on the ArrayBuffer prototype object. 79 // Set up the constructor property on the ArrayBuffer prototype object.
77 %AddNamedProperty( 80 %AddNamedProperty(
78 $ArrayBuffer.prototype, "constructor", $ArrayBuffer, DONT_ENUM); 81 GlobalArrayBuffer.prototype, "constructor", GlobalArrayBuffer, DONT_ENUM);
79 82
80 %AddNamedProperty($ArrayBuffer.prototype, 83 %AddNamedProperty(GlobalArrayBuffer.prototype,
81 symbolToStringTag, "ArrayBuffer", DONT_ENUM | READ_ONLY); 84 symbolToStringTag, "ArrayBuffer", DONT_ENUM | READ_ONLY);
82 85
83 InstallGetter($ArrayBuffer.prototype, "byteLength", ArrayBufferGetByteLen); 86 InstallGetter(GlobalArrayBuffer.prototype, "byteLength", ArrayBufferGetByteLen);
84 87
85 InstallFunctions($ArrayBuffer, DONT_ENUM, [ 88 InstallFunctions(GlobalArrayBuffer, DONT_ENUM, [
86 "isView", ArrayBufferIsViewJS 89 "isView", ArrayBufferIsViewJS
87 ]); 90 ]);
88 91
89 InstallFunctions($ArrayBuffer.prototype, DONT_ENUM, [ 92 InstallFunctions(GlobalArrayBuffer.prototype, DONT_ENUM, [
90 "slice", ArrayBufferSlice 93 "slice", ArrayBufferSlice
91 ]); 94 ]);
92 }
93 95
94 SetUpArrayBuffer(); 96 })();
OLDNEW
« no previous file with comments | « src/array-iterator.js ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698