Message78691
== On the patch itself ==
Why don't you use the C preprocessor instead of that Python code?
Sample code:
#define OPCODE_LIST(DEFINE_OPCODE) \
DEFINE_OPCODE(STOP_CODE, 0) \
DEFINE_OPCODE(POP_TOP, 1) \
DEFINE_OPCODE(ROT_TWO, 2) \
DEFINE_OPCODE(ROT_THREE, 3) \
DEFINE_OPCODE(DUP_TOP, 4) \
DEFINE_OPCODE(ROT_FOUR, 5) \
DEFINE_OPCODE(NOP, 9) \
...
# define DECL_OPCODE(opcode) \
[opcode] = && label_ ## opcode,
void *opcodes[] = {
OPCODE_LIST(DECL_OPCODE)
};
# undef DECL_OPCODE
There are also other ways to do it, but using higher-order functions
within the preprocessor in this way is something that I learned from the
V8 source code.
It has the advantage that OPCODE_LIST can be used in a lot of other
places (maybe when implementing the 'opcode' module, if it's written in C). |
|
Date |
User |
Action |
Args |
2009-01-01 05:15:12 | blaisorblade | set | recipients:
+ blaisorblade, lemburg, skip.montanaro, arigo, rhettinger, pitrou, christian.heimes, alexandre.vassalotti |
2009-01-01 05:15:12 | blaisorblade | set | messageid: <1230786912.6.0.31251595307.issue4753@psf.upfronthosting.co.za> |
2009-01-01 05:15:11 | blaisorblade | link | issue4753 messages |
2009-01-01 05:15:11 | blaisorblade | create | |
|