equip.visitors package¶
Submodules¶
equip.visitors.bytecode¶
Callback the visitor method for each encountered opcode.
copyright: |
|
---|---|
license: | Apache 2, see LICENSE for more details. |
-
class
equip.visitors.bytecode.
BytecodeVisitor
[source]¶ Bases:
object
A visitor to visit each instruction in the bytecode. For example, the following code:
class CallFunctionVisitor(BytecodeVisitor): def __init__(self): BytecodeVisitor.__init__(self) def visit_call_function(self, oparg): print "Function call with %d args" % oparg
Prints whenever a
CALL_FUNCTION
opcode is visited and prints out its number of arguments (the oparg for this opcode).-
visit
(index, op, arg=None, lineno=None, cflow_in=False)[source]¶ Callback of the visitor. It dynamically constructs the name of the specialized visitor to call based on the name of the opcode.
Parameters: - index – Bytecode index.
- op – The opcode that is currently visited.
- arg – The expanded oparg (i.e., constants, names, etc. are resolved).
- lineno – The line number associated with the opcode.
- cflow_in –
True
if the currentindex
is the target of a jump.
-
equip.visitors.classes¶
Callback the visit method for each encountered class in the program.
copyright: |
|
---|---|
license: | Apache 2, see LICENSE for more details. |
-
class
equip.visitors.classes.
ClassVisitor
[source]¶ Bases:
object
A class visitor that is triggered for all encountered
TypeDeclaration
.Example, listing all types declared in the bytecode:
class TypeDeclVisitor(ClassVisitor): def __init__(self): ClassVisitor.__init__(self) def visit(self, typeDecl): print "New type: %s (parentDecl=%s)" \ % (typeDecl.type_name, typeDecl.parent)
equip.visitors.methods¶
Callback the visit method for each encountered method in the program.
copyright: |
|
---|---|
license: | Apache 2, see LICENSE for more details. |
-
class
equip.visitors.methods.
MethodVisitor
[source]¶ Bases:
object
A method visitor that is triggered for all encountered
MethodDeclaration
.Example, listing all methods declared in the bytecode:
class MethodDeclVisitor(MethodVisitor): def __init__(self): MethodVisitor.__init__(self) def visit(self, methDecl): print "New method: %s:%d (parentDecl=%s)" \ % (methDecl.method_name, methDecl.start_lineno, methDecl.parent)