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

Side by Side Diff: src/typedarray.js

Issue 17904007: Do not allow invocation of ArrayBuffer and array buffer views' constructors as functions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « src/messages.js ('k') | test/mjsunit/external-array.js » ('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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 if (IS_ARRAYBUFFER(arg1)) { 90 if (IS_ARRAYBUFFER(arg1)) {
91 ConstructByArrayBuffer(this, arg1, arg2, arg3); 91 ConstructByArrayBuffer(this, arg1, arg2, arg3);
92 } else if (IS_NUMBER(arg1) || IS_STRING(arg1) || IS_BOOLEAN(arg1)) { 92 } else if (IS_NUMBER(arg1) || IS_STRING(arg1) || IS_BOOLEAN(arg1)) {
93 ConstructByLength(this, arg1); 93 ConstructByLength(this, arg1);
94 } else if (!IS_UNDEFINED(arg1)){ 94 } else if (!IS_UNDEFINED(arg1)){
95 ConstructByArrayLike(this, arg1); 95 ConstructByArrayLike(this, arg1);
96 } else { 96 } else {
97 throw MakeTypeError("parameterless_typed_array_constr", [name]); 97 throw MakeTypeError("parameterless_typed_array_constr", [name]);
98 } 98 }
99 } else { 99 } else {
100 return new constructor(arg1, arg2, arg3); 100 throw MakeTypeError("constructor_not_function", [name])
101 } 101 }
102 } 102 }
103 } 103 }
104 104
105 function TypedArrayGetBuffer() { 105 function TypedArrayGetBuffer() {
106 return %TypedArrayGetBuffer(this); 106 return %TypedArrayGetBuffer(this);
107 } 107 }
108 108
109 function TypedArrayGetByteLength() { 109 function TypedArrayGetByteLength() {
110 return %TypedArrayGetByteLength(this); 110 return %TypedArrayGetByteLength(this);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 if (offset > bufferByteLength) { 216 if (offset > bufferByteLength) {
217 throw MakeRangeError('invalid_data_view_offset'); 217 throw MakeRangeError('invalid_data_view_offset');
218 } 218 }
219 var length = IS_UNDEFINED(byteLength) ? 219 var length = IS_UNDEFINED(byteLength) ?
220 bufferByteLength - offset : TO_INTEGER(byteLength); 220 bufferByteLength - offset : TO_INTEGER(byteLength);
221 if (length < 0 || offset + length > bufferByteLength) { 221 if (length < 0 || offset + length > bufferByteLength) {
222 throw new MakeRangeError('invalid_data_view_length'); 222 throw new MakeRangeError('invalid_data_view_length');
223 } 223 }
224 %DataViewInitialize(this, buffer, offset, length); 224 %DataViewInitialize(this, buffer, offset, length);
225 } else { 225 } else {
226 return new $DataView(buffer, byteOffset, byteLength) 226 throw MakeTypeError('constructor_not_function', ["DataView"]);
227 } 227 }
228 } 228 }
229 229
230 function DataViewGetBuffer() { 230 function DataViewGetBuffer() {
231 if (!IS_DATAVIEW(this)) { 231 if (!IS_DATAVIEW(this)) {
232 throw MakeTypeError('incompatible_method_reciever', 232 throw MakeTypeError('incompatible_method_reciever',
233 ['DataView.buffer', this]); 233 ['DataView.buffer', this]);
234 } 234 }
235 return %DataViewGetBuffer(this); 235 return %DataViewGetBuffer(this);
236 } 236 }
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 466
467 "getFloat32", DataViewGetFloat32, 467 "getFloat32", DataViewGetFloat32,
468 "setFloat32", DataViewSetFloat32, 468 "setFloat32", DataViewSetFloat32,
469 469
470 "getFloat64", DataViewGetFloat64, 470 "getFloat64", DataViewGetFloat64,
471 "setFloat64", DataViewSetFloat64 471 "setFloat64", DataViewSetFloat64
472 )); 472 ));
473 } 473 }
474 474
475 SetupDataView(); 475 SetupDataView();
OLDNEW
« no previous file with comments | « src/messages.js ('k') | test/mjsunit/external-array.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698