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 21 matching lines...) Expand all Loading... |
32 // var $Function = global.Function; | 32 // var $Function = global.Function; |
33 | 33 |
34 // ---------------------------------------------------------------------------- | 34 // ---------------------------------------------------------------------------- |
35 | 35 |
36 | 36 |
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)) { |
| 43 throw MakeTypeError('incompatible_method_receiver', |
| 44 ['[Generator].prototype.next', this]); |
| 45 } |
| 46 |
42 // TODO(wingo): Implement. | 47 // TODO(wingo): Implement. |
43 } | 48 } |
44 | 49 |
45 function GeneratorObjectSend(value) { | 50 function GeneratorObjectSend(value) { |
| 51 if (!IS_GENERATOR(this)) { |
| 52 throw MakeTypeError('incompatible_method_receiver', |
| 53 ['[Generator].prototype.send', this]); |
| 54 } |
| 55 |
46 // TODO(wingo): Implement. | 56 // TODO(wingo): Implement. |
47 } | 57 } |
48 | 58 |
49 function GeneratorObjectThrow(exn) { | 59 function GeneratorObjectThrow(exn) { |
| 60 if (!IS_GENERATOR(this)) { |
| 61 throw MakeTypeError('incompatible_method_receiver', |
| 62 ['[Generator].prototype.throw', this]); |
| 63 } |
| 64 |
50 // TODO(wingo): Implement. | 65 // TODO(wingo): Implement. |
51 } | 66 } |
52 | 67 |
53 function GeneratorObjectClose() { | 68 function GeneratorObjectClose() { |
| 69 if (!IS_GENERATOR(this)) { |
| 70 throw MakeTypeError('incompatible_method_receiver', |
| 71 ['[Generator].prototype.close', this]); |
| 72 } |
| 73 |
54 // TODO(wingo): Implement. | 74 // TODO(wingo): Implement. |
55 } | 75 } |
56 | 76 |
57 function SetUpGenerators() { | 77 function SetUpGenerators() { |
58 %CheckIsBootstrapping(); | 78 %CheckIsBootstrapping(); |
59 var GeneratorObjectPrototype = GeneratorFunctionPrototype.prototype; | 79 var GeneratorObjectPrototype = GeneratorFunctionPrototype.prototype; |
60 InstallFunctions(GeneratorObjectPrototype, | 80 InstallFunctions(GeneratorObjectPrototype, |
61 DONT_ENUM | DONT_DELETE | READ_ONLY, | 81 DONT_ENUM | DONT_DELETE | READ_ONLY, |
62 ["next", GeneratorObjectNext, | 82 ["next", GeneratorObjectNext, |
63 "send", GeneratorObjectSend, | 83 "send", GeneratorObjectSend, |
64 "throw", GeneratorObjectThrow, | 84 "throw", GeneratorObjectThrow, |
65 "close", GeneratorObjectClose]); | 85 "close", GeneratorObjectClose]); |
66 %SetProperty(GeneratorObjectPrototype, "constructor", | 86 %SetProperty(GeneratorObjectPrototype, "constructor", |
67 GeneratorFunctionPrototype, DONT_ENUM | DONT_DELETE | READ_ONLY); | 87 GeneratorFunctionPrototype, DONT_ENUM | DONT_DELETE | READ_ONLY); |
68 %SetPrototype(GeneratorFunctionPrototype, $Function.prototype); | 88 %SetPrototype(GeneratorFunctionPrototype, $Function.prototype); |
69 %SetProperty(GeneratorFunctionPrototype, "constructor", | 89 %SetProperty(GeneratorFunctionPrototype, "constructor", |
70 GeneratorFunction, DONT_ENUM | DONT_DELETE | READ_ONLY); | 90 GeneratorFunction, DONT_ENUM | DONT_DELETE | READ_ONLY); |
71 %SetPrototype(GeneratorFunction, $Function); | 91 %SetPrototype(GeneratorFunction, $Function); |
72 } | 92 } |
73 | 93 |
74 SetUpGenerators(); | 94 SetUpGenerators(); |
OLD | NEW |