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

Unified Diff: src/generator.js

Issue 13192004: arrange to create prototypes for generators (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Explicitly add constructor properties in generator.js Created 7 years, 8 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
« no previous file with comments | « src/factory.cc ('k') | src/heap.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « src/factory.cc ('k') | src/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698