|
Revision 14549, 0.9 kB
(checked in by tokuhirom, 7 months ago)
|
|
display op info
|
| Line | |
|---|
| 1 | #define PERL_CORE |
|---|
| 2 | |
|---|
| 3 | #include "EXTERN.h" |
|---|
| 4 | #include "perl.h" |
|---|
| 5 | #include "XSUB.h" |
|---|
| 6 | |
|---|
| 7 | #include "ppport.h" |
|---|
| 8 | |
|---|
| 9 | static op_score; |
|---|
| 10 | |
|---|
| 11 | static OP *(*PL_ppaddr_bak[OP_max + 1])(pTHX); |
|---|
| 12 | |
|---|
| 13 | OP * count_score(pTHX) { |
|---|
| 14 | PerlIO_printf(PerlIO_stderr(), "hit: %dop(%s, %s)\n", PL_op->op_type, OP_NAME(PL_op), OP_DESC(PL_op)); |
|---|
| 15 | op_score += PL_op->op_type; |
|---|
| 16 | |
|---|
| 17 | if (PL_op->op_type == OP_LEAVE) { |
|---|
| 18 | PerlIO_printf(PerlIO_stdout(), "Your perl is : %d.%d.%d\n", PERL_REVISION, PERL_VERSION, PERL_SUBVERSION); |
|---|
| 19 | PerlIO_printf(PerlIO_stdout(), "Your score is : %dop\n", op_score); |
|---|
| 20 | } |
|---|
| 21 | |
|---|
| 22 | return PL_ppaddr_bak[PL_op->op_type](aTHX); |
|---|
| 23 | } |
|---|
| 24 | |
|---|
| 25 | MODULE = Acme::PerlVMGolf PACKAGE = Acme::PerlVMGolf |
|---|
| 26 | |
|---|
| 27 | PROTOTYPES: ENABLE |
|---|
| 28 | |
|---|
| 29 | BOOT: |
|---|
| 30 | { |
|---|
| 31 | op_score = 0; |
|---|
| 32 | } |
|---|
| 33 | |
|---|
| 34 | void |
|---|
| 35 | _setup() |
|---|
| 36 | PROTOTYPE: |
|---|
| 37 | CODE: |
|---|
| 38 | int i; |
|---|
| 39 | for (i = 0;i < OP_max;i++) { |
|---|
| 40 | PL_ppaddr_bak[i] = PL_ppaddr[i]; |
|---|
| 41 | PL_ppaddr[i] = count_score; |
|---|
| 42 | } |
|---|