* 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]>
* allow ignoring struct member using a - in expr struct tag
* fix in operator
* simplify logic
* add regression test for #807
* fixes#807: make in operator return false for unexported struct fields
---------
Co-authored-by: Anton Medvedev <[email protected]>
* Reset tracking of applied operator overloads before every walk of the ast tree.
* Remove limit on operator overload resolution
* Do separate patcher phase for those that require multiple passes (Currently only need for Operator overloading). This patcher phase is run after other patchers.
* Add test to track how many times a patcher is run. Used to detect if patching phases is erroneously applying the patcher multiple times.
---------
Co-authored-by: Anton Medvedev <[email protected]>
This PR introduces a new concept inside Expr's type checker - Nature.
It's an abstraction other reflect.Type which carries additional information about possible type, methods and builtin function.
I was able to find and fix a few bugs in type checker and optimizer. Implementation of nature concept has proven itself. As well nature will allow to bring more feature for type checker in future.
Why Nature? I was looking for a name to replace Type. Type name already carries much information, as well can be confused with reflect.Type. Nature name should be understood as "nature of the node", same as "type of the node".
* 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
* add failing test case: embedded pointer to struct
* fix(dereference embedded pointers to structs)
* add evaluation test for field access and method call on embedded pointer struct