feat: add entry_id to IDL AST and use it across parser and generators#1275
feat: add entry_id to IDL AST and use it across parser and generators#1275vobradovich merged 6 commits intomasterfrom
entry_id to IDL AST and use it across parser and generators#1275Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces an explicit entry_id field to IDL components like constructors, service functions, and enum variants across both JavaScript and Rust implementations. The changes include adding normalization logic to derive these IDs from @entry-id annotations or positional indices, updating code generators to utilize the new field, and implementing validation to ensure ID uniqueness and mandatory annotations for partial services. Feedback focuses on maintaining consistency between the JS and Rust normalization logic, reducing code duplication in annotation parsing, addressing a performance regression in the type validator's scope lookup, and extending @entry-id format validation to all service types.
Summary
This PR adds
entry_idas a first-class field in the IDL AST for:The parser and metadata builders now normalize these values into the AST, and JS/Rust generators consume the normalized
entry_iddirectly instead of recomputing it from annotations or position.What changed
entry_id: u16to AST nodes for ctors, funcs, and events.entry_idinProgramUnit::normalize().entry_idinServiceUnit::normalize().entry_idduring AST construction.@partialservices:@entry-idon all functions/events@entry-idvaluesentry_idfrom the AST directly.entry_idby falling back to index.ProgramUnitinidl-genso metadata-generated constructors get stable entry IDs too.Why
Previously, entry IDs were derived ad hoc from annotations or array position in multiple places. That made partial-service handling fragile and duplicated logic across parser, JS runtime, and generators.
This change centralizes entry-id resolution in the AST normalization layer so downstream code reads one canonical value.
Tests
Added/updated coverage for:
@entry-id@entry-idon partial services@entry-idvalues on partial servicesentry_id