Add import/export parsing, module registry, bytecode opcodes, host integration, and <script type="module"> HTML pipeline support. Includes three rounds of code review with 21 remaining action items tracked in the story file for follow-up. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
23 KiB
23 KiB
JavaScript Implementation Checklist
Checked items mean the feature is implemented and working end-to-end (parse → execute → correct result). Partial support is left unchecked and called out inline.
Phase 0: Infrastructure & Conformance
- Hand-written recursive-descent parser producing AST
- Tree-walking interpreter over AST
- Statement limit for infinite-loop prevention (configurable, default 100,000)
- Call-depth limit (configurable, default 64)
- JS262 conformance harness (vendored Test262 tests, TOML manifest, pass/known_fail/skip)
- Full Test262 integration (Tier 2: upstream clone, auto-generated manifest, triage tooling)
- Bytecode compiler + VM (top-level bytecode compilation; function calls delegate to AST interpreter)
- Source maps support
- Cycle-detecting garbage collection (currently Rc<RefCell<>>; no cycle collection)
Phase 1: Lexical Grammar & Tokenization
- Identifiers and reserved words
- Numeric literals (integers, floats, hex
0x, octal0o, binary0b, exponential) - String literals (single/double quotes, escape sequences)
- Template literal tokenization (backticks,
${expr}interpolation) - Regular expression literal tokenization with flags
- Single-line (
//) and multi-line (/* */) comments - Automatic semicolon insertion (ASI)
- Current state: core ASI works; 5 known-fail edge cases remain (labeled statements, do-while ASI).
- Hashbang (
#!) comment support - BigInt literals (
123n)
Phase 2: Declarations & Scoping
vardeclarations with function-scoped hoistingletdeclarations with block scopingconstdeclarations with block scoping- Temporal Dead Zone (TDZ) for
let/const - Function declarations with hoisting
- Function expressions (named and anonymous)
- Arrow function expressions (
=>with expression and block bodies) - Class declarations (constructor, methods,
extends,super(),super.method(), static methods) - Class expressions
- Block-scoped function declarations (Annex B semantics)
import/exportdeclarations (ES modules)import()dynamic import expressions
Phase 3: Statements & Control Flow
- Block statements with scope
if/elsefor(C-style)for...in(property enumeration)for...of(iterable iteration)- Current state: works with arrays and strings only; does not invoke the general iterator protocol.
whileanddo...whileswitch/casewith fall-throughbreakandcontinuetry/catch/finallythrowstatement- Empty statements (
;) - Labeled statements (
label: stmt,break label,continue label) withstatement (deprecated but spec-required in non-strict mode)for await...ofdebuggerstatement (can be a no-op, but should parse)
Phase 4: Expressions & Operators
4.1 Arithmetic & Assignment
- Arithmetic:
+,-,*,/,%,** - Unary:
+,-,!,~,typeof,void,delete - Increment / decrement:
++,--(prefix and postfix) - Assignment:
= - Compound assignment:
+=,-=,*=,/=,%=,**= - Bitwise compound assignment:
&=,|=,^=,<<=,>>=,>>>= - Logical assignment:
&&=,||=,??=
4.2 Comparison & Logical
- Equality:
==,===,!=,!== - Relational:
<,>,<=,>= - Logical:
&&,||,! - Nullish coalescing:
?? - Conditional (ternary):
? :
4.3 Bitwise
- Bitwise:
&,|,^,~ - Shift:
<<,>>,>>>
4.4 Member Access & Calls
- Dot member access:
obj.prop - Bracket member access:
obj[expr] - Function calls:
fn(args) - Method calls:
obj.method(args) newexpressions- Current state: works with identifier targets;
new foo.Bar()with member expressions is not supported.
- Current state: works with identifier targets;
instanceofoperatorinoperator- Optional chaining:
?. - Tagged template expressions:
tag`str`
4.5 Spread & Destructuring (Expressions)
- Spread in array literals:
[...arr] - Spread in function calls:
fn(...args) - Spread in object literals:
{...obj} - Comma operator
Phase 5: Functions
- Function declarations and expressions
- Arrow functions with lexical
this - Default parameters
- Rest parameters (
...args) thisbinding (global, method, constructor contexts)Function.prototype.call(thisArg, ...args)- Closures with variable capture
- Current state: variables captured by value at definition time; mutable closure state requires specific patterns.
- Recursion support
Function.prototype.apply(thisArg, argsArray)Function.prototype.bind(thisArg, ...args)argumentsobject- Generator functions (
function*/yield/yield*) - Async functions (
async function/await) - Async generator functions (
async function*) - Getter / setter methods (
get prop()/set prop()) new.targetmeta-property
Phase 6: Classes
- Class declarations and expressions
- Constructor method
- Instance methods
- Static methods
extendswith simple identifier targetssuper()in constructorssuper.method()calls- Prototype chain setup
- Class fields (public instance properties)
- Private fields (
#field) - Private methods (
#method()) - Static fields and static initialization blocks
- Computed method names (
[expr]() {}) - Getter / setter methods in classes
extendswith member expressions (class Foo extends ns.Bar)
Phase 7: Destructuring & Patterns
- Array destructuring:
const [a, b] = arr - Object destructuring:
const {x, y} = obj - Nested destructuring
- Default values:
const {x = 5} = obj - Renaming:
const {x: newX} = obj - Rest in arrays:
const [first, ...rest] = arr - Rest in objects:
const {a, ...rest} = obj - Array holes:
const [a, , c] = arr - Destructuring in function parameters
- Assignment destructuring:
[a, b] = [1, 2] - Destructuring in
for...of/for...inbindings - Computed property destructuring:
const {[expr]: val} = obj
Phase 8: Template Literals
- Basic template literals:
`text` - Expression interpolation:
`${expr}` - Nested expressions
- Multiline strings
- Escape sequences
- Tagged templates:
tag`str` String.rawtag function
Phase 9: Strict Mode
- Directive prologue detection (
"use strict") - Function-scoped and inherited strict mode
- Escape sequence guard (prevents
"use\040strict"interpretation) - Reserved word enforcement
- Duplicate parameter rejection
- Non-simple parameter rejection (with defaults/rest)
deleteidentifier prohibitionthisundefined in non-constructor strict calls.call()does not coerce non-objectthis- Octal escape sequence rejection
Phase 10: Error Types & Handling
Errorbase type withmessageandnamepropertiesTypeErrorReferenceErrorSyntaxErrorRangeErrorEvalErrorURIError- Proper prototype chain for all error types
toString()method on errors- Constructor callable without
new instanceofchecks on error typesError.prototype.stack(stack traces)AggregateError(ES2021)
Phase 11: Object Built-in
Object()constructorObject.create(proto)Object.keys(obj)Object.values(obj)Object.entries(obj)Object.assign(target, ...sources)Object.getPrototypeOf(obj)Object.getOwnPropertySymbols(obj)Object.prototype.toString()(withSymbol.toStringTagsupport)Object.prototype.valueOf()Object.prototype.hasOwnProperty(prop)Object.prototype.propertyIsEnumerable(prop)Object.setPrototypeOf(obj, proto)Object.getOwnPropertyNames(obj)Object.getOwnPropertyDescriptor(obj, prop)Object.getOwnPropertyDescriptors(obj)Object.defineProperty(obj, prop, descriptor)Object.defineProperties(obj, descriptors)Object.freeze(obj)/Object.isFrozen(obj)Object.seal(obj)/Object.isSealed(obj)Object.preventExtensions(obj)/Object.isExtensible(obj)Object.is(a, b)Object.fromEntries(iterable)Object.hasOwn(obj, prop)(ES2022)Object.prototype.isPrototypeOf(obj)Object.prototype.toLocaleString()
Phase 12: Array Built-in
Array()constructor /new Array(len)Array.isArray(value).push(...items)/.pop().shift()/.unshift(...items).slice(start, end).concat(...items).join(separator).reverse().sort(compareFn).indexOf(item, from)/.lastIndexOf(item, from).includes(item, from).forEach(cb, thisArg).map(cb, thisArg).filter(cb, thisArg).find(cb, thisArg)/.findIndex(cb, thisArg).some(cb, thisArg)/.every(cb, thisArg).reduce(cb, init)/.reduceRight(cb, init).toString().lengthproperty (auto-maintained).splice(start, deleteCount, ...items).fill(value, start, end).copyWithin(target, start, end).flat(depth)/.flatMap(cb, thisArg).at(index).findLast(cb)/.findLastIndex(cb)(ES2023).entries()/.keys()/.values().toLocaleString()Array.from(iterable, mapFn)/Array.of(...items).toReversed()/.toSorted()/.toSpliced()/.with()(ES2023 immutable methods)
Phase 13: String Built-in
String()constructor (wrapper object vianew).charAt(index)/.charCodeAt(index).slice(start, end)/.substring(start, end).indexOf(str, from)/.lastIndexOf(str, from).includes(str, pos)/.startsWith(str, pos)/.endsWith(str, len).toUpperCase()/.toLowerCase().trim()/.trimStart()/.trimEnd().split(separator, limit)(including regex with capture groups).replace(pattern, replacement)(string and regex patterns).match(regexp)/.search(regexp).repeat(count).concat(...strings).toString()/.valueOf().lengthproperty.substr(start, length)(legacy but widely used).padStart(len, pad)/.padEnd(len, pad).at(index).codePointAt(index).normalize(form).matchAll(regexp).replaceAll(pattern, replacement)String.fromCharCode(...codes)/String.fromCodePoint(...codes).toLocaleLowerCase()/.toLocaleUpperCase()/.localeCompare()
Phase 14: Number Built-in
Number()constructor (wrapper object vianew)Number.prototype.toString()Number.prototype.valueOf()Number.prototype.toFixed(digits)Number.prototype.toExponential(digits)Number.prototype.toPrecision(digits)Number.prototype.toLocaleString()Number.isNaN(value)Number.isFinite(value)Number.isInteger(value)Number.isSafeInteger(value)Number.parseFloat(string)/Number.parseInt(string, radix)Number.MAX_VALUE/Number.MIN_VALUENumber.MAX_SAFE_INTEGER/Number.MIN_SAFE_INTEGERNumber.EPSILONNumber.POSITIVE_INFINITY/Number.NEGATIVE_INFINITY/Number.NaN
Phase 15: Boolean Built-in
Boolean()constructor (wrapper object vianew)Boolean.prototype.toString()Boolean.prototype.valueOf()
Phase 16: RegExp Built-in
- Regex literals:
/pattern/flags new RegExp(pattern, flags)constructor.test(string).exec(string)with capture groups,index, andinputproperties.toString().source/.flags/.lastIndexproperties- Flags:
g,i,m,s,u,y - String integration:
.match(),.replace(),.search(),.split() - Function replacers in
.replace(regexp, fn) .matchAll()(returns iterator)- Named capture groups (
(?<name>...)and$<name>) - Lookbehind assertions (
(?<=...)/(?<!...))- Lookahead is supported via the
regresscrate.
- Lookahead is supported via the
RegExp.prototype[Symbol.match]/[Symbol.replace]/[Symbol.search]/[Symbol.split]dflag (hasIndices)
Phase 17: Symbol Built-in
Symbol(description)creation.descriptionproperty.toString()→"Symbol(description)"Symbol.for(key)/Symbol.keyFor(symbol)(global registry)- Symbol-keyed object properties
Object.getOwnPropertySymbols(obj)- Well-known symbols:
Symbol.iteratorSymbol.toPrimitiveSymbol.hasInstanceSymbol.toStringTagSymbol.speciesSymbol.isConcatSpreadable
Symbol.asyncIteratorSymbol.match/Symbol.replace/Symbol.search/Symbol.splitSymbol.toPrimitivefull hint protocol in all coercion contexts
Phase 18: Promise
new Promise(executor)Promise.resolve(value)/Promise.reject(reason).then(onFulfilled, onRejected).catch(onRejected)- Microtask queue integration
- Handler chaining
- Error propagation
.finally(onFinally)Promise.all(iterable)Promise.race(iterable)Promise.allSettled(iterable)Promise.any(iterable)(ES2021)Promise.withResolvers()(ES2024)
Phase 19: JSON
JSON.stringify(value, replacer, space)- Replacer function and array support
- Space / indentation parameter
toJSON()method support- Circular reference detection
- Boxed primitive handling
JSON.parse(text, reviver)- Full JSON spec compliance
- Surrogate pair handling
- Depth limit enforcement (512)
- Reviver function support
Phase 20: WeakMap / WeakSet / Map / Set
WeakMap:new WeakMap(),.get(),.set(),.has(),.delete()- Object-key-only enforcement implemented.
WeakSetWeakRef/FinalizationRegistry(ES2021)Map:new Map(),.get(),.set(),.has(),.delete(),.size,.forEach(),.entries(),.keys(),.values(),.clear()Set:new Set(),.add(),.has(),.delete(),.size,.forEach(),.entries(),.keys(),.values(),.clear()
Phase 21: Proxy & Reflect
Proxy
new Proxy(target, handler)Proxy.revocable(target, handler)- Trap:
get - Trap:
set - Trap:
has - Trap:
deleteProperty - Trap:
apply(function targets) - Trap:
construct - Trap:
ownKeys - Trap:
getOwnPropertyDescriptor - Trap:
defineProperty - Trap:
getPrototypeOf/setPrototypeOf - Trap:
preventExtensions/isExtensible
Reflect
Reflect.get()/Reflect.set()/Reflect.has()Reflect.deleteProperty()/Reflect.apply()/Reflect.construct()Reflect.ownKeys()/Reflect.getOwnPropertyDescriptor()Reflect.defineProperty()/Reflect.getPrototypeOf()/Reflect.setPrototypeOf()Reflect.preventExtensions()/Reflect.isExtensible()
Phase 22: Missing Global Objects
Math
- Constants:
Math.PI,Math.E,Math.LN2,Math.LN10,Math.LOG2E,Math.LOG10E,Math.SQRT2,Math.SQRT1_2 Math.abs(),Math.ceil(),Math.floor(),Math.round(),Math.trunc()Math.max(),Math.min()Math.pow(),Math.sqrt(),Math.cbrt(),Math.hypot()Math.log(),Math.log2(),Math.log10(),Math.exp(),Math.expm1(),Math.log1p()Math.sin(),Math.cos(),Math.tan(),Math.asin(),Math.acos(),Math.atan(),Math.atan2()Math.random(),Math.sign(),Math.clz32(),Math.fround(),Math.imul()
Date
new Date()/Date.now()/Date.parse()/Date.UTC()- Getter methods:
.getFullYear(),.getMonth(),.getDate(),.getDay(),.getHours(),.getMinutes(),.getSeconds(),.getMilliseconds(),.getTime(),.getTimezoneOffset() - Setter methods:
.setFullYear(),.setMonth(),.setDate(),.setHours(),.setMinutes(),.setSeconds(),.setMilliseconds(),.setTime() - UTC variants of getters and setters
.toISOString(),.toJSON(),.toDateString(),.toTimeString(),.toLocaleDateString(),.toLocaleTimeString(),.toLocaleString(),.toString(),.valueOf()
Global Functions
parseInt(string, radix)parseFloat(string)isNaN(value)/isFinite(value)encodeURI()/decodeURI()encodeURIComponent()/decodeURIComponent()eval()direct and indirect- Current state:
eval()is implemented with direct/indirect semantics and strict mode isolation.
- Current state:
Phase 23: Iterators & Generators
Iterator Protocol
Symbol.iteratorinvocation infor...of, spread, destructuring- Generalized:
for...ofand spread now invokeSymbol.iteratoron any object.
- Generalized:
IteratorResultprotocol ({ value, done })- Iterator helpers:
.next(),.return(),.throw() - Built-in iterables: Array, String, Map, Set, TypedArray, arguments
- Arrays and strings work via hardcoded fallbacks + Symbol.iterator protocol.
Symbol.asyncIteratorfor async iteration
Generators
function*declarations and expressionsyieldexpressionyield*delegation- Generator objects with
.next(),.return(),.throw() - Async generators (
async function*)
Phase 24: Async / Await
async functiondeclarations and expressionsasyncarrow functionsawaitexpressionasyncmethods in classes and objectsfor await...ofloops- Top-level
await(module context)
Phase 25: Modules (ES Modules)
importdeclarations (named, default, namespace)exportdeclarations (named, default, re-export)import()dynamic import- Module resolution algorithm
- Module evaluation and linking
import.meta- Top-level
await - Circular dependency handling
Phase 26: TypedArrays & ArrayBuffer
ArrayBuffer/SharedArrayBufferDataView- TypedArray constructors:
Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array - TypedArray methods (
.set(),.subarray(),.slice(),.from(),.of(), etc.) Atomics(for shared memory)
Phase 27: Web APIs (Browser Integration)
DOM Access
document.getElementById(id)document.createElement(tagName)element.appendChild(child)/element.removeChild(child)element.textContent(get/set)- Element properties:
id,tagName,className - Element attribute access (read/write)
document.querySelector()/document.querySelectorAll()document.getElementsByTagName()/document.getElementsByClassName()element.insertBefore()/element.replaceChild()element.innerHTML(get/set)- Current state: wired to fragment parse/serialize but not fully spec-compliant.
element.outerHTMLelement.classList(DOMTokenList)element.style(CSSStyleDeclaration)element.getBoundingClientRect()element.parentElement/element.children/element.nextSiblingetc.document.createTextNode()/document.createDocumentFragment()Node.cloneNode(deep)
Events
addEventListener(type, listener, useCapture)removeEventListener(type, listener)- Event object:
type,target,currentTarget,bubbles,cancelable event.preventDefault()/event.stopPropagation()- Event bubbling
- Current state: target + bubble phases implemented for click.
- Event capture phase
dispatchEvent(event)(custom events)- Keyboard events:
keydown,keyup,keypress - Mouse events:
mousedown,mouseup,mousemove,mouseenter,mouseleave - Focus events:
focus,blur,focusin,focusout - Input events:
input,change
Timers & Scheduling
setTimeout(callback, delay)/clearTimeout(id)queueMicrotask(callback)- Microtask queue draining after script execution
setInterval(callback, delay)/clearInterval(id)requestAnimationFrame(callback)/cancelAnimationFrame(id)
Window & Navigation
windowglobal objectwindow.location/LocationAPIwindow.history/HistoryAPI (pushState,replaceState,popstate)window.navigatorwindow.innerWidth/window.innerHeightwindow.getComputedStyle(element)window.scrollTo()/window.scrollBy()
Network
fetch()API withRequest/Response/HeadersXMLHttpRequestWebSocket
Storage
localStorage/sessionStorageIndexedDBdocument.cookie
Console
console.log(...args)console.warn()/console.error()/console.info()/console.debug()console.table()/console.dir()console.time()/console.timeEnd()console.assert()console.group()/console.groupEnd()
Phase 28: Additional ES2015+ Features
BigInttype and operations- Optional chaining (
?.) globalThisstructuredClone()queueMicrotask()(already in Web APIs — ensure global availability)- Logical assignment operators (
&&=,||=,??=)- Current state: parsing and execution implemented.
- Private class fields and methods (
#) - Class static initialization blocks
at()method on Array, String, TypedArrayObject.hasOwn()Array.prototype.toSorted()/.toReversed()/.toSpliced()/.with()Error.prototype.causeRegExpmatch indices (dflag)
Phase 29: Property Descriptors & Meta-Object Protocol
- Property descriptors (
writable,enumerable,configurable) Object.defineProperty()/Object.getOwnPropertyDescriptor()- Accessor properties (getters/setters via descriptors)
Object.freeze()/Object.seal()/Object.preventExtensions()- Non-configurable / non-writable property enforcement
[[Prototype]]chain with proper property lookup semantics- Current state: prototype chain lookup works for basic get; descriptor-level semantics are missing.
Phase 30: Eval
- Direct
eval()with scope access - Indirect
eval()with global scope - Strict mode isolation in eval
- Parse error handling as
SyntaxError new Function(args, body)constructor
Phase 31: Conformance Exit Criteria
- Pass Test262 conformance targets (define threshold per feature area)
- No crashers: malformed JS must not crash the engine
- All known failures have linked issues and documented spec rationale
Math,Date,Map,Setbuilt-ins implemented (required by most real-world JS)- Iterator protocol fully integrated with
for...of, spread, and destructuring - Property descriptor model implemented (required by many libraries)
- Publish JavaScript conformance report with pass rates and remaining gaps