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

Side by Side Diff: src/generator.js

Issue 1086313003: Migrate error messages, part 2. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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 unified diff | Download patch
« no previous file with comments | « src/factory.cc ('k') | src/harmony-array.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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 "use strict"; 5 "use strict";
6 6
7 // This file relies on the fact that the following declarations have been made 7 // This file relies on the fact that the following declarations have been made
8 // in runtime.js: 8 // in runtime.js:
9 // var $Function = global.Function; 9 // var $Function = global.Function;
10 10
11 // ---------------------------------------------------------------------------- 11 // ----------------------------------------------------------------------------
12 12
13 13
14 // Generator functions and objects are specified by ES6, sections 15.19.3 and 14 // Generator functions and objects are specified by ES6, sections 15.19.3 and
15 // 15.19.4. 15 // 15.19.4.
16 16
17 function GeneratorObjectNext(value) { 17 function GeneratorObjectNext(value) {
18 if (!IS_GENERATOR(this)) { 18 if (!IS_GENERATOR(this)) {
19 throw MakeTypeError('incompatible_method_receiver', 19 throw MakeTypeError(kIncompatibleMethodReceiver,
20 ['[Generator].prototype.next', this]); 20 '[Generator].prototype.next', this);
21 } 21 }
22 22
23 var continuation = %GeneratorGetContinuation(this); 23 var continuation = %GeneratorGetContinuation(this);
24 if (continuation > 0) { 24 if (continuation > 0) {
25 // Generator is suspended. 25 // Generator is suspended.
26 if (DEBUG_IS_ACTIVE) %DebugPrepareStepInIfStepping(this); 26 if (DEBUG_IS_ACTIVE) %DebugPrepareStepInIfStepping(this);
27 try { 27 try {
28 return %_GeneratorNext(this, value); 28 return %_GeneratorNext(this, value);
29 } catch (e) { 29 } catch (e) {
30 %GeneratorClose(this); 30 %GeneratorClose(this);
31 throw e; 31 throw e;
32 } 32 }
33 } else if (continuation == 0) { 33 } else if (continuation == 0) {
34 // Generator is already closed. 34 // Generator is already closed.
35 return { value: void 0, done: true }; 35 return { value: void 0, done: true };
36 } else { 36 } else {
37 // Generator is running. 37 // Generator is running.
38 throw MakeTypeError('generator_running', []); 38 throw MakeTypeError(kGeneratorRunning);
39 } 39 }
40 } 40 }
41 41
42 function GeneratorObjectThrow(exn) { 42 function GeneratorObjectThrow(exn) {
43 if (!IS_GENERATOR(this)) { 43 if (!IS_GENERATOR(this)) {
44 throw MakeTypeError('incompatible_method_receiver', 44 throw MakeTypeError(kIncompatibleMethodReceiver,
45 ['[Generator].prototype.throw', this]); 45 '[Generator].prototype.throw', this);
46 } 46 }
47 47
48 var continuation = %GeneratorGetContinuation(this); 48 var continuation = %GeneratorGetContinuation(this);
49 if (continuation > 0) { 49 if (continuation > 0) {
50 // Generator is suspended. 50 // Generator is suspended.
51 try { 51 try {
52 return %_GeneratorThrow(this, exn); 52 return %_GeneratorThrow(this, exn);
53 } catch (e) { 53 } catch (e) {
54 %GeneratorClose(this); 54 %GeneratorClose(this);
55 throw e; 55 throw e;
56 } 56 }
57 } else if (continuation == 0) { 57 } else if (continuation == 0) {
58 // Generator is already closed. 58 // Generator is already closed.
59 throw exn; 59 throw exn;
60 } else { 60 } else {
61 // Generator is running. 61 // Generator is running.
62 throw MakeTypeError('generator_running', []); 62 throw MakeTypeError(kGeneratorRunning);
63 } 63 }
64 } 64 }
65 65
66 function GeneratorObjectIterator() { 66 function GeneratorObjectIterator() {
67 return this; 67 return this;
68 } 68 }
69 69
70 function GeneratorFunctionConstructor(arg1) { // length == 1 70 function GeneratorFunctionConstructor(arg1) { // length == 1
71 var source = NewFunctionString(arguments, 'function*'); 71 var source = NewFunctionString(arguments, 'function*');
72 var global_proxy = %GlobalProxy(global); 72 var global_proxy = %GlobalProxy(global);
(...skipping 30 matching lines...) Expand all
103 %InternalSetPrototype(GeneratorFunctionPrototype, $Function.prototype); 103 %InternalSetPrototype(GeneratorFunctionPrototype, $Function.prototype);
104 %AddNamedProperty(GeneratorFunctionPrototype, 104 %AddNamedProperty(GeneratorFunctionPrototype,
105 symbolToStringTag, "GeneratorFunction", DONT_ENUM | READ_ONLY); 105 symbolToStringTag, "GeneratorFunction", DONT_ENUM | READ_ONLY);
106 %AddNamedProperty(GeneratorFunctionPrototype, "constructor", 106 %AddNamedProperty(GeneratorFunctionPrototype, "constructor",
107 GeneratorFunction, DONT_ENUM | READ_ONLY); 107 GeneratorFunction, DONT_ENUM | READ_ONLY);
108 %InternalSetPrototype(GeneratorFunction, $Function); 108 %InternalSetPrototype(GeneratorFunction, $Function);
109 %SetCode(GeneratorFunction, GeneratorFunctionConstructor); 109 %SetCode(GeneratorFunction, GeneratorFunctionConstructor);
110 } 110 }
111 111
112 SetUpGenerators(); 112 SetUpGenerators();
OLDNEW
« no previous file with comments | « src/factory.cc ('k') | src/harmony-array.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698