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

Side by Side Diff: src/array-iterator.js

Issue 22715004: Version 3.20.15 (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Add TypedArray API and correctness patches r16033 and r16084 Created 7 years, 4 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/arm/macro-assembler-arm.cc ('k') | src/ast.h » ('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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 var itemKind = iterator[arrayIterationKindSymbol]; 70 var itemKind = iterator[arrayIterationKindSymbol];
71 var length = TO_UINT32(array.length); 71 var length = TO_UINT32(array.length);
72 72
73 // "sparse" is never used. 73 // "sparse" is never used.
74 74
75 if (index >= length) { 75 if (index >= length) {
76 iterator[arrayIteratorNextIndexSymbol] = 1 / 0; // Infinity 76 iterator[arrayIteratorNextIndexSymbol] = 1 / 0; // Infinity
77 return CreateIteratorResultObject(void 0, true); 77 return CreateIteratorResultObject(void 0, true);
78 } 78 }
79 79
80 var elementKey = ToString(index);
80 iterator[arrayIteratorNextIndexSymbol] = index + 1; 81 iterator[arrayIteratorNextIndexSymbol] = index + 1;
81 82
82 if (itemKind == ARRAY_ITERATOR_KIND_VALUES) 83 if (itemKind == ARRAY_ITERATOR_KIND_VALUES)
83 return CreateIteratorResultObject(array[index], false); 84 return CreateIteratorResultObject(array[elementKey], false);
84 85
85 if (itemKind == ARRAY_ITERATOR_KIND_ENTRIES) 86 if (itemKind == ARRAY_ITERATOR_KIND_ENTRIES)
86 return CreateIteratorResultObject([index, array[index]], false); 87 return CreateIteratorResultObject([elementKey, array[elementKey]], false);
87 88
88 return CreateIteratorResultObject(index, false); 89 return CreateIteratorResultObject(elementKey, false);
89 } 90 }
90 91
91 function ArrayEntries() { 92 function ArrayEntries() {
92 return CreateArrayIterator(this, ARRAY_ITERATOR_KIND_ENTRIES); 93 return CreateArrayIterator(this, ARRAY_ITERATOR_KIND_ENTRIES);
93 } 94 }
94 95
95 function ArrayValues() { 96 function ArrayValues() {
96 return CreateArrayIterator(this, ARRAY_ITERATOR_KIND_VALUES); 97 return CreateArrayIterator(this, ARRAY_ITERATOR_KIND_VALUES);
97 } 98 }
98 99
(...skipping 18 matching lines...) Expand all
117 %CheckIsBootstrapping(); 118 %CheckIsBootstrapping();
118 119
119 InstallFunctions($Array.prototype, DONT_ENUM, $Array( 120 InstallFunctions($Array.prototype, DONT_ENUM, $Array(
120 'entries', ArrayEntries, 121 'entries', ArrayEntries,
121 'values', ArrayValues, 122 'values', ArrayValues,
122 'keys', ArrayKeys 123 'keys', ArrayKeys
123 )); 124 ));
124 } 125 }
125 126
126 ExtendArrayPrototype(); 127 ExtendArrayPrototype();
OLDNEW
« no previous file with comments | « src/arm/macro-assembler-arm.cc ('k') | src/ast.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698