79 Commits
Author SHA1 Message Date
Diego Augusto MolinaandGitHub 6b6df6494c make ast.Node return *nature.Nature (#849) 2025-09-29 11:10:45 +02:00
a60d994e25 Improve Performance of the Type System (#824)
* 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]>
2025-09-18 14:38:27 +02:00
Anton Medvedev ebd5b4e426 Add print test for if 2025-03-08 12:31:51 +01:00
Anton Medvedev c146c2fc9b Add SequenceNode
Fixes #717
2025-03-08 09:27:09 +01:00
Anton Medvedev 1e518fddcb Add ast.Find 2025-03-07 20:40:02 +01:00
f1b80c01df Fix print with precedence (#678)
* feat: extract code for compiling equal operator

* fix: fix unary and binary node print

consider the precedence of operators and their associative law when printing unary and binary nodes

---------

Co-authored-by: Anton Medvedev <[email protected]>
2025-03-07 16:34:41 +01:00
zhuliquanandGitHub b74ed56efa Fix unary node print for conditional expr (#676)
* feat: extract code for compiling equal operator

* fix: fix unary node inside condition node print
2024-06-23 21:20:41 +02:00
Anton MedvedevandGitHub c953d0dde1 Refactor types table (#667) 2024-06-04 00:08:01 +02:00
Anton Medvedev de9d6dcf8a Remove Node.Kind() method 2024-06-01 14:57:15 +02:00
Anton MedvedevandGitHub fee5690347 Refactor checker to use Nature (#665)
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".
2024-06-01 00:09:22 +02:00
Anton Medvedev c8b0171f3a Return tree on parse errors 2024-05-18 23:41:49 +02:00
Anton MedvedevandGitHub 68e3148c1f Vendor testify (#642) 2024-05-08 00:24:35 +02:00
Ganesan KaruppasamyandGitHub 36482dfa5a Resolve double-escaping issue with pair node key (#640)
* Resolve double-escaping issue with pair node key

* Resolve double-escaping issue with pair node key

* Added test cases for pair node key
2024-05-07 21:07:12 +02:00
Anton Medvedev 3ceff1cdb3 Fix printing on conditional/binary nodes
Fixes #613
2024-04-16 23:23:12 +02:00
Anton Medvedev 9ca56a8aeb Better map ast printing 2024-03-27 09:26:56 +01:00
Anton Medvedev 2171fef85d Fix ast printing of ?.[ 2024-02-12 22:15:17 +01:00
Anton Medvedev 7d4dd1a708 Improve ast printing for boolean operators 2024-01-17 23:21:11 +01:00
Ganesan KaruppasamyandGitHub 9b73bb722e Remove parents field for optimization (#527) 2024-01-16 12:47:46 +01:00
Anton Medvedev 1dca2cbdc2 Move ast.Function to builtin.Function 2023-12-29 21:04:25 +01:00
Anton MedvedevandGitHub 30be4c9f08 Remove redundant fields from CallNode and BinaryNode (#504) 2023-12-29 19:50:08 +01:00
Anton MedvedevandGitHub 8e2df3e45e Simplify ast nodes (#503)
* Move FiendIndex and MethodIndex out of ast nodes

* Remove println statement

* Add method compiler tests
2023-12-26 23:14:20 +01:00
Anton Medvedev 6aba05a765 Update ast comments 2023-12-22 22:49:43 +01:00
Anton Medvedev 551d2a7e0f Use expr-lang/expr 2023-12-03 21:53:01 +01:00
Anton Medvedev 2439c112f9 Update ast comments 2023-11-27 20:36:08 +01:00
Anton Medvedev 8048a93b2d Add ast comments
Rename program.Opcodes() to program.DisassembleWriter()
2023-11-27 19:15:20 +01:00
Anton Medvedev 6d9b8d819f Improve type checking for $env
Fixes #462
2023-11-16 22:12:50 +01:00
Anton Medvedev 12bade29ad Fix ast printing for ?? operator
Fixes #442
2023-11-16 16:22:34 +01:00
Anton Medvedev 3274bda123 Do not copy node type in ast.Patch
Fixes #468
2023-11-16 15:41:43 +01:00
Anton Medvedev 32f5fde2eb Replace interface{} with any 2023-08-30 11:25:15 +02:00
Anton Medvedev 9a9cab2e4a Add sort builtin 2023-08-28 14:55:44 +02:00
Anton Medvedev eb03bcb945 Remove ExperimentalPipe() 2023-08-24 15:26:36 +02:00
Anton Medvedev 46929e4646 Add map(filter()) optimization 2023-08-24 11:15:43 +02:00
Anton Medvedev 8c52bd6d8b Add filter()[0] optimization 2023-08-24 11:15:43 +02:00
Anton Medvedev ed5f9bfbcb Add variables 2023-08-22 22:30:07 +02:00
Anton Medvedev b900473614 Fix SliceNode String() 2023-08-21 11:58:29 +02:00
Anton Medvedev c8b485f6a8 Add String() to nodes 2023-08-17 17:23:18 +02:00
Anton MedvedevandGitHub 95fc04c65e Refactor deref (#398)
* Refactor deref types

* Refactor deref opcode inserts

* Add multiple pointers deref
2023-08-10 22:09:32 +02:00
Anton Medvedev 2c1a3790aa Add comment 2023-03-20 21:15:52 +01:00
Anton Medvedev e6f4e823ba Add todo 2023-03-20 21:13:35 +01:00
Anton Medvedev 72a4ce18e9 Add len() builtin 2023-01-29 20:34:15 +01:00
Anton Medvedev 75edfd2b79 Add tests 2023-01-29 20:34:15 +01:00
Anton Medvedev 4b7c89eff1 Add expr.Function feature 2023-01-29 20:34:15 +01:00
Anton Medvedev 54c29bfda2 Simplify "not in" operators 2022-11-06 13:04:35 +01:00
Anton Medvedev 6e7a89b65c Optimizer should return []interface{} as well. 2022-11-05 20:33:41 +01:00
Anton MedvedevandGitHub 1c69d7a8ef Add OpCallTyped (#269) 2022-11-05 13:44:15 +01:00
Anton Medvedev 97b2a9e16d Simplify ast.Visitor interface 2022-11-02 22:27:34 +01:00
Anton Medvedev b8346f98f1 Optimize method calls and builtins opcodes 2022-10-27 21:23:04 +02:00
Anton Medvedev 4104ff8967 Add runtime.Field 2022-10-19 23:37:56 +02:00
Anton Medvedev 2a34731b5a Add FieldByIndex optimization 2022-10-19 00:55:01 +02:00
Anton Medvedev b0705d7de2 Add OpDeref opcode 2022-10-18 00:08:53 +02:00