* export the checker and ensure no methods or fields are exported
* make Checker reusable
* add PatchAndCheck method to Checker, and reuse it in visitors
* avoid unnecessary map and consolidate structs
* make all Nature methods use pointer-receiver
* added cache for type and nature information
* optimize type and nature checks
* more aggressively cache some partial results and add cheap checks
* cache reused values
* reduce copying in Nature by breaking down optional fields
* enforce use of cache
* improve ergonomics of FromType and NatureOf
* improve struct method fetching
* make cache private to Nature
* first iteration improving struct reflect caching
* cleaned up struct fields data
* improve caching of functions data
* simplify checker code
* simplify and remove dead code
* add checker benchmarks
* address PR comments and minor improvements
* rename from SetCache to Bind
* make the benchmarks more fair
* fix benchmark option not being applied
* move Cache to be argument instead of field
* merge FuncData into Optional
* rename Optional to TypeData
* simplify struct logic
* cache builtin numeric types
---------
Co-authored-by: Anton Medvedev <[email protected]>
Simplifies the code by using the type switch variable binding instead of
performing an additional type assertion.
Signed-off-by: Ville Vesilehto <[email protected]>
Co-authored-by: Anton Medvedev <[email protected]>
* feat: add node budget and memory limits
Implement compile-time and runtime safeguards against deeply nested expressions:
- Add MaxNodes limit to track and limit AST node count during parsing
- Move MemoryBudget from VM to Config for better configurability
- Add node creation tracking in parser to enforce node budget
- Refactor node creation to check limits before allocation
- Add RunWithConfig to VM for passing memory budget settings
- Set reasonable defaults in Config (10000 nodes, 1M memory)
- Add comprehensive tests for both node and memory limits
This prevents stack overflows from malicious or poorly written expressions
by failing fast with clear error messages during compilation or runtime.
Signed-off-by: Ville Vesilehto <[email protected]>
* Update parser.go
Signed-off-by: Anton Medvedev <[email protected]>
---------
Signed-off-by: Ville Vesilehto <[email protected]>
Signed-off-by: Anton Medvedev <[email protected]>
Co-authored-by: Anton Medvedev <[email protected]>
* Add concat() builtin
* Use pkg deref in builtin
* Use pkg deref in checker
* Use pkg deref in types_table.go
* Use pkg deref in docgen.go
* Use pkg deref in vm