| 1 |
|
| ################################################################################ |
| 2 |
|
| # |
| 3 |
|
| # Copyright (c) 2002-2020 Marcus Holland-Moritz. All rights reserved. |
| 4 |
|
| # This program is free software; you can redistribute it and/or modify |
| 5 |
|
| # it under the same terms as Perl itself. |
| 6 |
|
| # |
| 7 |
|
| ################################################################################ |
| 8 |
|
| |
| 9 |
|
| |
| 10 |
|
| ################################################################################ |
| 11 |
|
| # |
| 12 |
|
| # METHOD: Include / Define / Assert |
| 13 |
|
| # |
| 14 |
|
| # WRITTEN BY: Marcus Holland-Moritz ON: Mar 2002 |
| 15 |
|
| # CHANGED BY: ON: |
| 16 |
|
| # |
| 17 |
|
| ################################################################################ |
| 18 |
|
| |
| 19 |
|
| void |
| 20 |
|
| CBC::Include(...) |
| 21 |
|
| ALIAS: |
| 22 |
|
| Define = 1 |
| 23 |
|
| Assert = 2 |
| 24 |
|
| |
| 25 |
|
| PREINIT: |
| 26 |
115 |
| CBC_METHOD_VAR; |
| 27 |
|
| LinkedList list; |
| 28 |
|
| int hasRval; |
| 29 |
|
| SV *rval, *inval; |
| 30 |
|
| |
| 31 |
|
| PPCODE: |
| 32 |
115 |
| switch (ix) |
| 33 |
|
| { |
| 34 |
40 |
| case 1: /* Define */ |
| 35 |
40 |
| CBC_METHOD_SET("Define"); |
| 36 |
40 |
| list = THIS->cfg.defines; |
| 37 |
40 |
| break; |
| 38 |
36 |
| case 2: /* Assert */ |
| 39 |
36 |
| CBC_METHOD_SET("Assert"); |
| 40 |
36 |
| list = THIS->cfg.assertions; |
| 41 |
36 |
| break; |
| 42 |
39 |
| default: /* Include */ |
| 43 |
39 |
| CBC_METHOD_SET("Include"); |
| 44 |
39 |
| list = THIS->cfg.includes; |
| 45 |
39 |
| break; |
| 46 |
|
| } |
| 47 |
|
| |
| 48 |
|
| CT_DEBUG_METHOD; |
| 49 |
|
| |
| 50 |
115 |
▶ | hasRval = GIMME_V != G_VOID && items <= 1; |
Branch: 2 branches
| Branch | True | False | Total |
| hasRval = GIMME_V != G_VOID && items <= 1; |
14 |
101 |
115 |
| hasRval = GIMME_V != G_VOID && items <= 1; |
10 |
4 |
14 |
|
| 51 |
|
| |
| 52 |
115 |
▶ | if (GIMME_V == G_VOID && items <= 1) |
Branch: 2 branches
| Branch | True | False | Total |
| if (GIMME_V == G_VOID && items <= 1) |
101 |
14 |
115 |
| if (GIMME_V == G_VOID && items <= 1) |
3 |
98 |
101 |
|
| 53 |
|
| { |
| 54 |
3 |
▶ | WARN_VOID_CONTEXT; |
Branch: 1 branch
| Branch | True | False | Total |
| WARN_VOID_CONTEXT; |
3 |
0 |
3 |
|
| 55 |
3 |
| XSRETURN_EMPTY; |
| 56 |
|
| } |
| 57 |
|
| |
| 58 |
112 |
▶ | if (items > 1 && !SvROK(ST(1))) |
Branch: 2 branches
| Branch | True | False | Total |
| if (items > 1 && !SvROK(ST(1))) |
102 |
10 |
112 |
| if (items > 1 && !SvROK(ST(1))) |
36 |
66 |
102 |
|
| 59 |
30 |
| { |
| 60 |
|
| int i; |
| 61 |
36 |
| inval = NULL; |
| 62 |
|
| |
| 63 |
98 |
▶ | for (i = 1; i < items; i++) |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 1; i < items; i++) |
68 |
30 |
98 |
|
| 64 |
|
| { |
| 65 |
68 |
▶ | if (SvROK(ST(i))) |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvROK(ST(i))) |
6 |
62 |
68 |
|
| 66 |
6 |
| Perl_croak(aTHX_ "Argument %d to %s must not be a reference", i, method); |
| 67 |
|
| |
| 68 |
62 |
| LL_push(list, string_new_fromSV(aTHX_ ST(i))); |
| 69 |
|
| } |
| 70 |
|
| } |
| 71 |
|
| else |
| 72 |
|
| { |
| 73 |
76 |
▶ | if (items > 2) |
Branch: 1 branch
| Branch | True | False | Total |
| if (items > 2) |
6 |
70 |
76 |
|
| 74 |
6 |
| Perl_croak(aTHX_ "Invalid number of arguments to %s", method); |
| 75 |
|
| |
| 76 |
70 |
▶ | inval = items == 2 ? ST(1) : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| inval = items == 2 ? ST(1) : NULL; |
60 |
10 |
70 |
|
| 77 |
|
| } |
| 78 |
|
| |
| 79 |
100 |
▶ | if (inval != NULL || hasRval) |
Branch: 2 branches
| Branch | True | False | Total |
| if (inval != NULL || hasRval) |
40 |
60 |
100 |
| if (inval != NULL || hasRval) |
10 |
30 |
40 |
|
| 80 |
70 |
▶ | handle_string_list(aTHX_ method, list, inval, hasRval ? &rval : NULL); |
Branch: 1 branch
| Branch | True | False | Total |
| handle_string_list(aTHX_ method, list, inval, hasRval ? &rval : NULL); |
10 |
60 |
70 |
|
| 81 |
|
| |
| 82 |
88 |
▶ | if (hasRval) |
Branch: 1 branch
| Branch | True | False | Total |
| if (hasRval) |
10 |
78 |
88 |
|
| 83 |
10 |
| ST(0) = sv_2mortal(rval); |
| 84 |
|
| |
| 85 |
88 |
| reset_preprocessor(&THIS->cpi); |
| 86 |
|
| |
| 87 |
88 |
| XSRETURN(1); |
| 88 |
|
| |
| 89 |
|
| |