You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was checking to see if I can redistribute the AST accross multiple threads, such as for caching the AST for multiple Jint that are running the same script. So it's natural to check if the AST is immutable, and hence safe for this, like e.g. the Roslyn syntax tree is.
According to the source code I have looked at so far, the AST is indeed immutable, but it would be nice if the documentation mentioned it somewhere :). So other people later don't have to spend time investigating the source code to figure that out.
The text was updated successfully, but these errors were encountered:
From Jint's perspective using Engine.PrepareScript should guarantee safe instance for multi-threading. But it's always possible to mutate the custom state field if any code decides to do so afterwards. But the AST structure should be static.
I'd say the AST is immutable-ish. The tree structure and node-specific data are immutable indeed but there are a few general or optional properties (like SyntaxElement.Range, SyntaxElement.Location, SyntaxElement.AssociatedData, Program.Tokens, Program.Comments, etc.) which are not for performance and/or backward compatibility reasons.
There are some warnings about this in the XML comments of these properties but the documentation could be improved for sure.
I was checking to see if I can redistribute the AST accross multiple threads, such as for caching the AST for multiple Jint that are running the same script. So it's natural to check if the AST is immutable, and hence safe for this, like e.g. the Roslyn syntax tree is.
According to the source code I have looked at so far, the AST is indeed immutable, but it would be nice if the documentation mentioned it somewhere :). So other people later don't have to spend time investigating the source code to figure that out.
The text was updated successfully, but these errors were encountered: