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

Side by Side Diff: src/generator.js

Issue 1154743003: Revert of Hook up more import/exports in natives. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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/date.js ('k') | src/harmony-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 // 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(global, utils) { 5 (function(global, utils) {
6 6
7 "use strict"; 7 "use strict";
8 8
9 %CheckIsBootstrapping(); 9 %CheckIsBootstrapping();
10 10
11 // -------------------------------------------------------------------
12 // Imports
13
14 var GlobalFunction = global.Function; 11 var GlobalFunction = global.Function;
15 12
16 var NewFunctionString;
17
18 utils.Import(function(from) {
19 NewFunctionString = from.NewFunctionString;
20 });
21
22 // ---------------------------------------------------------------------------- 13 // ----------------------------------------------------------------------------
23 14
24 // Generator functions and objects are specified by ES6, sections 15.19.3 and 15 // Generator functions and objects are specified by ES6, sections 15.19.3 and
25 // 15.19.4. 16 // 15.19.4.
26 17
27 function GeneratorObjectNext(value) { 18 function GeneratorObjectNext(value) {
28 if (!IS_GENERATOR(this)) { 19 if (!IS_GENERATOR(this)) {
29 throw MakeTypeError(kIncompatibleMethodReceiver, 20 throw MakeTypeError(kIncompatibleMethodReceiver,
30 '[Generator].prototype.next', this); 21 '[Generator].prototype.next', this);
31 } 22 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 // Generator is already closed. 60 // Generator is already closed.
70 throw exn; 61 throw exn;
71 } else { 62 } else {
72 // Generator is running. 63 // Generator is running.
73 throw MakeTypeError(kGeneratorRunning); 64 throw MakeTypeError(kGeneratorRunning);
74 } 65 }
75 } 66 }
76 67
77 68
78 function GeneratorFunctionConstructor(arg1) { // length == 1 69 function GeneratorFunctionConstructor(arg1) { // length == 1
79 var source = NewFunctionString(arguments, 'function*'); 70 var source = $newFunctionString(arguments, 'function*');
80 var global_proxy = %GlobalProxy(GeneratorFunctionConstructor); 71 var global_proxy = %GlobalProxy(GeneratorFunctionConstructor);
81 // Compile the string in the constructor and not a helper so that errors 72 // Compile the string in the constructor and not a helper so that errors
82 // appear to come from here. 73 // appear to come from here.
83 var f = %_CallFunction(global_proxy, %CompileString(source, true)); 74 var f = %_CallFunction(global_proxy, %CompileString(source, true));
84 %FunctionMarkNameShouldPrintAsAnonymous(f); 75 %FunctionMarkNameShouldPrintAsAnonymous(f);
85 return f; 76 return f;
86 } 77 }
87 78
88 // ---------------------------------------------------------------------------- 79 // ----------------------------------------------------------------------------
89 80
90 // Both Runtime_GeneratorNext and Runtime_GeneratorThrow are supported by 81 // Both Runtime_GeneratorNext and Runtime_GeneratorThrow are supported by
91 // neither Crankshaft nor TurboFan, disable optimization of wrappers here. 82 // neither Crankshaft nor TurboFan, disable optimization of wrappers here.
92 %NeverOptimizeFunction(GeneratorObjectNext); 83 %NeverOptimizeFunction(GeneratorObjectNext);
93 %NeverOptimizeFunction(GeneratorObjectThrow); 84 %NeverOptimizeFunction(GeneratorObjectThrow);
94 85
95 // Set up non-enumerable functions on the generator prototype object. 86 // Set up non-enumerable functions on the generator prototype object.
96 var GeneratorObjectPrototype = GeneratorFunctionPrototype.prototype; 87 var GeneratorObjectPrototype = GeneratorFunctionPrototype.prototype;
97 utils.InstallFunctions(GeneratorObjectPrototype, 88 $installFunctions(GeneratorObjectPrototype,
98 DONT_ENUM, 89 DONT_ENUM,
99 ["next", GeneratorObjectNext, 90 ["next", GeneratorObjectNext,
100 "throw", GeneratorObjectThrow]); 91 "throw", GeneratorObjectThrow]);
101 92
102 %AddNamedProperty(GeneratorObjectPrototype, "constructor", 93 %AddNamedProperty(GeneratorObjectPrototype, "constructor",
103 GeneratorFunctionPrototype, DONT_ENUM | READ_ONLY); 94 GeneratorFunctionPrototype, DONT_ENUM | READ_ONLY);
104 %AddNamedProperty(GeneratorObjectPrototype, 95 %AddNamedProperty(GeneratorObjectPrototype,
105 symbolToStringTag, "Generator", DONT_ENUM | READ_ONLY); 96 symbolToStringTag, "Generator", DONT_ENUM | READ_ONLY);
106 %InternalSetPrototype(GeneratorFunctionPrototype, GlobalFunction.prototype); 97 %InternalSetPrototype(GeneratorFunctionPrototype, GlobalFunction.prototype);
107 %AddNamedProperty(GeneratorFunctionPrototype, 98 %AddNamedProperty(GeneratorFunctionPrototype,
108 symbolToStringTag, "GeneratorFunction", DONT_ENUM | READ_ONLY); 99 symbolToStringTag, "GeneratorFunction", DONT_ENUM | READ_ONLY);
109 %AddNamedProperty(GeneratorFunctionPrototype, "constructor", 100 %AddNamedProperty(GeneratorFunctionPrototype, "constructor",
110 GeneratorFunction, DONT_ENUM | READ_ONLY); 101 GeneratorFunction, DONT_ENUM | READ_ONLY);
111 %InternalSetPrototype(GeneratorFunction, GlobalFunction); 102 %InternalSetPrototype(GeneratorFunction, GlobalFunction);
112 %SetCode(GeneratorFunction, GeneratorFunctionConstructor); 103 %SetCode(GeneratorFunction, GeneratorFunctionConstructor);
113 104
114 }) 105 })
OLDNEW
« no previous file with comments | « src/date.js ('k') | src/harmony-array.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698