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

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

Issue 1000063002: Hide RegExp and String initialization in a closure. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: address comments Created 5 years, 9 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
« no previous file with comments | « src/string.js ('k') | src/third_party/fdlibm/fdlibm.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 (function() {
6
5 "use strict"; 7 "use strict";
6 8
9 %CheckIsBootstrapping();
7 10
8 // This file relies on the fact that the following declaration has been made 11 var GlobalArray = global.Array;
9 // in runtime.js: 12 var GlobalObject = global.Object;
10 // var $String = global.String; 13 var GlobalString = global.String;
11 14
15 //-------------------------------------------------------------------
12 16
13 var stringIteratorIteratedStringSymbol = 17 var stringIteratorIteratedStringSymbol =
14 GLOBAL_PRIVATE("StringIterator#iteratedString"); 18 GLOBAL_PRIVATE("StringIterator#iteratedString");
15 var stringIteratorNextIndexSymbol = GLOBAL_PRIVATE("StringIterator#next"); 19 var stringIteratorNextIndexSymbol = GLOBAL_PRIVATE("StringIterator#next");
16 20
17 21
18 function StringIterator() {} 22 function StringIterator() {}
19 23
20 24
21 // 21.1.5.1 CreateStringIterator Abstract Operation 25 // 21.1.5.1 CreateStringIterator Abstract Operation
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 position++; 72 position++;
69 } 73 }
70 } 74 }
71 75
72 SET_PRIVATE(iterator, stringIteratorNextIndexSymbol, position); 76 SET_PRIVATE(iterator, stringIteratorNextIndexSymbol, position);
73 77
74 return CreateIteratorResultObject(resultString, false); 78 return CreateIteratorResultObject(resultString, false);
75 } 79 }
76 80
77 81
78 function SetUpStringIterator() {
79 %CheckIsBootstrapping();
80
81 %FunctionSetPrototype(StringIterator, new $Object());
82 %FunctionSetInstanceClassName(StringIterator, 'String Iterator');
83
84 InstallFunctions(StringIterator.prototype, DONT_ENUM, $Array(
85 'next', StringIteratorNext
86 ));
87 %FunctionSetName(StringIteratorIterator, '[Symbol.iterator]');
88 %AddNamedProperty(StringIterator.prototype, symbolIterator,
89 StringIteratorIterator, DONT_ENUM);
90 %AddNamedProperty(StringIterator.prototype, symbolToStringTag,
91 "String Iterator", READ_ONLY | DONT_ENUM);
92 }
93 SetUpStringIterator();
94
95
96 // 21.1.3.27 String.prototype [ @@iterator ]( ) 82 // 21.1.3.27 String.prototype [ @@iterator ]( )
97 function StringPrototypeIterator() { 83 function StringPrototypeIterator() {
98 return CreateStringIterator(this); 84 return CreateStringIterator(this);
99 } 85 }
100 86
87 //-------------------------------------------------------------------
101 88
102 function ExtendStringPrototypeWithIterator() { 89 %FunctionSetPrototype(StringIterator, new GlobalObject());
103 %CheckIsBootstrapping(); 90 %FunctionSetInstanceClassName(StringIterator, 'String Iterator');
104 91
105 %FunctionSetName(StringPrototypeIterator, '[Symbol.iterator]'); 92 InstallFunctions(StringIterator.prototype, DONT_ENUM, GlobalArray(
106 %AddNamedProperty($String.prototype, symbolIterator, 93 'next', StringIteratorNext
107 StringPrototypeIterator, DONT_ENUM); 94 ));
108 } 95 %FunctionSetName(StringIteratorIterator, '[Symbol.iterator]');
109 ExtendStringPrototypeWithIterator(); 96 %AddNamedProperty(StringIterator.prototype, symbolIterator,
97 StringIteratorIterator, DONT_ENUM);
98 %AddNamedProperty(StringIterator.prototype, symbolToStringTag,
99 "String Iterator", READ_ONLY | DONT_ENUM);
100
101 %FunctionSetName(StringPrototypeIterator, '[Symbol.iterator]');
102 %AddNamedProperty(GlobalString.prototype, symbolIterator,
103 StringPrototypeIterator, DONT_ENUM);
104
105 })();
OLDNEW
« no previous file with comments | « src/string.js ('k') | src/third_party/fdlibm/fdlibm.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698