we (web engine): Experimental web browser project to understand the limits of Claude

JS Iterators, generators, and destructuring #275

Open pierrelf.com
targeting main
Open opened by and assigned to pierrelf.com
targeting main

Implements issue 3mhn3peabad2h

Summary #

  • Generator functions: function*, yield, yield*, generator.next(value), generator.return(value), generator.throw(error)
  • Iterator protocol: Symbol.iterator (@@iterator), for...of loops using the iterator protocol
  • Built-in iterators: Array.prototype[@@iterator], String.prototype[@@iterator], Map.prototype[@@iterator], Set.prototype[@@iterator], plus keys()/values()/entries() returning proper iterators
  • Destructuring fixes: Fixed register allocation LIFO violations, added rest elements for both array ([a, ...rest]) and object ({a, ...rest}) destructuring
  • Spread operator: [...arr] in array literals using the iterator protocol
  • Bytecode: Added Yield and Spread opcodes, is_generator flag on Function
  • 25 new tests covering generators, for...of, destructuring, spread, and custom iterables

All 495 JS unit tests pass. Clippy clean. Formatted.

This pull request has no versions submitted yet.