oils-for-unix / oils

Oils is our upgrade path from bash to a better language and runtime. It's also for Python and JavaScript users who avoid shell!
http://www.oilshell.org/
Other
2.84k stars 157 forks source link

[mycpp] share if-statement special cases with all visitors #2021

Closed melvinw closed 3 months ago

melvinw commented 3 months ago

The SimpleVisitor base class was missing these before. This was causing ir_pass to run into various collisions that cppgen_pass wasn't. Fixing this allows us to make HeapObjectMember more strict, which simplifies the next datalog patch.

melvinw commented 3 months ago

Just double-checked: the diff of _gen/bin/oils_for_unix.mycpp.cc is empty between this patch and master

andychu commented 3 months ago

OK great, yeah this looks more reasonable

It is more verbose but I think being explicit is better. Thanks!

andychu commented 3 months ago

Hm I imagine if we have our own IR, I guess we would do a transformation where

i.e. we would create new DATA rather than changing the way we iterate over the MyPy data

But I realize that is hard because everything is so tightly coupled to MyPy right now


Having explicit decoupled functions in util.py will help us move to that style I think

Now I think the downside of visitors is that everything becomes very tightly coupled to that API , which is the problem we are having ...