Skip to content

Commit

Permalink
interactive: Moving the pass pipeline string construction to own func…
Browse files Browse the repository at this point in the history
…tion (2/4) (#1822)
  • Loading branch information
dshaaban01 authored Dec 1, 2023
1 parent 613d09a commit a12487b
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions xdsl/interactive/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,7 @@ def watch_pass_pipeline(self) -> None:
Function called when the reactive variable pass_pipeline changes - updates the
label to display the respective generated query in the Label.
"""
new_passes = "\n" + (", " + "\n").join(p.name for p in self.pass_pipeline)
new_label = f"xdsl-opt -p {new_passes}"
self.selected_query_label.update(new_label)
self.selected_query_label.update(self.get_query_string())
self.update_current_module()

@on(TextArea.Changed, "#input")
Expand Down Expand Up @@ -275,6 +273,15 @@ def watch_current_module(self):

self.output_text_area.load_text(output_text)

def get_query_string(self) -> str:
"""
Function returning a string containing the textual description of the pass
pipeline generated thus far.
"""
new_passes = "\n" + (", " + "\n").join(p.name for p in self.pass_pipeline)
new_label = f"xdsl-opt -p {new_passes}"
return new_label

def action_toggle_dark(self) -> None:
"""An action to toggle dark mode."""
self.dark = not self.dark
Expand All @@ -296,9 +303,7 @@ def copy_output(self, event: Button.Pressed) -> None:
@on(Button.Pressed, "#copy_query_button")
def copy_query(self, event: Button.Pressed) -> None:
"""Selected passes/query Label is copied when "Copy Query" button is pressed."""
selected_passes = "\n" + (", " + "\n").join(p.name for p in self.pass_pipeline)
query = f"xdsl-opt -p {selected_passes}"
pyclip_copy(query)
pyclip_copy(self.get_query_string())

@on(Button.Pressed, "#clear_passes_button")
def clear_passes(self, event: Button.Pressed) -> None:
Expand Down

0 comments on commit a12487b

Please sign in to comment.