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

Side by Side Diff: src/generator.js

Issue 14619040: Revert "GeneratorFunction() makes generator instances" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/v8natives.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 function GeneratorObjectThrow(exn) { 59 function GeneratorObjectThrow(exn) {
60 if (!IS_GENERATOR(this)) { 60 if (!IS_GENERATOR(this)) {
61 throw MakeTypeError('incompatible_method_receiver', 61 throw MakeTypeError('incompatible_method_receiver',
62 ['[Generator].prototype.throw', this]); 62 ['[Generator].prototype.throw', this]);
63 } 63 }
64 64
65 return %_GeneratorThrow(this, exn); 65 return %_GeneratorThrow(this, exn);
66 } 66 }
67 67
68 function GeneratorFunctionPrototypeConstructor(x) {
69 if (%_IsConstructCall()) {
70 throw MakeTypeError('not_constructor', ['GeneratorFunctionPrototype']);
71 }
72 }
73
74 function GeneratorFunctionConstructor(arg1) { // length == 1
75 return NewFunction(arguments, 'function*');
76 }
77
78
79 function SetUpGenerators() { 68 function SetUpGenerators() {
80 %CheckIsBootstrapping(); 69 %CheckIsBootstrapping();
81 var GeneratorObjectPrototype = GeneratorFunctionPrototype.prototype; 70 var GeneratorObjectPrototype = GeneratorFunctionPrototype.prototype;
82 InstallFunctions(GeneratorObjectPrototype, 71 InstallFunctions(GeneratorObjectPrototype,
83 DONT_ENUM | DONT_DELETE | READ_ONLY, 72 DONT_ENUM | DONT_DELETE | READ_ONLY,
84 ["next", GeneratorObjectNext, 73 ["next", GeneratorObjectNext,
85 "send", GeneratorObjectSend, 74 "send", GeneratorObjectSend,
86 "throw", GeneratorObjectThrow]); 75 "throw", GeneratorObjectThrow]);
87 %SetProperty(GeneratorObjectPrototype, "constructor", 76 %SetProperty(GeneratorObjectPrototype, "constructor",
88 GeneratorFunctionPrototype, DONT_ENUM | DONT_DELETE | READ_ONLY); 77 GeneratorFunctionPrototype, DONT_ENUM | DONT_DELETE | READ_ONLY);
89 %SetPrototype(GeneratorFunctionPrototype, $Function.prototype); 78 %SetPrototype(GeneratorFunctionPrototype, $Function.prototype);
90 %SetCode(GeneratorFunctionPrototype, GeneratorFunctionPrototypeConstructor);
91 %SetProperty(GeneratorFunctionPrototype, "constructor", 79 %SetProperty(GeneratorFunctionPrototype, "constructor",
92 GeneratorFunction, DONT_ENUM | DONT_DELETE | READ_ONLY); 80 GeneratorFunction, DONT_ENUM | DONT_DELETE | READ_ONLY);
93 %SetPrototype(GeneratorFunction, $Function); 81 %SetPrototype(GeneratorFunction, $Function);
94 %SetCode(GeneratorFunction, GeneratorFunctionConstructor);
95 } 82 }
96 83
97 SetUpGenerators(); 84 SetUpGenerators();
OLDNEW
« no previous file with comments | « no previous file | src/v8natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698