Remove eval and rework primitive extraction #265
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR reworks how primitives are extracted. Previously you would use
egraph.eval(x)
ifx
is a primitive like ani64
to get the pythonint
value from it. This used some private methods of the egraph at runtime to inspect the rust value.Instead, we now just extract the primitive and use python to "parse" it from the AST. So this also works for things like vecs. This adds support for python builtin methods like
int
andlist
so they can be used to implicitly extract things from the egraph:To do this, we refine the concept of a "current" e-graph in the context. If none exists, one will be created. But we can use one with the
egraph.set_current()
context manager.We also add support for translating
==
intoeq
and!=
intone
for all types. If you need to override these operations on your type, you still can, and then just use the functions.