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

Unified Diff: src/string-iterator.js

Issue 486763002: Make all global private symbols own symbols. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rename Created 6 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 side-by-side diff with in-line comments
Download patch
Index: src/string-iterator.js
diff --git a/src/string-iterator.js b/src/string-iterator.js
index 7222885a56f465931980d646a277ea9c69cc1abf..e237257e03538c8d7a73995061636de1a95a5b0b 100644
--- a/src/string-iterator.js
+++ b/src/string-iterator.js
@@ -11,8 +11,10 @@
var stringIteratorIteratedStringSymbol =
- GLOBAL_PRIVATE("StringIterator#iteratedString");
-var stringIteratorNextIndexSymbol = GLOBAL_PRIVATE("StringIterator#next");
+ GLOBAL_PRIVATE_OWN("StringIterator#iteratedString");
+var stringIteratorNextIndexSymbol = GLOBAL_PRIVATE_OWN("StringIterator#next");
+
+var stringEndOfIterationMarker = new $Object();
function StringIterator() {}
@@ -38,13 +40,13 @@ function StringIteratorIterator() {
function StringIteratorNext() {
var iterator = ToObject(this);
- if (!HAS_PRIVATE(iterator, stringIteratorIteratedStringSymbol)) {
+ if (!HAS_DEFINED_PRIVATE(iterator, stringIteratorIteratedStringSymbol)) {
throw MakeTypeError('incompatible_method_receiver',
['String Iterator.prototype.next']);
}
var s = GET_PRIVATE(iterator, stringIteratorIteratedStringSymbol);
- if (IS_UNDEFINED(s)) {
+ if (s === stringEndOfIterationMarker) {
wingo 2014/08/20 15:32:53 Wouldn't stringEndOfIterationMarker be per-realm?
arv (Not doing code reviews) 2014/08/20 15:39:26 You are right. This is not going to work. I don't
Dmitry Lomov (no reviews) 2014/08/20 17:01:37 Thanks, good catch, I haven't thought of that.
arv (Not doing code reviews) 2014/08/20 18:07:07 In this case and for the ArrayIterator we can chec
return CreateIteratorResultObject(UNDEFINED, true);
}
@@ -52,7 +54,8 @@ function StringIteratorNext() {
var length = TO_UINT32(s.length);
if (position >= length) {
- SET_PRIVATE(iterator, stringIteratorIteratedStringSymbol, UNDEFINED);
+ SET_PRIVATE(iterator, stringIteratorIteratedStringSymbol,
+ stringEndOfIterationMarker);
return CreateIteratorResultObject(UNDEFINED, true);
}

Powered by Google App Engine
This is Rietveld 408576698