Chromium Code Reviews| Index: src/generator.js |
| diff --git a/src/symbol.js b/src/generator.js |
| similarity index 52% |
| copy from src/symbol.js |
| copy to src/generator.js |
| index fb7476f4383362925a020169427a75fbb02e0968..cac536054e6503b8925ebdc37385f1c861ca50ac 100644 |
| --- a/src/symbol.js |
| +++ b/src/generator.js |
| @@ -25,57 +25,49 @@ |
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| -"use strict"; |
| +// This file relies on the fact that the following declarations have been made |
|
Michael Starzinger
2013/04/11 18:43:47
Late drive-by comment: Can we make this file "use
|
| +// |
| +// in runtime.js: |
| +// var $Function = global.Function; |
| -var $Symbol = global.Symbol; |
| +// ---------------------------------------------------------------------------- |
| -function SymbolConstructor(x) { |
| - var value = |
| - IS_SYMBOL(x) ? x : %CreateSymbol(IS_UNDEFINED(x) ? x : ToString(x)); |
| - if (%_IsConstructCall()) { |
| - %_SetValueOf(this, value); |
| - } else { |
| - return value; |
| - } |
| -} |
| -function SymbolGetName() { |
| - var symbol = IS_SYMBOL_WRAPPER(this) ? %_ValueOf(this) : this; |
| - if (!IS_SYMBOL(symbol)) { |
| - throw MakeTypeError( |
| - 'incompatible_method_receiver', ["Symbol.prototype.name", this]); |
| - } |
| - return %SymbolName(symbol); |
| +// TODO(wingo): Give link to specification. For now, the following diagram is |
| +// the spec: |
| +// http://wiki.ecmascript.org/lib/exe/fetch.php?cache=cache&media=harmony:es6_generator_object_model_3-29-13.png |
| + |
| +function GeneratorObjectNext() { |
| + // TODO(wingo): Implement. |
| } |
| -function SymbolToString() { |
| - throw MakeTypeError('symbol_to_string'); |
| +function GeneratorObjectSend(value) { |
| + // TODO(wingo): Implement. |
| } |
| -function SymbolValueOf() { |
| - // NOTE: Both Symbol objects and values can enter here as |
| - // 'this'. This is not as dictated by ECMA-262. |
| - if (!IS_SYMBOL(this) && !IS_SYMBOL_WRAPPER(this)) { |
| - throw MakeTypeError( |
| - 'incompatible_method_receiver', ["Symbol.prototype.valueOf", this]); |
| - } |
| - return %_ValueOf(this); |
| +function GeneratorObjectThrow(exn) { |
| + // TODO(wingo): Implement. |
| } |
| -//------------------------------------------------------------------- |
| +function GeneratorObjectClose() { |
| + // TODO(wingo): Implement. |
| +} |
| -function SetUpSymbol() { |
| +function SetUpGenerators() { |
| %CheckIsBootstrapping(); |
| - |
| - %SetCode($Symbol, SymbolConstructor); |
| - %FunctionSetPrototype($Symbol, new $Symbol()); |
| - %SetProperty($Symbol.prototype, "constructor", $Symbol, DONT_ENUM); |
| - |
| - InstallGetter($Symbol.prototype, "name", SymbolGetName); |
| - InstallFunctions($Symbol.prototype, DONT_ENUM, $Array( |
| - "toString", SymbolToString, |
| - "valueOf", SymbolValueOf |
| - )); |
| + var GeneratorObjectPrototype = GeneratorFunctionPrototype.prototype; |
| + InstallFunctions(GeneratorObjectPrototype, |
| + DONT_ENUM | DONT_DELETE | READ_ONLY, |
| + ["next", GeneratorObjectNext, |
| + "send", GeneratorObjectSend, |
| + "throw", GeneratorObjectThrow, |
| + "close", GeneratorObjectClose]); |
| + %SetProperty(GeneratorObjectPrototype, "constructor", |
| + GeneratorFunctionPrototype, DONT_ENUM | DONT_DELETE | READ_ONLY); |
| + %SetPrototype(GeneratorFunctionPrototype, $Function.prototype); |
| + %SetProperty(GeneratorFunctionPrototype, "constructor", |
| + GeneratorFunction, DONT_ENUM | DONT_DELETE | READ_ONLY); |
| + %SetPrototype(GeneratorFunction, $Function); |
| } |
| -SetUpSymbol(); |
| +SetUpGenerators(); |