Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Unified Diff: src/generators.js

Issue 13192004: arrange to create prototypes for generators (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Generators JS runtime to separate file, to avoid overhead when no --harmony-generators Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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();

Powered by Google App Engine
This is Rietveld 408576698