124 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 MedvedevandGitHub 452d355706 Make expr.Eval faster (#775)
* Make expr.Eval faster

* Add bench_call_test.go

* Make parser config optional
2025-03-24 14:48:41 +01:00
Anton Medvedev 6022ffd21d Add support deref in all builtins 2025-03-10 13:38:02 +01:00
Anton Medvedev 82ec7571df Correctly add OpDeref if needed
Fixes #739
2025-03-09 13:07:38 +01:00
Anton Medvedev 5aada75b87 Add SequenceNode to compiler 2025-03-08 12:46:59 +01: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 1960bc8e9d Improve compilation for detached tree parts 2024-05-30 21:45:13 +02:00
Anton MedvedevandGitHub 0308dbbbb4 Fix function calls with int64 params (#663)
Fixes #661
2024-05-27 12:05:19 +02:00
Ganesan KaruppasamyandGitHub b53d7bdcfd Invoke the Deref function as needed for the function arguments. (#651) 2024-05-21 11:10:48 +02:00
Anton Medvedev 0a33193f26 Fix build for 386 and add build.yml workflow 2024-05-17 21:40:50 +02:00
Anton Medvedev cea9c8ae86 Add int overflow checks 2024-05-09 17:22:41 +02:00
Anton Medvedev c8f7d22462 Return proper nil from optional chain
Fixes #570
2024-04-16 23:11:01 +02:00
Anton Medvedev c5dfe3a811 Make count() predicate optional 2024-04-13 23:38:35 +02:00
Anton MedvedevandGitHub 772eaba1ca Add predicate to sum() builtin (#592)
* Add predicate to sum() builtin

* go mod tidy
2024-04-13 15:37:02 +02:00
zhuliquanandGitHub 62163f4450 feat: extract code for compiling equal operator (#614) 2024-03-28 14:37:51 +01:00
Anton MedvedevandGitHub 46d295876f Add spans 2024-02-29 20:51:34 +01:00
Anton MedvedevandGitHub b1e82de54a Refactor groupBy and sortBy (#562)
* Rearrange opcodes

* Refactor groupBy

* Fix tests

* Super opcodes for GroupBy

* Refactor sortBy builtin

* Fix sortBy bench
2024-02-15 19:53:35 +01:00
Anton Medvedev fdae534aa9 Add OpCallSafe 2024-02-12 22:15:17 +01:00
SergeyandGitHub a20dd842e3 Optimize jump opcodes (#545) 2024-02-02 19:37:21 +01:00
Anton MedvedevandGitHub 84f18d7e5d Add ast tree to program (#528)
* Add pro holder

* explain
2024-01-17 20:01:34 +01:00
Anton MedvedevandGitHub 010c934215 Fix race cond in variabels (#523)
* Add race cond test

* Move variables array to vm

* Resize vars array for different programs
2024-01-13 20:41:14 +01:00
Anton MedvedevandGitHub d903980830 Add mem grow to builtin (#505)
* Add mem grow to builtin

* Add OpValidateArgs opcode
2023-12-30 12:49:43 +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 97df6debcd fix: make deref commutative
Fixes #490
2023-12-10 11:02:12 +01:00
Anton Medvedev 551d2a7e0f Use expr-lang/expr 2023-12-03 21:53:01 +01:00
Anton Medvedev 2cf93593f4 Hide fields in vm.Program 2023-11-27 13:52:56 +01:00
Anton Medvedev 638a454886 Only emit OpEqual{Int,String} for simple types
Fixes #461
2023-11-16 21:39:50 +01:00
hesiningandGitHub a05268880c Propagate uint32 arguments types in ast (#438) 2023-09-12 16:10:41 +02:00
Anton Medvedev 6d8d2390cf Remove countBy 2023-08-30 14:55:05 +02:00
Anton Medvedev 5023b3005d Add reduce() 2023-08-30 13:33:16 +02:00
Anton Medvedev 7f85c0551f Add countBy() 2023-08-30 12:07:16 +02:00
Anton Medvedev 32f5fde2eb Replace interface{} with any 2023-08-30 11:25:15 +02:00
Anton Medvedev 3f57b885d4 Add groupBy 2023-08-30 11:14:54 +02:00
Anton Medvedev 9a9cab2e4a Add sort builtin 2023-08-28 14:55:44 +02:00
Anton Medvedev 846431d0c9 Add named pointers #index 2023-08-25 11:23:44 +02:00
Anton Medvedev 46929e4646 Add map(filter()) optimization 2023-08-24 11:15:43 +02:00
Anton Medvedev 166d8b8ce9 Add filter()[-1] 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 2c139ca36a Add find() and findIndex() 2023-08-24 11:15:43 +02:00
Anton Medvedev ed5f9bfbcb Add variables 2023-08-22 22:30:07 +02:00
Anton Medvedev 4ae978d384 Allow to disable builtins 2023-08-19 22:24:42 +02:00
Anton Medvedev a012738292 Rename env to $env 2023-08-15 23:34:16 +02:00
Anton Medvedev ffc47e10cc Add func names in disassemble 2023-08-15 23:05:53 +02:00
Anton Medvedev 719f30d3ad Add builtin functions 2023-08-14 15:37:06 +02:00
Anton Medvedev 8177d8bd9f Add OpCallBuiltin opcode to avoid an extra allocation 2023-08-14 11:50:42 +02:00