| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 } else { | 60 } else { |
| 61 // Generator is running. | 61 // Generator is running. |
| 62 throw MakeTypeError('generator_running', []); | 62 throw MakeTypeError('generator_running', []); |
| 63 } | 63 } |
| 64 } | 64 } |
| 65 | 65 |
| 66 function GeneratorObjectIterator() { | 66 function GeneratorObjectIterator() { |
| 67 return this; | 67 return this; |
| 68 } | 68 } |
| 69 | 69 |
| 70 function GeneratorFunctionPrototypeConstructor(x) { | |
| 71 if (%_IsConstructCall()) { | |
| 72 throw MakeTypeError('not_constructor', ['GeneratorFunctionPrototype']); | |
| 73 } | |
| 74 } | |
| 75 | |
| 76 function GeneratorFunctionConstructor(arg1) { // length == 1 | 70 function GeneratorFunctionConstructor(arg1) { // length == 1 |
| 77 var source = NewFunctionString(arguments, 'function*'); | 71 var source = NewFunctionString(arguments, 'function*'); |
| 78 var global_proxy = %GlobalProxy(global); | 72 var global_proxy = %GlobalProxy(global); |
| 79 // Compile the string in the constructor and not a helper so that errors | 73 // Compile the string in the constructor and not a helper so that errors |
| 80 // appear to come from here. | 74 // appear to come from here. |
| 81 var f = %_CallFunction(global_proxy, %CompileString(source, true)); | 75 var f = %_CallFunction(global_proxy, %CompileString(source, true)); |
| 82 %FunctionMarkNameShouldPrintAsAnonymous(f); | 76 %FunctionMarkNameShouldPrintAsAnonymous(f); |
| 83 return f; | 77 return f; |
| 84 } | 78 } |
| 85 | 79 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 102 %FunctionSetName(GeneratorObjectIterator, '[Symbol.iterator]'); | 96 %FunctionSetName(GeneratorObjectIterator, '[Symbol.iterator]'); |
| 103 %AddNamedProperty(GeneratorObjectPrototype, symbolIterator, | 97 %AddNamedProperty(GeneratorObjectPrototype, symbolIterator, |
| 104 GeneratorObjectIterator, DONT_ENUM | DONT_DELETE | READ_ONLY); | 98 GeneratorObjectIterator, DONT_ENUM | DONT_DELETE | READ_ONLY); |
| 105 %AddNamedProperty(GeneratorObjectPrototype, "constructor", | 99 %AddNamedProperty(GeneratorObjectPrototype, "constructor", |
| 106 GeneratorFunctionPrototype, DONT_ENUM | READ_ONLY); | 100 GeneratorFunctionPrototype, DONT_ENUM | READ_ONLY); |
| 107 %AddNamedProperty(GeneratorObjectPrototype, | 101 %AddNamedProperty(GeneratorObjectPrototype, |
| 108 symbolToStringTag, "Generator", DONT_ENUM | READ_ONLY); | 102 symbolToStringTag, "Generator", DONT_ENUM | READ_ONLY); |
| 109 %InternalSetPrototype(GeneratorFunctionPrototype, $Function.prototype); | 103 %InternalSetPrototype(GeneratorFunctionPrototype, $Function.prototype); |
| 110 %AddNamedProperty(GeneratorFunctionPrototype, | 104 %AddNamedProperty(GeneratorFunctionPrototype, |
| 111 symbolToStringTag, "GeneratorFunction", DONT_ENUM | READ_ONLY); | 105 symbolToStringTag, "GeneratorFunction", DONT_ENUM | READ_ONLY); |
| 112 %SetCode(GeneratorFunctionPrototype, GeneratorFunctionPrototypeConstructor); | |
| 113 %AddNamedProperty(GeneratorFunctionPrototype, "constructor", | 106 %AddNamedProperty(GeneratorFunctionPrototype, "constructor", |
| 114 GeneratorFunction, DONT_ENUM | READ_ONLY); | 107 GeneratorFunction, DONT_ENUM | READ_ONLY); |
| 115 %InternalSetPrototype(GeneratorFunction, $Function); | 108 %InternalSetPrototype(GeneratorFunction, $Function); |
| 116 %SetCode(GeneratorFunction, GeneratorFunctionConstructor); | 109 %SetCode(GeneratorFunction, GeneratorFunctionConstructor); |
| 117 } | 110 } |
| 118 | 111 |
| 119 SetUpGenerators(); | 112 SetUpGenerators(); |
| OLD | NEW |