-
I'm building a system where there is a non trivial cost to building the environment and the program isn't known in advance. There are a few hundred possible inputs, but most programs will only need one or two. I'd like to only populate the environment with the necessary inputs, saving a lot of compute cost getting the rest. Is there any good way (or can one be added) to get the expected inputs? Ideally a map of I've hacked one together below, but I'm not certain it covers all cases (OpLoadField/OpFetchField might be missing?), and it doesn't give me the expected type. If this isn't an ER you'd want to take to main, can you comment on if I'm missing anything important in this version? Thanks in advance!
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
Ahhhh, you have a sample for this in docs. https://expr.medv.io/docs/Visitor-and-Patch Will leave this open as an feature request, but understand if you close it. |
Beta Was this translation helpful? Give feedback.
-
Ha! Just what I was thinking - one way to attack this might be use a Visitor to check all the nodes in the tree, and load every identifier you come across from your set of hundreds. But getting the expected type might be a little tricky. |
Beta Was this translation helpful? Give feedback.
-
One more note: it would be nice to have an official api because a few tricks to figure out (like calling optimize). But it's doable without one. |
Beta Was this translation helpful? Give feedback.
-
Here's what I ended up with. Had to dive into internals a bit to get this working with config/methods/optimizer, might be handy as a tested part of the main project, but I leave that up to you!
|
Beta Was this translation helpful? Give feedback.
Here's what I ended up with. Had to dive into internals a bit to get this working with config/methods/optimizer, might be handy as a tested part of the main project, but I leave that up to you!