Ready for numba/llnumba -> llvmpy/llpython
This commit is contained in:
parent
6d19096438
commit
bbc7a4ddf0
15 changed files with 0 additions and 0 deletions
27
llpython/gen_bytecode_visitor.py
Normal file
27
llpython/gen_bytecode_visitor.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#! /usr/bin/env python
|
||||
# ______________________________________________________________________
|
||||
|
||||
import opcode_util
|
||||
|
||||
# ______________________________________________________________________
|
||||
|
||||
def generate_bytecode_visitor (classname = 'BytecodeVisitor',
|
||||
baseclass = 'object'):
|
||||
opnames = list(set((opname.split('+')[0]
|
||||
for opname in opcode_util.OPCODE_MAP.keys())))
|
||||
opnames.sort()
|
||||
return 'class %s (%s):\n%s\n' % (
|
||||
classname, baseclass,
|
||||
'\n\n'.join((' def op_%s (self, i, op, arg):\n'
|
||||
' raise NotImplementedError("%s.op_%s")' %
|
||||
(opname, classname, opname)
|
||||
for opname in opnames)))
|
||||
|
||||
# ______________________________________________________________________
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
print(generate_bytecode_visitor(*sys.argv[1:]))
|
||||
|
||||
# ______________________________________________________________________
|
||||
# End of gen_bytecode_visitor.py
|
||||
Loading…
Add table
Add a link
Reference in a new issue