Skip to content

Basic match for integers; bugfix#18

Merged
mengzhuo merged 2 commits intoplctlab:mainfrom
AdUhTkJm:main
Jan 27, 2025
Merged

Basic match for integers; bugfix#18
mengzhuo merged 2 commits intoplctlab:mainfrom
AdUhTkJm:main

Conversation

@AdUhTkJm
Copy link

@AdUhTkJm AdUhTkJm commented Jan 24, 2025

Adds support to match expression on integers.

Currently, if we denote the set of values to match against as S, only those cases subject to max(S) - min(S) <= 20 will be compiled.

For larger ranges (such as the one in match03), I plan to implement an algorithm of finding a perfect hash function that hashes them into [0, len(S)), so they can fit in a jump table. (On the contrary, the WASM backend just compiles it into a series of if-else.) For len(S) <= 3, I also plan to compile them into if-else.

Bugfix:

  • match on variants now works with Cexpr_join_apply.
  • escape analysis now works properly; it should be done with backwards data flow approach, not forward.

@mengzhuo mengzhuo merged commit 12affe1 into plctlab:main Jan 27, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants