import libgenop libgenop.load() print("""// Generated by codegen/create_bif_tab_*.py #include "bif_tab.h" #include "predef_atoms.h" #include "bif/bif_misc.h" #include "bif/bif_proc.h" namespace gluon { namespace bif { const BIFIndex g_bif_table[bif_table_size] = {""") # print atom constants for b in libgenop.bif_tab: arity = int(b['arity']) bif_atom_id = libgenop.atom_id_tab[b['atom']] bif_atom = libgenop.id_atom_tab[bif_atom_id] bifname = libgenop.atom_constname(bif_atom) print(' {atom::%s, %d, (void *)&bif_%s_%d}, // atom id=%d' \ % (bifname, arity, b['cname'], arity, bif_atom_id)) print("""}; } // ns bif } // ns gluon """)
#!/usr/bin/python # takes: genop.tab from erlang/otp # produces: predef atoms include file with constants import libgenop libgenop.load() print("""// Generated by codegen/vm_predef_atoms_*.py #include "term.h" namespace gluon { namespace atom { """) # print atom constants for a in libgenop.atom_tab: constname = libgenop.atom_constname(a) print(" const Term %s = Term::make_atom(%d);" % (constname, a['id'])) print(""" extern const char *g_predef_atoms; } // ns atom } // ns gluon """)