kaleidawave / ezno

A JavaScript compiler and TypeScript checker written in Rust with a focus on static analysis and runtime performance
https://kaleidawave.github.io/posts/introducing-ezno/
MIT License
2.3k stars 42 forks source link

Change way types are stored and represented + allow for more than u16::MAX types #120

Open kaleidawave opened 4 months ago

kaleidawave commented 4 months ago

Currently all types are currently held under a single Vec<Type>, and TypeId is pointer into this vector. TypeId is a wrapped for a u16. To support larger files/codebases this needs to increase

kaleidawave commented 2 months ago

Quick thoughts:

Considering struct TypeId { block: u16, offset: u16 }. Where BlockId points to a collection of Vec<Type> that can span multiple files / packages. But each block only contains types per module so that invalidations have a limited effect or something.

kaleidawave commented 1 week ago

I think the first thing is to split types apart.

TypeId should be InterfaceTypeId | ConstantId | FunctionId | ... with each of them having their own Vec

Could try splitting types that an expression can represent from conventional types again at some point. Although makes subtyping less simple