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

Side by Side Diff: src/typedarray.js

Issue 19210002: Throw if first argument to TypedArray.set is a number. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 5 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 | « no previous file | 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 function TypedArraySet(obj, offset) { 147 function TypedArraySet(obj, offset) {
148 var intOffset = IS_UNDEFINED(offset) ? 0 : TO_INTEGER(offset); 148 var intOffset = IS_UNDEFINED(offset) ? 0 : TO_INTEGER(offset);
149 if (intOffset < 0) { 149 if (intOffset < 0) {
150 throw MakeTypeError("typed_array_set_negative_offset"); 150 throw MakeTypeError("typed_array_set_negative_offset");
151 } 151 }
152 if (%TypedArraySetFastCases(this, obj, intOffset)) 152 if (%TypedArraySetFastCases(this, obj, intOffset))
153 return; 153 return;
154 154
155 var l = obj.length; 155 var l = obj.length;
156 if (IS_UNDEFINED(l)) { 156 if (IS_UNDEFINED(l)) {
157 if (IS_NUMBER(obj))
Benedikt Meurer 2013/07/16 05:39:57 This if is missing { and }.
158 // For number as a first argument, throw TypeError
159 // instead of silently ignoring the call, so that
160 // the user knows (s)he did something wrong.
161 // (Consistent with Firefox and Blink/WebKit)
162 throw MakeTypeError("invalid_argument");
157 return; 163 return;
158 } 164 }
159 if (intOffset + l > this.length) { 165 if (intOffset + l > this.length) {
160 throw MakeRangeError("typed_array_set_source_too_large"); 166 throw MakeRangeError("typed_array_set_source_too_large");
161 } 167 }
162 for (var i = 0; i < l; i++) { 168 for (var i = 0; i < l; i++) {
163 this[intOffset + i] = obj[i]; 169 this[intOffset + i] = obj[i];
164 } 170 }
165 } 171 }
166 172
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 511
506 "getFloat32", DataViewGetFloat32, 512 "getFloat32", DataViewGetFloat32,
507 "setFloat32", DataViewSetFloat32, 513 "setFloat32", DataViewSetFloat32,
508 514
509 "getFloat64", DataViewGetFloat64, 515 "getFloat64", DataViewGetFloat64,
510 "setFloat64", DataViewSetFloat64 516 "setFloat64", DataViewSetFloat64
511 )); 517 ));
512 } 518 }
513 519
514 SetupDataView(); 520 SetupDataView();
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/external-array.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698