Index: src/generators.js |
diff --git a/src/symbol.js b/src/generators.js |
similarity index 53% |
copy from src/symbol.js |
copy to src/generators.js |
index fb7476f4383362925a020169427a75fbb02e0968..ef14b354d1e68e3e725809b861cdfbd625900591 100644 |
--- a/src/symbol.js |
+++ b/src/generators.js |
@@ -25,57 +25,47 @@ |
// (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"; |
+// 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 |
-var $Symbol = global.Symbol; |
+var GeneratorFunctionPrototype = function () {}; |
+function GeneratorFunction() {}; |
+var GeneratorIteratorPrototype = new $Object; |
-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 GeneratorIteratorNext() { |
+ // TODO(wingo): Implement. |
} |
-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); |
+function GeneratorIteratorSend(value) { |
+ // TODO(wingo): Implement. |
} |
-function SymbolToString() { |
- throw MakeTypeError('symbol_to_string'); |
+function GeneratorIteratorThrow(exn) { |
+ // 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 GeneratorIteratorClose() { |
+ // TODO(wingo): Implement. |
} |
-//------------------------------------------------------------------- |
- |
-function SetUpSymbol() { |
+function SetUpGenerators() { |
%CheckIsBootstrapping(); |
+ // TODO(wingo): What are the right flags here? Should these objects |
+ // be extensible? They are user-visible. |
+ %SetPrototype(GeneratorFunction, $Function); |
+ %FunctionSetPrototype(GeneratorFunction, GeneratorFunctionPrototype); |
- %SetCode($Symbol, SymbolConstructor); |
- %FunctionSetPrototype($Symbol, new $Symbol()); |
- %SetProperty($Symbol.prototype, "constructor", $Symbol, DONT_ENUM); |
+ %SetProperty(GeneratorFunctionPrototype, 'constructor', GeneratorFunction, |
+ DONT_ENUM | DONT_DELETE | READ_ONLY); |
+ %FunctionSetPrototype(GeneratorFunctionPrototype, GeneratorIteratorPrototype); |
rossberg
2013/04/09 16:44:14
Don't you also need to set GeneratorIteratorProtot
|
- InstallGetter($Symbol.prototype, "name", SymbolGetName); |
- InstallFunctions($Symbol.prototype, DONT_ENUM, $Array( |
- "toString", SymbolToString, |
- "valueOf", SymbolValueOf |
- )); |
+ InstallFunctions(GeneratorIteratorPrototype, |
+ DONT_ENUM | DONT_DELETE | READ_ONLY, |
+ $Array("next", GeneratorIteratorNext, |
rossberg
2013/04/09 16:44:14
Nit: Use array literal here.
|
+ "send", GeneratorIteratorSend, |
+ "throw", GeneratorIteratorThrow, |
+ "close", GeneratorIteratorClose)); |
} |
-SetUpSymbol(); |
+SetUpGenerators(); |