[Libre-soc-bugs] [Bug 1094] insndb instruction database visitor-walker is needed
bugzilla-daemon at libre-soc.org
bugzilla-daemon at libre-soc.org
Sun Jun 4 16:16:57 BST 2023
https://bugs.libre-soc.org/show_bug.cgi?id=1094
--- Comment #41 from Luke Kenneth Casson Leighton <lkcl at lkcl.net> ---
(In reply to Dmitry Selyutin from comment #40)
> (In reply to Luke Kenneth Casson Leighton from comment #39)
> > ahhh i know what you've missed. look again at the pyomo Visitor API:
>
> It's not that I missed it, that's a deliberate omission. With context
> managers, everything before yield is beforeNode; everything after is
> afterNode.
contextmanager - which only has constructor, __enter__ and __exit,
are actually too simple.
now, it turns out that *in some cases* (particularly things that write
directly to file-streams) you just don't need and don't care about
"ongoing state", and *in those cases* a contextmanager is perfectly
sufficient.
(these are effectively "one-pass" in compiler terminology)
but for things that i am envisioning, contextmanager is nowhere near enough.
imagine that you want to do a full language-translation (pseudocode-to-c),
and that (aieee) we do actually put iterative-node-walking down into the RTL.
but the big advantage of pyomo's Visitor walker-function is: it does *both*.
> On the other hand, if we don't allow overriding the manager, we can hide the
> walking logic, so I'm unsure what to choose. Ideas?
these two should in no way be mutually-exclusive.
as i have used Visitors for such a long time i have absolutely no
problem at all with the "there's these functions you provide and they
get called" idea.
the walking-logic should be its own completely separate and independent
function.
https://git.libre-soc.org/?p=openpower-isa.git;a=blob;f=src/openpower/visitor.py;h=7ad025#l506
note, sigh, ha ha: pyomo designed the code so that you *can* inherit from
the VisitorClass. but look carefully at the notes:
168 Clients interact with this class by either deriving from it and
169 implementing the necessary callbacks (see above), assigning callable
170 functions to an instance of this class, or passing the callback
171 functions as arguments to this class' constructor.
and another way would be to pass in an "instance which has those same methods"
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the libre-soc-bugs
mailing list