OLD | NEW |
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 "use strict"; | 5 "use strict"; |
6 | 6 |
7 // This file relies on the fact that the following declarations have been made | 7 // This file relies on the fact that the following declarations have been made |
8 // in runtime.js: | 8 // in runtime.js: |
9 // var $Function = global.Function; | 9 // var $Function = global.Function; |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... |
37 return this; | 37 return this; |
38 } | 38 } |
39 | 39 |
40 function GeneratorFunctionPrototypeConstructor(x) { | 40 function GeneratorFunctionPrototypeConstructor(x) { |
41 if (%_IsConstructCall()) { | 41 if (%_IsConstructCall()) { |
42 throw MakeTypeError('not_constructor', ['GeneratorFunctionPrototype']); | 42 throw MakeTypeError('not_constructor', ['GeneratorFunctionPrototype']); |
43 } | 43 } |
44 } | 44 } |
45 | 45 |
46 function GeneratorFunctionConstructor(arg1) { // length == 1 | 46 function GeneratorFunctionConstructor(arg1) { // length == 1 |
47 var source = NewFunctionString(arguments, 'function*'); | 47 return NewFunctionFromString(arguments, 'function*'); |
48 var global_proxy = %GlobalProxy(global); | |
49 // Compile the string in the constructor and not a helper so that errors | |
50 // appear to come from here. | |
51 var f = %_CallFunction(global_proxy, %CompileString(source, true)); | |
52 %FunctionMarkNameShouldPrintAsAnonymous(f); | |
53 return f; | |
54 } | 48 } |
55 | 49 |
56 | 50 |
57 function SetUpGenerators() { | 51 function SetUpGenerators() { |
58 %CheckIsBootstrapping(); | 52 %CheckIsBootstrapping(); |
59 | 53 |
60 // Both Runtime_GeneratorNext and Runtime_GeneratorThrow are supported by | 54 // Both Runtime_GeneratorNext and Runtime_GeneratorThrow are supported by |
61 // neither Crankshaft nor TurboFan, disable optimization of wrappers here. | 55 // neither Crankshaft nor TurboFan, disable optimization of wrappers here. |
62 %NeverOptimizeFunction(GeneratorObjectNext); | 56 %NeverOptimizeFunction(GeneratorObjectNext); |
63 %NeverOptimizeFunction(GeneratorObjectThrow); | 57 %NeverOptimizeFunction(GeneratorObjectThrow); |
(...skipping 14 matching lines...) Expand all Loading... |
78 symbolToStringTag, "Generator", DONT_ENUM | READ_ONLY); | 72 symbolToStringTag, "Generator", DONT_ENUM | READ_ONLY); |
79 %InternalSetPrototype(GeneratorFunctionPrototype, $Function.prototype); | 73 %InternalSetPrototype(GeneratorFunctionPrototype, $Function.prototype); |
80 %SetCode(GeneratorFunctionPrototype, GeneratorFunctionPrototypeConstructor); | 74 %SetCode(GeneratorFunctionPrototype, GeneratorFunctionPrototypeConstructor); |
81 %AddNamedProperty(GeneratorFunctionPrototype, "constructor", | 75 %AddNamedProperty(GeneratorFunctionPrototype, "constructor", |
82 GeneratorFunction, DONT_ENUM | DONT_DELETE | READ_ONLY); | 76 GeneratorFunction, DONT_ENUM | DONT_DELETE | READ_ONLY); |
83 %InternalSetPrototype(GeneratorFunction, $Function); | 77 %InternalSetPrototype(GeneratorFunction, $Function); |
84 %SetCode(GeneratorFunction, GeneratorFunctionConstructor); | 78 %SetCode(GeneratorFunction, GeneratorFunctionConstructor); |
85 } | 79 } |
86 | 80 |
87 SetUpGenerators(); | 81 SetUpGenerators(); |
OLD | NEW |