MCPcopy Create free account
hub / github.com/vispy/vispy / StatementList

Class StatementList

vispy/visuals/shaders/function.py:752–788  ·  view source on GitHub ↗

Represents a list of statements.

Source from the content-addressed store, hash-verified

750
751
752class StatementList(ShaderObject):
753 """Represents a list of statements."""
754
755 def __init__(self):
756 self.items = {}
757 self.order = []
758 ShaderObject.__init__(self)
759
760 def add(self, item, position=5):
761 """Add an item to the list unless it is already present.
762
763 If the item is an expression, then a semicolon will be appended to it
764 in the final compiled code.
765 """
766 if item in self.items:
767 return
768 self.items[item] = position
769 self._add_dep(item)
770 self.order = None
771 self.changed(code_changed=True)
772
773 def remove(self, item):
774 """Remove an item from the list."""
775 self.items.pop(item)
776 self._remove_dep(item)
777 self.order = None
778 self.changed(code_changed=True)
779
780 def expression(self, obj_names):
781 if self.order is None:
782 self.order = list(self.items.items())
783 self.order.sort(key=lambda x: x[1])
784
785 code = ""
786 for item, pos in self.order:
787 code += item.expression(obj_names) + ';\n'
788 return code

Callers 3

test_StatementListFunction · 0.90
test_multiprogramFunction · 0.90
_get_hookMethod · 0.85

Calls

no outgoing calls

Tested by 2

test_StatementListFunction · 0.72
test_multiprogramFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…