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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 return this; | 67 return this; |
68 } | 68 } |
69 | 69 |
70 function GeneratorFunctionPrototypeConstructor(x) { | 70 function GeneratorFunctionPrototypeConstructor(x) { |
71 if (%_IsConstructCall()) { | 71 if (%_IsConstructCall()) { |
72 throw MakeTypeError('not_constructor', ['GeneratorFunctionPrototype']); | 72 throw MakeTypeError('not_constructor', ['GeneratorFunctionPrototype']); |
73 } | 73 } |
74 } | 74 } |
75 | 75 |
76 function GeneratorFunctionConstructor(arg1) { // length == 1 | 76 function GeneratorFunctionConstructor(arg1) { // length == 1 |
77 return NewFunctionFromString(arguments, 'function*'); | 77 var source = NewFunctionString(arguments, 'function*'); |
| 78 var global_proxy = %GlobalProxy(global); |
| 79 // Compile the string in the constructor and not a helper so that errors |
| 80 // appear to come from here. |
| 81 var f = %_CallFunction(global_proxy, %CompileString(source, true)); |
| 82 %FunctionMarkNameShouldPrintAsAnonymous(f); |
| 83 return f; |
78 } | 84 } |
79 | 85 |
80 | 86 |
81 function SetUpGenerators() { | 87 function SetUpGenerators() { |
82 %CheckIsBootstrapping(); | 88 %CheckIsBootstrapping(); |
83 | 89 |
84 // Both Runtime_GeneratorNext and Runtime_GeneratorThrow are supported by | 90 // Both Runtime_GeneratorNext and Runtime_GeneratorThrow are supported by |
85 // neither Crankshaft nor TurboFan, disable optimization of wrappers here. | 91 // neither Crankshaft nor TurboFan, disable optimization of wrappers here. |
86 %NeverOptimizeFunction(GeneratorObjectNext); | 92 %NeverOptimizeFunction(GeneratorObjectNext); |
87 %NeverOptimizeFunction(GeneratorObjectThrow); | 93 %NeverOptimizeFunction(GeneratorObjectThrow); |
(...skipping 16 matching lines...) Expand all Loading... |
104 %AddNamedProperty(GeneratorFunctionPrototype, | 110 %AddNamedProperty(GeneratorFunctionPrototype, |
105 symbolToStringTag, "GeneratorFunction", DONT_ENUM | READ_ONLY); | 111 symbolToStringTag, "GeneratorFunction", DONT_ENUM | READ_ONLY); |
106 %SetCode(GeneratorFunctionPrototype, GeneratorFunctionPrototypeConstructor); | 112 %SetCode(GeneratorFunctionPrototype, GeneratorFunctionPrototypeConstructor); |
107 %AddNamedProperty(GeneratorFunctionPrototype, "constructor", | 113 %AddNamedProperty(GeneratorFunctionPrototype, "constructor", |
108 GeneratorFunction, DONT_ENUM | READ_ONLY); | 114 GeneratorFunction, DONT_ENUM | READ_ONLY); |
109 %InternalSetPrototype(GeneratorFunction, $Function); | 115 %InternalSetPrototype(GeneratorFunction, $Function); |
110 %SetCode(GeneratorFunction, GeneratorFunctionConstructor); | 116 %SetCode(GeneratorFunction, GeneratorFunctionConstructor); |
111 } | 117 } |
112 | 118 |
113 SetUpGenerators(); | 119 SetUpGenerators(); |
OLD | NEW |