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 30 matching lines...) Expand all Loading... |
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 var source = NewFunctionString(arguments, 'function*'); |
48 var global_proxy = %GlobalProxy(global); | 48 var global_proxy = %GlobalProxy(global); |
49 // Compile the string in the constructor and not a helper so that errors | 49 // Compile the string in the constructor and not a helper so that errors |
50 // appear to come from here. | 50 // appear to come from here. |
51 var f = %CompileString(source, true); | 51 var f = %_CallFunction(global_proxy, %CompileString(source, true)); |
52 if (!IS_FUNCTION(f)) return f; | |
53 f = %_CallFunction(global_proxy, f); | |
54 %FunctionMarkNameShouldPrintAsAnonymous(f); | 52 %FunctionMarkNameShouldPrintAsAnonymous(f); |
55 return f; | 53 return f; |
56 } | 54 } |
57 | 55 |
58 | 56 |
59 function SetUpGenerators() { | 57 function SetUpGenerators() { |
60 %CheckIsBootstrapping(); | 58 %CheckIsBootstrapping(); |
61 | 59 |
62 // Both Runtime_GeneratorNext and Runtime_GeneratorThrow are supported by | 60 // Both Runtime_GeneratorNext and Runtime_GeneratorThrow are supported by |
63 // neither Crankshaft nor TurboFan, disable optimization of wrappers here. | 61 // neither Crankshaft nor TurboFan, disable optimization of wrappers here. |
(...skipping 14 matching lines...) Expand all Loading... |
78 GeneratorFunctionPrototype, DONT_ENUM | DONT_DELETE | READ_ONLY); | 76 GeneratorFunctionPrototype, DONT_ENUM | DONT_DELETE | READ_ONLY); |
79 %InternalSetPrototype(GeneratorFunctionPrototype, $Function.prototype); | 77 %InternalSetPrototype(GeneratorFunctionPrototype, $Function.prototype); |
80 %SetCode(GeneratorFunctionPrototype, GeneratorFunctionPrototypeConstructor); | 78 %SetCode(GeneratorFunctionPrototype, GeneratorFunctionPrototypeConstructor); |
81 %AddNamedProperty(GeneratorFunctionPrototype, "constructor", | 79 %AddNamedProperty(GeneratorFunctionPrototype, "constructor", |
82 GeneratorFunction, DONT_ENUM | DONT_DELETE | READ_ONLY); | 80 GeneratorFunction, DONT_ENUM | DONT_DELETE | READ_ONLY); |
83 %InternalSetPrototype(GeneratorFunction, $Function); | 81 %InternalSetPrototype(GeneratorFunction, $Function); |
84 %SetCode(GeneratorFunction, GeneratorFunctionConstructor); | 82 %SetCode(GeneratorFunction, GeneratorFunctionConstructor); |
85 } | 83 } |
86 | 84 |
87 SetUpGenerators(); | 85 SetUpGenerators(); |
OLD | NEW |