| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 // TODO(wingo): Give link to specification. For now, the following diagram is | 37 // TODO(wingo): Give link to specification. For now, the following diagram is |
| 38 // the spec: | 38 // the spec: |
| 39 // http://wiki.ecmascript.org/lib/exe/fetch.php?cache=cache&media=harmony:es6_ge
nerator_object_model_3-29-13.png | 39 // http://wiki.ecmascript.org/lib/exe/fetch.php?cache=cache&media=harmony:es6_ge
nerator_object_model_3-29-13.png |
| 40 | 40 |
| 41 function GeneratorObjectNext() { | 41 function GeneratorObjectNext() { |
| 42 if (!IS_GENERATOR(this)) { | 42 if (!IS_GENERATOR(this)) { |
| 43 throw MakeTypeError('incompatible_method_receiver', | 43 throw MakeTypeError('incompatible_method_receiver', |
| 44 ['[Generator].prototype.next', this]); | 44 ['[Generator].prototype.next', this]); |
| 45 } | 45 } |
| 46 | 46 |
| 47 // TODO(wingo): Implement. | 47 return %_GeneratorSend(this, void 0); |
| 48 } | 48 } |
| 49 | 49 |
| 50 function GeneratorObjectSend(value) { | 50 function GeneratorObjectSend(value) { |
| 51 if (!IS_GENERATOR(this)) { | 51 if (!IS_GENERATOR(this)) { |
| 52 throw MakeTypeError('incompatible_method_receiver', | 52 throw MakeTypeError('incompatible_method_receiver', |
| 53 ['[Generator].prototype.send', this]); | 53 ['[Generator].prototype.send', this]); |
| 54 } | 54 } |
| 55 | 55 |
| 56 // TODO(wingo): Implement. | 56 return %_GeneratorSend(this, value); |
| 57 } | 57 } |
| 58 | 58 |
| 59 function GeneratorObjectThrow(exn) { | 59 function GeneratorObjectThrow(exn) { |
| 60 if (!IS_GENERATOR(this)) { | 60 if (!IS_GENERATOR(this)) { |
| 61 throw MakeTypeError('incompatible_method_receiver', | 61 throw MakeTypeError('incompatible_method_receiver', |
| 62 ['[Generator].prototype.throw', this]); | 62 ['[Generator].prototype.throw', this]); |
| 63 } | 63 } |
| 64 | 64 |
| 65 // TODO(wingo): Implement. | 65 return %_GeneratorThrow(this, exn); |
| 66 } | |
| 67 | |
| 68 function GeneratorObjectClose() { | |
| 69 if (!IS_GENERATOR(this)) { | |
| 70 throw MakeTypeError('incompatible_method_receiver', | |
| 71 ['[Generator].prototype.close', this]); | |
| 72 } | |
| 73 | |
| 74 // TODO(wingo): Implement. | |
| 75 } | 66 } |
| 76 | 67 |
| 77 function SetUpGenerators() { | 68 function SetUpGenerators() { |
| 78 %CheckIsBootstrapping(); | 69 %CheckIsBootstrapping(); |
| 79 var GeneratorObjectPrototype = GeneratorFunctionPrototype.prototype; | 70 var GeneratorObjectPrototype = GeneratorFunctionPrototype.prototype; |
| 80 InstallFunctions(GeneratorObjectPrototype, | 71 InstallFunctions(GeneratorObjectPrototype, |
| 81 DONT_ENUM | DONT_DELETE | READ_ONLY, | 72 DONT_ENUM | DONT_DELETE | READ_ONLY, |
| 82 ["next", GeneratorObjectNext, | 73 ["next", GeneratorObjectNext, |
| 83 "send", GeneratorObjectSend, | 74 "send", GeneratorObjectSend, |
| 84 "throw", GeneratorObjectThrow, | 75 "throw", GeneratorObjectThrow]); |
| 85 "close", GeneratorObjectClose]); | |
| 86 %SetProperty(GeneratorObjectPrototype, "constructor", | 76 %SetProperty(GeneratorObjectPrototype, "constructor", |
| 87 GeneratorFunctionPrototype, DONT_ENUM | DONT_DELETE | READ_ONLY); | 77 GeneratorFunctionPrototype, DONT_ENUM | DONT_DELETE | READ_ONLY); |
| 88 %SetPrototype(GeneratorFunctionPrototype, $Function.prototype); | 78 %SetPrototype(GeneratorFunctionPrototype, $Function.prototype); |
| 89 %SetProperty(GeneratorFunctionPrototype, "constructor", | 79 %SetProperty(GeneratorFunctionPrototype, "constructor", |
| 90 GeneratorFunction, DONT_ENUM | DONT_DELETE | READ_ONLY); | 80 GeneratorFunction, DONT_ENUM | DONT_DELETE | READ_ONLY); |
| 91 %SetPrototype(GeneratorFunction, $Function); | 81 %SetPrototype(GeneratorFunction, $Function); |
| 92 } | 82 } |
| 93 | 83 |
| 94 SetUpGenerators(); | 84 SetUpGenerators(); |
| OLD | NEW |