[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 15:12:38 BST 2023


https://bugs.libre-soc.org/show_bug.cgi?id=1094

--- Comment #39 from Luke Kenneth Casson Leighton <lkcl at lkcl.net> ---
(In reply to Dmitry Selyutin from comment #36)

> Basically what I want is "only filter some specific records to be visited,
> where record name matches the CLI arguments".

https://git.libre-soc.org/?p=openpower-isa.git;a=blob;f=src/openpower/decoder/power_decoder.py;h=9389dd3a#l328

i pass in a col_subset (a set - by CSV-name - of which columns)
and a row_subsetfn.

row_subsetfn receives the row and returns True/False.

however the *visitor* would simply go:

     def child_data_function(self, child_index, child_data):
          if some_filter_criteria(child_data):
               return
          do_something_with_child_data(child_data)

ahhh i know what you've missed.  look again at the pyomo Visitor API:

https://git.libre-soc.org/?p=openpower-isa.git;a=blob;f=src/openpower/visitor.py;h=7ad025cd0#l97

the "enterNode()" function is where the Visitor API allows for "results"
to be accumulated - partially - and keeps all necessary state information.

  83        initializeWalker(expr) -> walk, result
  84        enterNode(N1) -> args, data
  85        {for N2 in args:}
  86          beforeChild(N1, N2) -> descend, child_result
  87            enterNode(N2) -> N2_args, N2_data
  88            [...]
  89            exitNode(N2, n2_data) -> child_result
  90          acceptChildResult(N1, data, child_result) -> data
  91          afterChild(N1, N2) -> None
  92        exitNode(N1, data) -> N1_result
  93        finalizeWalker(result) -> result

so the Visitor-callbacks receive all the information they need to "keep track".

one of the things they can "keep track" of is: an object with the
filter arguments.  anything else can also be passed "up the stack"
of the Visitor-callbacks.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the libre-soc-bugs mailing list