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 } | 37 } |
38 | 38 |
39 function GeneratorFunctionPrototypeConstructor(x) { | 39 function GeneratorFunctionPrototypeConstructor(x) { |
40 if (%_IsConstructCall()) { | 40 if (%_IsConstructCall()) { |
41 throw MakeTypeError('not_constructor', ['GeneratorFunctionPrototype']); | 41 throw MakeTypeError('not_constructor', ['GeneratorFunctionPrototype']); |
42 } | 42 } |
43 } | 43 } |
44 | 44 |
45 function GeneratorFunctionConstructor(arg1) { // length == 1 | 45 function GeneratorFunctionConstructor(arg1) { // length == 1 |
46 var source = NewFunctionString(arguments, 'function*'); | 46 var source = NewFunctionString(arguments, 'function*'); |
47 var global_receiver = %GlobalReceiver(global); | 47 var global_proxy = %GlobalProxy(global); |
48 // Compile the string in the constructor and not a helper so that errors | 48 // Compile the string in the constructor and not a helper so that errors |
49 // appear to come from here. | 49 // appear to come from here. |
50 var f = %CompileString(source, true); | 50 var f = %CompileString(source, true); |
51 if (!IS_FUNCTION(f)) return f; | 51 if (!IS_FUNCTION(f)) return f; |
52 f = %_CallFunction(global_receiver, f); | 52 f = %_CallFunction(global_proxy, f); |
53 %FunctionMarkNameShouldPrintAsAnonymous(f); | 53 %FunctionMarkNameShouldPrintAsAnonymous(f); |
54 return f; | 54 return f; |
55 } | 55 } |
56 | 56 |
57 | 57 |
58 function SetUpGenerators() { | 58 function SetUpGenerators() { |
59 %CheckIsBootstrapping(); | 59 %CheckIsBootstrapping(); |
60 var GeneratorObjectPrototype = GeneratorFunctionPrototype.prototype; | 60 var GeneratorObjectPrototype = GeneratorFunctionPrototype.prototype; |
61 InstallFunctions(GeneratorObjectPrototype, | 61 InstallFunctions(GeneratorObjectPrototype, |
62 DONT_ENUM | DONT_DELETE | READ_ONLY, | 62 DONT_ENUM | DONT_DELETE | READ_ONLY, |
63 ["next", GeneratorObjectNext, | 63 ["next", GeneratorObjectNext, |
64 "throw", GeneratorObjectThrow]); | 64 "throw", GeneratorObjectThrow]); |
65 %FunctionSetName(GeneratorObjectIterator, '[Symbol.iterator]'); | 65 %FunctionSetName(GeneratorObjectIterator, '[Symbol.iterator]'); |
66 %AddProperty(GeneratorObjectPrototype, symbolIterator, | 66 %AddProperty(GeneratorObjectPrototype, symbolIterator, |
67 GeneratorObjectIterator, DONT_ENUM | DONT_DELETE | READ_ONLY); | 67 GeneratorObjectIterator, DONT_ENUM | DONT_DELETE | READ_ONLY); |
68 %AddProperty(GeneratorObjectPrototype, "constructor", | 68 %AddProperty(GeneratorObjectPrototype, "constructor", |
69 GeneratorFunctionPrototype, DONT_ENUM | DONT_DELETE | READ_ONLY); | 69 GeneratorFunctionPrototype, DONT_ENUM | DONT_DELETE | READ_ONLY); |
70 %SetPrototype(GeneratorFunctionPrototype, $Function.prototype); | 70 %SetPrototype(GeneratorFunctionPrototype, $Function.prototype); |
71 %SetCode(GeneratorFunctionPrototype, GeneratorFunctionPrototypeConstructor); | 71 %SetCode(GeneratorFunctionPrototype, GeneratorFunctionPrototypeConstructor); |
72 %AddProperty(GeneratorFunctionPrototype, "constructor", | 72 %AddProperty(GeneratorFunctionPrototype, "constructor", |
73 GeneratorFunction, DONT_ENUM | DONT_DELETE | READ_ONLY); | 73 GeneratorFunction, DONT_ENUM | DONT_DELETE | READ_ONLY); |
74 %SetPrototype(GeneratorFunction, $Function); | 74 %SetPrototype(GeneratorFunction, $Function); |
75 %SetCode(GeneratorFunction, GeneratorFunctionConstructor); | 75 %SetCode(GeneratorFunction, GeneratorFunctionConstructor); |
76 } | 76 } |
77 | 77 |
78 SetUpGenerators(); | 78 SetUpGenerators(); |
OLD | NEW |