Skip to content

v0.6.0-alpha.2

Pre-release
Pre-release
Compare
Choose a tag to compare
@FreeMasen FreeMasen released this 03 Jun 15:31
· 21 commits to main since this release

Changes

  • Smaller AST
    • The main goal of this release was to reduce the overall size of the spanned AST nodes. To achieve this a few optimizations were made
      • All constant size tokens were converted from being represented as a Slice to now only being represented as a Position marking the start of that token. The end can easily be calculated since the token is a constant size.
      • The requirement to use Cow<str> has been removed and now the AST nodes are generic over any T.
      • The source property of a Slice is now represented by a SourceText new type wrapper around T, helpers have been provided for this type with T of &str, String and Cow<str>.
    • To make these changes slightly easier to manage, all the conversion from spanned to non-spanned nodes was moved to its own module resast::spanned::convert
    • Nodes with duplicated data were re-structured to reduce that duplication
      • NormalImportSpec and ExportSpecifier, now has an Option for the local value which was renamed alias
      • TemplateElement is no longer represented as both cooked and raw but instead matches the StringLit pattern, that is the properties open_quote, close_quote, content
      • RegEx::flags is now an Option
    • Position was updated to hold u32 values instead of usize meaning any 64 bit architectures should see this type reduced to half its previous size.
    • A new spanned::Boolean is provided instead of spanned::Lit::Boolean holding a Slice
    • A new module was added containing new-type wrappers around Position for all fixed-sized nodes called spanned::tokens
      • These new types implement a new trait Token that provides an interface to get the &'static str for the token along with the start and end Position values. Any type that implements Token should also implement Node