| Index: src/runtime/runtime.js |
| diff --git a/src/runtime/runtime.js b/src/runtime/runtime.js |
| index 8adf74a0944f5ce2c5c5ffa1360afee357e75a85..f953e3ddf6e5149234081dad02fabf0a6881972d 100644 |
| --- a/src/runtime/runtime.js |
| +++ b/src/runtime/runtime.js |
| @@ -338,43 +338,34 @@ traceur.runtime = (function(global) { |
| if (index < array.length) { |
| return array[index++]; |
| } |
| - throw StopIterationLocal; |
| + throw new StopIterationLocal(); |
| } |
| }; |
| })); |
| } |
| - // Generators |
| - var StopIterationLocal; |
| - var isStopIteration = function(x) { |
| - return x === StopIterationLocal; |
| + // StopIteration |
| + var StopIterationLocal = function(v) { |
| + this.value = v; |
| }; |
| - switch (typeof StopIteration) { |
| - case 'function': |
| - StopIterationLocal = new StopIteration(); |
| - isStopIteration = function(x) { |
| - return x instanceof StopIteration; |
| - }; |
| - break; |
| - case 'object': |
| - StopIterationLocal = StopIteration; |
| - try { |
| - // Firefox's StopIteration is both a valid lhs and rhs for instanceof. |
| - StopIteration instanceof StopIteration; |
| - |
| - isStopIteration = function(x) { |
| - return x instanceof StopIteration; |
| - }; |
| - } catch(e) {} |
| - break; |
| - case 'undefined': |
| - StopIterationLocal = { |
| - toString: function() { |
| - return '[object StopIteration]'; |
| - } |
| - }; |
| - global.StopIteration = StopIterationLocal; |
| + StopIterationLocal.prototype = { |
| + toString: function() { |
| + return '[object StopIteration]'; |
| + } |
| + }; |
| + |
| + global.StopIteration = new StopIterationLocal(); |
| + |
| + function isStopIteration(x) { |
| + return x instanceof StopIterationLocal; |
| + } |
| + |
| + function setStopIteration(StopIteration) { |
| + if (typeof StopIteration !== 'function') |
| + throw new TypeError('constructor function required'); |
| + StopIterationLocal = StopIteration; |
| + global.StopIteration = new StopIteration(); |
| } |
| /** |
| @@ -487,6 +478,7 @@ traceur.runtime = (function(global) { |
| Deferred: Deferred, |
| StopIteration: StopIterationLocal, |
| isStopIteration: isStopIteration, |
| + setStopIteration: setStopIteration, |
| addIterator: addIterator, |
| assertName: assertName, |
| createName: NameModule.Name, |