Chromium Code Reviews| Index: src/generator.js |
| diff --git a/src/generator.js b/src/generator.js |
| index 5e61091565567bf9d516a45d0efd72add6aa33af..9693ce6c61668b3c76d0ab8e2cf57ba8f1d32b33 100644 |
| --- a/src/generator.js |
| +++ b/src/generator.js |
| @@ -65,6 +65,24 @@ function GeneratorObjectThrow(exn) { |
| return %_GeneratorThrow(this, exn); |
| } |
| +function GeneratorFunctionPrototypeConstructor(x) { |
| + if (%_IsConstructCall()) { |
| + throw MakeTypeError('not_constructor', ['GeneratorFunctionPrototype']); |
| + } |
| +} |
| + |
| +function GeneratorFunctionConstructor(arg1) { // length == 1 |
| + var n = %_ArgumentsLength(); |
| + if (n) { |
|
rossberg
2013/05/13 11:33:46
Nit: n > 0
wingo
2013/05/14 10:11:50
Done.
|
| + var formals = new InternalArray(n - 1); |
| + for (var i = 0; i < n - 1; i++) formals[i] = %_Arguments(i); |
| + return NewFunctionHelper(formals, ToString(%_Arguments(n - 1)), true); |
| + } else { |
| + return NewFunctionHelper(new InternalArray(0), '', true); |
| + } |
| +} |
| + |
| + |
| function SetUpGenerators() { |
| %CheckIsBootstrapping(); |
| var GeneratorObjectPrototype = GeneratorFunctionPrototype.prototype; |
| @@ -76,9 +94,11 @@ function SetUpGenerators() { |
| %SetProperty(GeneratorObjectPrototype, "constructor", |
| GeneratorFunctionPrototype, DONT_ENUM | DONT_DELETE | READ_ONLY); |
| %SetPrototype(GeneratorFunctionPrototype, $Function.prototype); |
| + %SetCode(GeneratorFunctionPrototype, GeneratorFunctionPrototypeConstructor); |
| %SetProperty(GeneratorFunctionPrototype, "constructor", |
| GeneratorFunction, DONT_ENUM | DONT_DELETE | READ_ONLY); |
| %SetPrototype(GeneratorFunction, $Function); |
| + %SetCode(GeneratorFunction, GeneratorFunctionConstructor); |
| } |
| SetUpGenerators(); |