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

Side by Side Diff: src/typedarray.js

Issue 163293002: Fix typed array error message. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 10 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/regress/regress-3159.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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 function NAMEConstructByArrayBuffer(obj, buffer, byteOffset, length) { 51 function NAMEConstructByArrayBuffer(obj, buffer, byteOffset, length) {
52 var bufferByteLength = buffer.byteLength; 52 var bufferByteLength = buffer.byteLength;
53 var offset; 53 var offset;
54 if (IS_UNDEFINED(byteOffset)) { 54 if (IS_UNDEFINED(byteOffset)) {
55 offset = 0; 55 offset = 0;
56 } else { 56 } else {
57 offset = ToPositiveInteger(byteOffset, "invalid_typed_array_length"); 57 offset = ToPositiveInteger(byteOffset, "invalid_typed_array_length");
58 58
59 if (offset % ELEMENT_SIZE !== 0) { 59 if (offset % ELEMENT_SIZE !== 0) {
60 throw MakeRangeError("invalid_typed_array_alignment", 60 throw MakeRangeError("invalid_typed_array_alignment",
61 "start offset", "NAME", ELEMENT_SIZE); 61 ["start offset", "NAME", ELEMENT_SIZE]);
62 } 62 }
63 if (offset > bufferByteLength) { 63 if (offset > bufferByteLength) {
64 throw MakeRangeError("invalid_typed_array_offset"); 64 throw MakeRangeError("invalid_typed_array_offset");
65 } 65 }
66 } 66 }
67 67
68 var newByteLength; 68 var newByteLength;
69 var newLength; 69 var newLength;
70 if (IS_UNDEFINED(length)) { 70 if (IS_UNDEFINED(length)) {
71 if (bufferByteLength % ELEMENT_SIZE !== 0) { 71 if (bufferByteLength % ELEMENT_SIZE !== 0) {
72 throw MakeRangeError("invalid_typed_array_alignment", 72 throw MakeRangeError("invalid_typed_array_alignment",
73 "byte length", "NAME", ELEMENT_SIZE); 73 ["byte length", "NAME", ELEMENT_SIZE]);
74 } 74 }
75 newByteLength = bufferByteLength - offset; 75 newByteLength = bufferByteLength - offset;
76 newLength = newByteLength / ELEMENT_SIZE; 76 newLength = newByteLength / ELEMENT_SIZE;
77 } else { 77 } else {
78 var newLength = ToPositiveInteger(length, "invalid_typed_array_length"); 78 var newLength = ToPositiveInteger(length, "invalid_typed_array_length");
79 newByteLength = newLength * ELEMENT_SIZE; 79 newByteLength = newLength * ELEMENT_SIZE;
80 } 80 }
81 if ((offset + newByteLength > bufferByteLength) 81 if ((offset + newByteLength > bufferByteLength)
82 || (newLength > %MaxSmi())) { 82 || (newLength > %MaxSmi())) {
83 throw MakeRangeError("invalid_typed_array_length"); 83 throw MakeRangeError("invalid_typed_array_length");
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 440
441 "getFloat32", DataViewGetFloat32, 441 "getFloat32", DataViewGetFloat32,
442 "setFloat32", DataViewSetFloat32, 442 "setFloat32", DataViewSetFloat32,
443 443
444 "getFloat64", DataViewGetFloat64, 444 "getFloat64", DataViewGetFloat64,
445 "setFloat64", DataViewSetFloat64 445 "setFloat64", DataViewSetFloat64
446 )); 446 ));
447 } 447 }
448 448
449 SetupDataView(); 449 SetupDataView();
OLDNEW
« no previous file with comments | « src/messages.js ('k') | test/mjsunit/regress/regress-3159.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698