rubyjs / therubyracer

Embed the V8 Javascript Interpreter into Ruby
1.66k stars 192 forks source link

Generators (TRR 0.12.1, libv8 3.16.14.3) #306

Closed retorquere closed 9 months ago

retorquere commented 10 years ago

I have a bit of code that uses generators:

function* values() {
  for (var i = 0; i < arguments.length; i++) {
    yield arguments[i];
  }
}

var o = values(1, 2, 3);  // => [object Generator]
o.next();

Can therubyracer be configured to support generators?

cowboyd commented 10 years ago

This could be done, but would require an upgrade to v8, so cannot be done with TRR 0.12,1

My guess is that it would require a decent amount of hacking since generators are probably using a longjmp() at somepoint and so would require care to make sure that the ruby calling contexts were preserved.