projects
/
openpower-isa.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
3f78f9d
)
insndb/db: switch to holy-cow visitors
author
Dmitry Selyutin
<ghostmansd@gmail.com>
Sat, 10 Jun 2023 16:00:32 +0000
(19:00 +0300)
committer
Luke Kenneth Casson Leighton
<lkcl@lkcl.net>
Fri, 22 Dec 2023 19:26:19 +0000
(19:26 +0000)
src/openpower/insndb/db.py
patch
|
blob
|
history
diff --git
a/src/openpower/insndb/db.py
b/src/openpower/insndb/db.py
index 17f46911ebb0ac9dce806e3678b6dc235d49e11d..a5210f087c85f63ead87622ac161fec19554ffd2 100644
(file)
--- a/
src/openpower/insndb/db.py
+++ b/
src/openpower/insndb/db.py
@@
-13,6
+13,7
@@
from openpower.insndb.core import (
Records,
Visitor,
visit,
Records,
Visitor,
visit,
+ visitormethod,
)
)
@@
-40,25
+41,23
@@
class SVP64Instruction(Instruction):
class ListVisitor(Visitor):
class ListVisitor(Visitor):
- @contextlib.contextmanager
- def __call__(self, node):
- if isinstance(node, Record):
- print(node.name)
+ @visitormethod(Record)
+ def Record(self, node):
+ print(node.name)
yield node
class OpcodesVisitor(Visitor):
yield node
class OpcodesVisitor(Visitor):
- @contextlib.contextmanager
- def __call__(self, node):
- if isinstance(node, Record):
- for opcode in node.opcodes:
- print(opcode)
+ @visitormethod(Record)
+ def Record(self, node):
+ for opcode in node.opcodes:
+ print(opcode)
yield node
class OperandsVisitor(Visitor):
yield node
class OperandsVisitor(Visitor):
- @
contextlib.contextmanager
- def
__call__
(self, node):
+ @
visitormethod(Record)
+ def
Record
(self, node):
if isinstance(node, Record):
for operand in node.dynamic_operands:
print(operand.name, ",".join(map(str, operand.span)))
if isinstance(node, Record):
for operand in node.dynamic_operands:
print(operand.name, ",".join(map(str, operand.span)))
@@
-70,8
+69,8
@@
class OperandsVisitor(Visitor):
class PCodeVisitor(Visitor):
class PCodeVisitor(Visitor):
- @
contextlib.contextmanager
- def
__call__
(self, node):
+ @
visitormethod(Record)
+ def
Record
(self, node):
if isinstance(node, Record):
for line in node.pcode:
print(line)
if isinstance(node, Record):
for line in node.pcode:
print(line)
@@
-79,14
+78,14
@@
class PCodeVisitor(Visitor):
class ExtrasVisitor(Visitor):
class ExtrasVisitor(Visitor):
- @
contextlib.contextmanager
- def
__call__
(self, node):
-
if isinstance(node, Extra
):
- print(n
ode.n
ame)
- print(" sel",
node.sel
)
- print(" reg",
node.reg
)
- print(" seltype",
node.seltype
)
- print(" idx",
node.idx
)
+ @
visitormethod(Record)
+ def
Record
(self, node):
+
for (name, extra) in node.extras.items(
):
+ print(name)
+ print(" sel",
extra["sel"]
)
+ print(" reg",
extra["reg"]
)
+ print(" seltype",
extra["seltype"]
)
+ print(" idx",
extra["idx"]
)
yield node
yield node