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

JS Built-in: Object, Function, Array, Error #267

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

Implements issue 3mhn3mu7azr25

Changes #

Adds comprehensive built-in object support for the JavaScript engine: Object, Array, Error constructors with static/prototype methods, plus global utility functions.

Infrastructure (vm.rs) #

  • NativeContext struct passed to native callbacks providing GC access and this binding
  • object_prototype and array_prototype fields stored in VM
  • CreateObject/CreateArray opcodes now set prototype chains
  • GC roots updated for built-in prototypes

Compiler (compiler.rs) #

  • Array literal compilation now sets length property after adding elements

Built-ins (builtins.rs — new file) #

  • Object: constructor, keys/values/entries/assign/create/is/getPrototypeOf/getOwnPropertyNames/getOwnPropertyDescriptor/defineProperty/freeze/seal/isFrozen/isSealed/fromEntries/hasOwn
  • Object.prototype: hasOwnProperty/toString/valueOf
  • Array (native): push/pop/shift/unshift/indexOf/lastIndexOf/includes/join/slice/concat/reverse/splice/fill/at/toString
  • Array (static): isArray/from/of
  • Array (JS preamble): map/filter/reduce/reduceRight/forEach/find/findIndex/some/every/sort/flat/flatMap
  • Error/TypeError/ReferenceError/SyntaxError/RangeError/URIError/EvalError constructors with prototype chain
  • Global: parseInt/parseFloat/isNaN/isFinite

Tests #

  • 37 new tests covering all built-in categories
  • All 291 JS tests pass (254 existing + 37 new)

This pull request has no versions submitted yet.