| 1 |
|
| #define PERL_NO_GET_CONTEXT |
| 2 |
|
| #include <EXTERN.h> |
| 3 |
|
| #include <perl.h> |
| 4 |
|
| #include <XSUB.h> |
| 5 |
|
| |
| 6 |
|
| #include "ppport.h" |
| 7 |
|
| |
| 8 |
|
| MODULE = Dallycot::Processor::XS PACKAGE = Dallycot::Processor::XS |
| 9 |
|
| |
| 10 |
|
| int add_cost(SV *engine, int delta) |
| 11 |
|
| PREINIT: |
| 12 |
|
| int new_cost; |
| 13 |
|
| int ignore_cost; |
| 14 |
|
| int count; |
| 15 |
|
| CODE: |
| 16 |
10562 |
▶ | PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP); |
0 |
10562 |
10562 |
|
| 17 |
10562 |
▶ | XPUSHs(engine); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(engine); |
0 |
10562 |
10562 |
|
| 18 |
10562 |
| PUTBACK; |
| 19 |
10562 |
| count = call_method("ignore_cost", G_SCALAR); |
| 20 |
|
| |
| 21 |
10562 |
| SPAGAIN; |
| 22 |
|
| |
| 23 |
10562 |
▶ | if (count != 1) |
Branch: 1 branch
| Branch | True | False | Total |
| if (count != 1) |
0 |
10562 |
10562 |
|
| 24 |
0 |
| croak("ignore_cost method didn't return a value!"); |
| 25 |
|
| |
| 26 |
10562 |
| ignore_cost = POPi; |
| 27 |
|
| |
| 28 |
10562 |
▶ | if(ignore_cost) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(ignore_cost) { |
0 |
10562 |
10562 |
|
| 29 |
0 |
| new_cost = 0; |
| 30 |
|
| } |
| 31 |
|
| else { |
| 32 |
10562 |
▶ | PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP); |
0 |
10562 |
10562 |
|
| 33 |
10562 |
▶ | XPUSHs(engine); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(engine); |
0 |
10562 |
10562 |
|
| 34 |
10562 |
| PUTBACK; |
| 35 |
10562 |
| count = call_method("cost", G_SCALAR); |
| 36 |
|
| |
| 37 |
10562 |
| SPAGAIN; |
| 38 |
|
| |
| 39 |
10562 |
▶ | if (count != 1) |
Branch: 1 branch
| Branch | True | False | Total |
| if (count != 1) |
0 |
10562 |
10562 |
|
| 40 |
0 |
| croak("cost method didn't return a value!"); |
| 41 |
|
| |
| 42 |
10562 |
| new_cost = POPi; |
| 43 |
|
| |
| 44 |
10562 |
| new_cost = new_cost + delta; |
| 45 |
|
| |
| 46 |
10562 |
▶ | PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP); |
0 |
10562 |
10562 |
|
| 47 |
10562 |
▶ | XPUSHs(engine); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(engine); |
0 |
10562 |
10562 |
|
| 48 |
10562 |
▶ | XPUSHs(sv_2mortal(newSVnv(new_cost))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVnv(new_cost))); |
0 |
10562 |
10562 |
|
| 49 |
10562 |
| PUTBACK; |
| 50 |
|
| |
| 51 |
10562 |
| call_method("_cost", G_SCALAR); |
| 52 |
|
| |
| 53 |
10562 |
| SPAGAIN; |
| 54 |
|
| } |
| 55 |
|
| |
| 56 |
10562 |
▶ | RETVAL = new_cost; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = new_cost; |
8799 |
1763 |
10562 |
|
| 57 |
|
| |
| 58 |
|
| OUTPUT: |
| 59 |
|
| RETVAL |
| 60 |
|
| |
| 61 |
|
| void DEMOLISH(SV *engine, int flag) |
| 62 |
|
| PREINIT: |
| 63 |
|
| int count; |
| 64 |
|
| int has_parent; |
| 65 |
|
| int our_cost; |
| 66 |
|
| SV *parent; |
| 67 |
|
| CODE: |
| 68 |
1834 |
▶ | if(!flag) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(!flag) { |
1718 |
116 |
1834 |
|
| 69 |
1718 |
▶ | PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP); |
0 |
1718 |
1718 |
|
| 70 |
1718 |
▶ | XPUSHs(engine); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(engine); |
0 |
1718 |
1718 |
|
| 71 |
1718 |
| PUTBACK; |
| 72 |
1718 |
| count = call_method("has_parent", G_SCALAR); |
| 73 |
|
| |
| 74 |
1718 |
| SPAGAIN; |
| 75 |
|
| |
| 76 |
1718 |
▶ | if (count != 1) |
Branch: 1 branch
| Branch | True | False | Total |
| if (count != 1) |
0 |
1718 |
1718 |
|
| 77 |
0 |
| croak("has_parent method didn't return a value!"); |
| 78 |
|
| |
| 79 |
1718 |
| has_parent = POPi; |
| 80 |
1718 |
▶ | if(has_parent) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(has_parent) { |
1718 |
0 |
1718 |
|
| 81 |
1718 |
▶ | PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP); |
0 |
1718 |
1718 |
|
| 82 |
1718 |
▶ | XPUSHs(engine); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(engine); |
0 |
1718 |
1718 |
|
| 83 |
1718 |
| PUTBACK; |
| 84 |
1718 |
| count = call_method("parent", G_SCALAR); |
| 85 |
1718 |
| SPAGAIN; |
| 86 |
1718 |
▶ | if (count != 1) |
Branch: 1 branch
| Branch | True | False | Total |
| if (count != 1) |
0 |
1718 |
1718 |
|
| 87 |
0 |
| croak("parent method didn't return a value!"); |
| 88 |
1718 |
| parent = POPs; |
| 89 |
|
| |
| 90 |
1718 |
▶ | PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP); |
0 |
1718 |
1718 |
|
| 91 |
1718 |
▶ | XPUSHs(engine); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(engine); |
0 |
1718 |
1718 |
|
| 92 |
1718 |
| PUTBACK; |
| 93 |
1718 |
| count = call_method("cost", G_SCALAR); |
| 94 |
1718 |
| SPAGAIN; |
| 95 |
1718 |
▶ | if (count != 1) |
Branch: 1 branch
| Branch | True | False | Total |
| if (count != 1) |
0 |
1718 |
1718 |
|
| 96 |
0 |
| croak("cost method didn't return a value!"); |
| 97 |
|
| |
| 98 |
1718 |
| our_cost = POPi; |
| 99 |
1718 |
▶ | PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP); |
0 |
1718 |
1718 |
|
| 100 |
1718 |
▶ | XPUSHs(parent); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(parent); |
0 |
1718 |
1718 |
|
| 101 |
1718 |
▶ | XPUSHs(sv_2mortal(newSVnv(our_cost))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVnv(our_cost))); |
0 |
1718 |
1718 |
|
| 102 |
1718 |
| PUTBACK; |
| 103 |
1718 |
| call_method("add_cost", G_SCALAR); |
| 104 |
|
| } |
| 105 |
|
| } |