dop251 / goja

ECMAScript/JavaScript engine in pure Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Implement generators

mstoykov opened this issue · comments

Generators were introduced in ES6.

AFAIK there are currently one of the two ES6 features that goja doesn't have support - the other one being modules.

It is also needed in order to implement async/await (will open issue and link it here later) which is ther other blocking thing on the modules PR #430 from this comment

I would want to work on this (already have a very WIP PR - still not to the "interesting" parts).
But it will be nice to know that there is nothing blocking it and what the scope will be.

I would implement all the syntax that is not async related:
-function * as both methods and functions

  • yield both with and without returning or taking arguments
  • yield* which delegates the execution to a different generator
  • .next(), return() and throw() on the generator
  • Makign a generator iterable so it is used with for cycles
  • pass all test262 tests that aren't blocked on something else.
  • Expose some interface for go code to make Generators
    Anything in particular that I am missing from this list?

I also will be basing it on the 13th edition of the specification.

Does this seem okay @dop251 and are you okay with me having a try at actually implemetning this in teh following month or two(I will not be able to start right away full time on this :( )

I am going to look at it myself and probably will have it done within the next couple of months... The most complicated part is changing the way exceptions are implemented. Currently they are Go function calls which seemed like a good idea at the time, unfortunately it makes it tricky to restore the execution context (in case yield is done from a try/catch/finally block).