| 1 |
|
| # The proxies a program sees for a context array or hash, and for every |
| 2 |
|
| # plain hash or array inside a context variable. Each is tied to a path, |
| 3 |
|
| # resolved against the current context at each access; every change copies |
| 4 |
|
| # the levels above it and stores the new top through the variable's rules. |
| 5 |
|
| |
| 6 |
|
| MODULE = Context::Vars PACKAGE = Context::Vars::Hash |
| 7 |
|
| |
| 8 |
|
| void |
| 9 |
|
| FETCH(self, key) |
| 10 |
|
| SV *self |
| 11 |
|
| SV *key |
| 12 |
|
| PPCODE: |
| 13 |
|
| { |
| 14 |
4153 |
| AV *path = context_vars_proxy_path(aTHX_ self); |
| 15 |
4153 |
▶ | SV *node = path ? context_vars_path_get(aTHX_ path) : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| SV *node = path ? context_vars_path_get(aTHX_ path) : NULL; |
4153 |
0 |
4153 |
|
| 16 |
4153 |
▶ | SV *val = node ? context_vars_node_get(aTHX_ node, key) : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| SV *val = node ? context_vars_node_get(aTHX_ node, key) : NULL; |
4153 |
0 |
4153 |
|
| 17 |
4153 |
▶ | XPUSHs(val ? context_vars_out(aTHX_ val, context_vars_path_plus(aTHX_ path, key)) : &PL_sv_undef); |
Branch: 2 branches
| Branch | True | False | Total |
| XPUSHs(val ? context_vars_out(aTHX_ val, context_vars_path_plus(aTHX_ path, key)) : &PL_sv_undef); |
0 |
4153 |
4153 |
| XPUSHs(val ? context_vars_out(aTHX_ val, context_vars_path_plus(aTHX_ path, key)) : &PL_sv_undef); |
4148 |
5 |
4153 |
|
| 18 |
|
| } |
| 19 |
|
| |
| 20 |
|
| void |
| 21 |
|
| STORE(self, key, value) |
| 22 |
|
| SV *self |
| 23 |
|
| SV *key |
| 24 |
|
| SV *value |
| 25 |
|
| CODE: |
| 26 |
|
| { |
| 27 |
4059 |
| AV *path = context_vars_proxy_path(aTHX_ self); |
| 28 |
4059 |
| AV *at = context_vars_path_plus(aTHX_ path, key); |
| 29 |
|
| SV *conv; |
| 30 |
4059 |
| SAVEFREESV((SV *)at); |
| 31 |
4059 |
| conv = context_vars_in(aTHX_ value); |
| 32 |
4059 |
▶ | context_vars_path_put(aTHX_ at, conv ? conv : newSVsv(value)); |
Branch: 1 branch
| Branch | True | False | Total |
| context_vars_path_put(aTHX_ at, conv ? conv : newSVsv(value)); |
4045 |
14 |
4059 |
|
| 33 |
4059 |
| context_vars_tie_fresh(aTHX_ value, at); |
| 34 |
|
| } |
| 35 |
|
| |
| 36 |
|
| void |
| 37 |
|
| DELETE(self, key) |
| 38 |
|
| SV *self |
| 39 |
|
| SV *key |
| 40 |
|
| PPCODE: |
| 41 |
|
| { |
| 42 |
3 |
| AV *path = context_vars_proxy_path(aTHX_ self); |
| 43 |
3 |
| SV *node = context_vars_path_get(aTHX_ path); |
| 44 |
3 |
▶ | SV *old = node ? context_vars_node_get(aTHX_ node, key) : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| SV *old = node ? context_vars_node_get(aTHX_ node, key) : NULL; |
3 |
0 |
3 |
|
| 45 |
3 |
▶ | SV *ret = old ? sv_2mortal(context_vars_plain(aTHX_ old)) : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV *ret = old ? sv_2mortal(context_vars_plain(aTHX_ old)) : &PL_sv_undef; |
3 |
0 |
3 |
|
| 46 |
3 |
▶ | if (old) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (old) { |
3 |
0 |
3 |
|
| 47 |
3 |
| AV *at = context_vars_path_plus(aTHX_ path, key); |
| 48 |
3 |
| SAVEFREESV((SV *)at); |
| 49 |
3 |
| context_vars_path_put(aTHX_ at, NULL); |
| 50 |
|
| } |
| 51 |
3 |
▶ | XPUSHs(ret); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(ret); |
0 |
3 |
3 |
|
| 52 |
|
| } |
| 53 |
|
| |
| 54 |
|
| void |
| 55 |
|
| CLEAR(self) |
| 56 |
|
| SV *self |
| 57 |
|
| CODE: |
| 58 |
|
| { |
| 59 |
22 |
| AV *path = context_vars_proxy_path(aTHX_ self); |
| 60 |
22 |
| context_vars_path_put(aTHX_ path, context_vars_map_sv(aTHX_ (CONTEXT_VARS_HAMT->map_new)(aTHX))); |
| 61 |
|
| } |
| 62 |
|
| |
| 63 |
|
| int |
| 64 |
|
| EXISTS(self, key) |
| 65 |
|
| SV *self |
| 66 |
|
| SV *key |
| 67 |
|
| CODE: |
| 68 |
|
| { |
| 69 |
37 |
| AV *path = context_vars_proxy_path(aTHX_ self); |
| 70 |
37 |
| SV *node = context_vars_path_get(aTHX_ path); |
| 71 |
|
| STRLEN klen; |
| 72 |
37 |
| const char *k = SvPV(key, klen); |
| 73 |
74 |
▶ | RETVAL = context_vars_is_map(aTHX_ node) |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = context_vars_is_map(aTHX_ node) |
0 |
37 |
37 |
|
| 74 |
37 |
| ? (CONTEXT_VARS_HAMT->map_has)(aTHX_ (CONTEXT_VARS_HAMT->map_from_sv)(aTHX_ node), |
| 75 |
37 |
| k, klen, SvUTF8(key) ? 1 : 0) |
| 76 |
37 |
▶ | : 0; |
Branch: 1 branch
| Branch | True | False | Total |
| : 0; |
37 |
0 |
37 |
|
| 77 |
|
| } |
| 78 |
|
| OUTPUT: |
| 79 |
|
| RETVAL |
| 80 |
|
| |
| 81 |
|
| # Iteration walks the keys as they were when it began. |
| 82 |
|
| void |
| 83 |
|
| FIRSTKEY(self) |
| 84 |
|
| SV *self |
| 85 |
|
| PPCODE: |
| 86 |
|
| { |
| 87 |
53 |
| AV *state = (AV *)SvRV(self); |
| 88 |
53 |
| AV *path = context_vars_proxy_path(aTHX_ self); |
| 89 |
53 |
| SV *node = context_vars_path_get(aTHX_ path); |
| 90 |
53 |
| AV *keys = newAV(); |
| 91 |
|
| SV *first; |
| 92 |
53 |
▶ | if (context_vars_is_map(aTHX_ node)) |
Branch: 1 branch
| Branch | True | False | Total |
| if (context_vars_is_map(aTHX_ node)) |
53 |
0 |
53 |
|
| 93 |
53 |
| (CONTEXT_VARS_HAMT->map_walk)(aTHX_ (CONTEXT_VARS_HAMT->map_from_sv)(aTHX_ node), |
| 94 |
|
| context_vars_keys_cb, keys); |
| 95 |
53 |
| av_store(state, 1, newRV_noinc((SV *)keys)); |
| 96 |
53 |
| first = av_shift(keys); |
| 97 |
53 |
▶ | XPUSHs(first == &PL_sv_undef ? first : sv_2mortal(first)); |
Branch: 2 branches
| Branch | True | False | Total |
| XPUSHs(first == &PL_sv_undef ? first : sv_2mortal(first)); |
0 |
53 |
53 |
| XPUSHs(first == &PL_sv_undef ? first : sv_2mortal(first)); |
51 |
2 |
53 |
|
| 98 |
|
| } |
| 99 |
|
| |
| 100 |
|
| void |
| 101 |
|
| NEXTKEY(self, last) |
| 102 |
|
| SV *self |
| 103 |
|
| SV *last |
| 104 |
|
| PPCODE: |
| 105 |
|
| { |
| 106 |
84 |
| SV **kp = av_fetch((AV *)SvRV(self), 1, 0); |
| 107 |
84 |
▶ | SV *next = (kp && SvROK(*kp)) ? av_shift((AV *)SvRV(*kp)) : &PL_sv_undef; |
Branch: 2 branches
| Branch | True | False | Total |
| SV *next = (kp && SvROK(*kp)) ? av_shift((AV *)SvRV(*kp)) : &PL_sv_undef; |
84 |
0 |
84 |
| SV *next = (kp && SvROK(*kp)) ? av_shift((AV *)SvRV(*kp)) : &PL_sv_undef; |
84 |
0 |
84 |
|
| 108 |
|
| PERL_UNUSED_VAR(last); |
| 109 |
84 |
▶ | XPUSHs(next == &PL_sv_undef ? next : sv_2mortal(next)); |
Branch: 2 branches
| Branch | True | False | Total |
| XPUSHs(next == &PL_sv_undef ? next : sv_2mortal(next)); |
0 |
84 |
84 |
| XPUSHs(next == &PL_sv_undef ? next : sv_2mortal(next)); |
33 |
51 |
84 |
|
| 110 |
|
| } |
| 111 |
|
| |
| 112 |
|
| IV |
| 113 |
|
| SCALAR(self) |
| 114 |
|
| SV *self |
| 115 |
|
| CODE: |
| 116 |
|
| { |
| 117 |
1 |
| SV *node = context_vars_path_get(aTHX_ context_vars_proxy_path(aTHX_ self)); |
| 118 |
2 |
▶ | RETVAL = context_vars_is_map(aTHX_ node) |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = context_vars_is_map(aTHX_ node) |
0 |
1 |
1 |
|
| 119 |
1 |
| ? (IV)(CONTEXT_VARS_HAMT->map_count)(aTHX_ (CONTEXT_VARS_HAMT->map_from_sv)(aTHX_ node)) |
| 120 |
2 |
▶ | : 0; |
Branch: 1 branch
| Branch | True | False | Total |
| : 0; |
1 |
0 |
1 |
|
| 121 |
|
| } |
| 122 |
|
| OUTPUT: |
| 123 |
|
| RETVAL |
| 124 |
|
| |
| 125 |
|
| MODULE = Context::Vars PACKAGE = Context::Vars::Array |
| 126 |
|
| |
| 127 |
|
| IV |
| 128 |
|
| FETCHSIZE(self) |
| 129 |
|
| SV *self |
| 130 |
|
| CODE: |
| 131 |
106 |
▶ | RETVAL = (IV)context_vars_vec_len(aTHX_ context_vars_path_get(aTHX_ context_vars_proxy_path(aTHX_ self))); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = (IV)context_vars_vec_len(aTHX_ context_vars_path_get(aTHX_ context_vars_proxy_path(aTHX_ self))); |
0 |
106 |
106 |
|
| 132 |
|
| OUTPUT: |
| 133 |
|
| RETVAL |
| 134 |
|
| |
| 135 |
|
| void |
| 136 |
|
| FETCH(self, index) |
| 137 |
|
| SV *self |
| 138 |
|
| SV *index |
| 139 |
|
| PPCODE: |
| 140 |
|
| { |
| 141 |
88 |
| AV *path = context_vars_proxy_path(aTHX_ self); |
| 142 |
88 |
| SV *node = context_vars_path_get(aTHX_ path); |
| 143 |
88 |
▶ | SV *val = context_vars_is_vec(aTHX_ node) ? context_vars_node_get(aTHX_ node, index) : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| SV *val = context_vars_is_vec(aTHX_ node) ? context_vars_node_get(aTHX_ node, index) : NULL; |
88 |
0 |
88 |
|
| 144 |
88 |
▶ | XPUSHs(val ? context_vars_out(aTHX_ val, context_vars_path_plus(aTHX_ path, index)) : &PL_sv_undef); |
Branch: 2 branches
| Branch | True | False | Total |
| XPUSHs(val ? context_vars_out(aTHX_ val, context_vars_path_plus(aTHX_ path, index)) : &PL_sv_undef); |
0 |
88 |
88 |
| XPUSHs(val ? context_vars_out(aTHX_ val, context_vars_path_plus(aTHX_ path, index)) : &PL_sv_undef); |
88 |
0 |
88 |
|
| 145 |
|
| } |
| 146 |
|
| |
| 147 |
|
| void |
| 148 |
|
| STORE(self, index, value) |
| 149 |
|
| SV *self |
| 150 |
|
| SV *index |
| 151 |
|
| SV *value |
| 152 |
|
| CODE: |
| 153 |
|
| { |
| 154 |
23 |
| AV *path = context_vars_proxy_path(aTHX_ self); |
| 155 |
23 |
| AV *at = context_vars_path_plus(aTHX_ path, index); |
| 156 |
|
| SV *conv; |
| 157 |
23 |
| SAVEFREESV((SV *)at); |
| 158 |
23 |
| conv = context_vars_in(aTHX_ value); |
| 159 |
23 |
| context_vars_vec_ensure(aTHX_ path); |
| 160 |
23 |
▶ | context_vars_path_put(aTHX_ at, conv ? conv : newSVsv(value)); |
Branch: 1 branch
| Branch | True | False | Total |
| context_vars_path_put(aTHX_ at, conv ? conv : newSVsv(value)); |
22 |
1 |
23 |
|
| 161 |
23 |
| context_vars_tie_fresh(aTHX_ value, at); |
| 162 |
|
| } |
| 163 |
|
| |
| 164 |
|
| int |
| 165 |
|
| EXISTS(self, index) |
| 166 |
|
| SV *self |
| 167 |
|
| SV *index |
| 168 |
|
| CODE: |
| 169 |
|
| { |
| 170 |
2 |
| IV i = SvIV(index); |
| 171 |
2 |
▶ | RETVAL = i >= 0 && (size_t)i < context_vars_vec_len(aTHX_ |
Branch: 3 branches
| Branch | True | False | Total |
| RETVAL = i >= 0 && (size_t)i < context_vars_vec_len(aTHX_ |
2 |
0 |
2 |
| RETVAL = i >= 0 && (size_t)i < context_vars_vec_len(aTHX_ |
2 |
0 |
2 |
| RETVAL = i >= 0 && (size_t)i < context_vars_vec_len(aTHX_ |
0 |
2 |
2 |
|
| 172 |
|
| context_vars_path_get(aTHX_ context_vars_proxy_path(aTHX_ self))); |
| 173 |
|
| } |
| 174 |
|
| OUTPUT: |
| 175 |
|
| RETVAL |
| 176 |
|
| |
| 177 |
|
| void |
| 178 |
|
| DELETE(self, index) |
| 179 |
|
| SV *self |
| 180 |
|
| SV *index |
| 181 |
|
| PPCODE: |
| 182 |
|
| { |
| 183 |
0 |
| AV *path = context_vars_proxy_path(aTHX_ self); |
| 184 |
0 |
| SV *node = context_vars_path_get(aTHX_ path); |
| 185 |
0 |
▶ | SV *old = context_vars_is_vec(aTHX_ node) ? context_vars_node_get(aTHX_ node, index) : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| SV *old = context_vars_is_vec(aTHX_ node) ? context_vars_node_get(aTHX_ node, index) : NULL; |
0 |
0 |
0 |
|
| 186 |
0 |
▶ | SV *ret = old ? sv_2mortal(context_vars_plain(aTHX_ old)) : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV *ret = old ? sv_2mortal(context_vars_plain(aTHX_ old)) : &PL_sv_undef; |
0 |
0 |
0 |
|
| 187 |
0 |
▶ | if (old) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (old) { |
0 |
0 |
0 |
|
| 188 |
0 |
| AV *at = context_vars_path_plus(aTHX_ path, index); |
| 189 |
0 |
| SAVEFREESV((SV *)at); |
| 190 |
0 |
| context_vars_path_put(aTHX_ at, newSV(0)); |
| 191 |
|
| } |
| 192 |
0 |
▶ | XPUSHs(ret); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(ret); |
0 |
0 |
0 |
|
| 193 |
|
| } |
| 194 |
|
| |
| 195 |
|
| void |
| 196 |
|
| CLEAR(self) |
| 197 |
|
| SV *self |
| 198 |
|
| CODE: |
| 199 |
10 |
| context_vars_path_put(aTHX_ context_vars_proxy_path(aTHX_ self), |
| 200 |
10 |
| context_vars_vec_sv(aTHX_ (CONTEXT_VARS_HAMT->vec_new)(aTHX))); |
| 201 |
|
| |
| 202 |
|
| void |
| 203 |
|
| EXTEND(self, n) |
| 204 |
|
| SV *self |
| 205 |
|
| SV *n |
| 206 |
|
| CODE: |
| 207 |
|
| PERL_UNUSED_VAR(self); |
| 208 |
|
| PERL_UNUSED_VAR(n); |
| 209 |
|
| |
| 210 |
|
| void |
| 211 |
|
| STORESIZE(self, n) |
| 212 |
|
| SV *self |
| 213 |
|
| IV n |
| 214 |
|
| CODE: |
| 215 |
|
| { |
| 216 |
1 |
| AV *path = context_vars_proxy_path(aTHX_ self); |
| 217 |
1 |
| SV *node = context_vars_path_get(aTHX_ path); |
| 218 |
1 |
| hamt_vec *v = context_vars_vec_dup(aTHX_ node); |
| 219 |
1 |
| size_t want = n < 0 ? 0 : (size_t)n; |
| 220 |
1 |
| size_t have = (CONTEXT_VARS_HAMT->vec_count)(aTHX_ v); |
| 221 |
1 |
▶ | if (want < have) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (want < have) { |
1 |
0 |
1 |
|
| 222 |
1 |
| int st = HAMT_ABI_OK; |
| 223 |
1 |
| hamt_vec *cut = (CONTEXT_VARS_HAMT->vec_slice)(aTHX_ v, 0, want, &st); |
| 224 |
1 |
| (CONTEXT_VARS_HAMT->vec_release)(aTHX_ v); |
| 225 |
1 |
▶ | if (!cut) croak("Context::Vars: out of memory"); |
Branch: 1 branch
| Branch | True | False | Total |
| if (!cut) croak("Context::Vars: out of memory"); |
0 |
1 |
1 |
|
| 226 |
1 |
| v = cut; |
| 227 |
|
| } |
| 228 |
1 |
▶ | while ((CONTEXT_VARS_HAMT->vec_count)(aTHX_ v) < want) |
Branch: 1 branch
| Branch | True | False | Total |
| while ((CONTEXT_VARS_HAMT->vec_count)(aTHX_ v) < want) |
0 |
1 |
1 |
|
| 229 |
0 |
| context_vars_ok((CONTEXT_VARS_HAMT->vec_push)(aTHX_ v, &PL_sv_undef)); |
| 230 |
1 |
| context_vars_path_put(aTHX_ path, context_vars_vec_sv(aTHX_ v)); |
| 231 |
|
| } |
| 232 |
|
| |
| 233 |
|
| IV |
| 234 |
|
| PUSH(self, ...) |
| 235 |
|
| SV *self |
| 236 |
|
| CODE: |
| 237 |
|
| { |
| 238 |
12 |
| AV *path = context_vars_proxy_path(aTHX_ self); |
| 239 |
12 |
| hamt_vec *v = context_vars_vec_dup(aTHX_ context_vars_path_get(aTHX_ path)); |
| 240 |
|
| I32 i; |
| 241 |
25 |
▶ | for (i = 1; i < items; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 1; i < items; i++) { |
13 |
12 |
25 |
|
| 242 |
13 |
| SV *conv = context_vars_in(aTHX_ ST(i)); |
| 243 |
13 |
▶ | context_vars_ok((CONTEXT_VARS_HAMT->vec_push)(aTHX_ v, conv ? conv : ST(i))); |
Branch: 1 branch
| Branch | True | False | Total |
| context_vars_ok((CONTEXT_VARS_HAMT->vec_push)(aTHX_ v, conv ? conv : ST(i))); |
13 |
0 |
13 |
|
| 244 |
13 |
▶ | if (conv) SvREFCNT_dec(conv); |
Branch: 1 branch
| Branch | True | False | Total |
| if (conv) SvREFCNT_dec(conv); |
0 |
13 |
13 |
|
| 245 |
|
| } |
| 246 |
12 |
| RETVAL = (IV)(CONTEXT_VARS_HAMT->vec_count)(aTHX_ v); |
| 247 |
12 |
| context_vars_path_put(aTHX_ path, context_vars_vec_sv(aTHX_ v)); |
| 248 |
|
| } |
| 249 |
|
| OUTPUT: |
| 250 |
|
| RETVAL |
| 251 |
|
| |
| 252 |
|
| void |
| 253 |
|
| POP(self) |
| 254 |
|
| SV *self |
| 255 |
|
| PPCODE: |
| 256 |
|
| { |
| 257 |
2 |
| AV *path = context_vars_proxy_path(aTHX_ self); |
| 258 |
2 |
| SV *node = context_vars_path_get(aTHX_ path); |
| 259 |
2 |
| size_t n = context_vars_vec_len(aTHX_ node); |
| 260 |
2 |
| SV *ret = &PL_sv_undef; |
| 261 |
2 |
▶ | if (n) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (n) { |
2 |
0 |
2 |
|
| 262 |
|
| hamt_vec *v; |
| 263 |
2 |
| ret = sv_2mortal(context_vars_plain(aTHX_ context_vars_node_get(aTHX_ node, sv_2mortal(newSVuv(n - 1))))); |
| 264 |
2 |
| v = context_vars_vec_dup(aTHX_ node); |
| 265 |
2 |
| context_vars_ok((CONTEXT_VARS_HAMT->vec_pop)(aTHX_ v)); |
| 266 |
2 |
| context_vars_path_put(aTHX_ path, context_vars_vec_sv(aTHX_ v)); |
| 267 |
|
| } |
| 268 |
2 |
▶ | XPUSHs(ret); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(ret); |
0 |
2 |
2 |
|
| 269 |
|
| } |
| 270 |
|
| |
| 271 |
|
| void |
| 272 |
|
| SHIFT(self) |
| 273 |
|
| SV *self |
| 274 |
|
| PPCODE: |
| 275 |
|
| { |
| 276 |
2 |
| AV *path = context_vars_proxy_path(aTHX_ self); |
| 277 |
2 |
| SV *node = context_vars_path_get(aTHX_ path); |
| 278 |
2 |
| SV *ret = &PL_sv_undef; |
| 279 |
2 |
▶ | if (context_vars_vec_len(aTHX_ node)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (context_vars_vec_len(aTHX_ node)) { |
2 |
0 |
2 |
|
| 280 |
2 |
| int st = HAMT_ABI_OK; |
| 281 |
|
| hamt_vec *rest; |
| 282 |
2 |
| ret = sv_2mortal(context_vars_plain(aTHX_ context_vars_node_get(aTHX_ node, sv_2mortal(newSViv(0))))); |
| 283 |
2 |
| rest = (CONTEXT_VARS_HAMT->vec_remove)(aTHX_ (CONTEXT_VARS_HAMT->vec_from_sv)(aTHX_ node), 0, 1, &st); |
| 284 |
2 |
▶ | if (!rest) croak("Context::Vars: out of memory"); |
Branch: 1 branch
| Branch | True | False | Total |
| if (!rest) croak("Context::Vars: out of memory"); |
0 |
2 |
2 |
|
| 285 |
2 |
| context_vars_path_put(aTHX_ path, context_vars_vec_sv(aTHX_ rest)); |
| 286 |
|
| } |
| 287 |
2 |
▶ | XPUSHs(ret); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(ret); |
0 |
2 |
2 |
|
| 288 |
|
| } |
| 289 |
|
| |
| 290 |
|
| IV |
| 291 |
|
| UNSHIFT(self, ...) |
| 292 |
|
| SV *self |
| 293 |
|
| CODE: |
| 294 |
|
| { |
| 295 |
2 |
| AV *path = context_vars_proxy_path(aTHX_ self); |
| 296 |
2 |
| SV *node = context_vars_path_get(aTHX_ path); |
| 297 |
2 |
| hamt_vec *mid = context_vars_vec_of_args(aTHX_ &ST(1), items - 1); |
| 298 |
2 |
| hamt_vec *cur = context_vars_vec_dup(aTHX_ node); |
| 299 |
2 |
| int st = HAMT_ABI_OK; |
| 300 |
2 |
| hamt_vec *joined = (CONTEXT_VARS_HAMT->vec_insert)(aTHX_ cur, 0, mid, &st); |
| 301 |
2 |
| (CONTEXT_VARS_HAMT->vec_release)(aTHX_ cur); |
| 302 |
2 |
| (CONTEXT_VARS_HAMT->vec_release)(aTHX_ mid); |
| 303 |
2 |
▶ | if (!joined) croak("Context::Vars: out of memory"); |
Branch: 1 branch
| Branch | True | False | Total |
| if (!joined) croak("Context::Vars: out of memory"); |
0 |
2 |
2 |
|
| 304 |
2 |
| RETVAL = (IV)(CONTEXT_VARS_HAMT->vec_count)(aTHX_ joined); |
| 305 |
2 |
| context_vars_path_put(aTHX_ path, context_vars_vec_sv(aTHX_ joined)); |
| 306 |
|
| } |
| 307 |
|
| OUTPUT: |
| 308 |
|
| RETVAL |
| 309 |
|
| |
| 310 |
|
| void |
| 311 |
|
| SPLICE(self, ...) |
| 312 |
|
| SV *self |
| 313 |
|
| PPCODE: |
| 314 |
|
| { |
| 315 |
2 |
| AV *path = context_vars_proxy_path(aTHX_ self); |
| 316 |
2 |
| SV *node = context_vars_path_get(aTHX_ path); |
| 317 |
2 |
| IV size = (IV)context_vars_vec_len(aTHX_ node); |
| 318 |
2 |
▶ | IV off = items > 1 && SvOK(ST(1)) ? SvIV(ST(1)) : 0; |
Branch: 2 branches
| Branch | True | False | Total |
| IV off = items > 1 && SvOK(ST(1)) ? SvIV(ST(1)) : 0; |
2 |
0 |
2 |
| IV off = items > 1 && SvOK(ST(1)) ? SvIV(ST(1)) : 0; |
2 |
0 |
2 |
|
| 319 |
|
| IV len; |
| 320 |
2 |
| I32 i, nnew = items > 3 ? items - 3 : 0; |
| 321 |
|
| hamt_vec *cur, *cut, *mid, *joined; |
| 322 |
2 |
| AV *gone = (AV *)sv_2mortal((SV *)newAV()); |
| 323 |
2 |
| int st = HAMT_ABI_OK; |
| 324 |
2 |
| I32 gimme = GIMME_V; |
| 325 |
|
| |
| 326 |
2 |
▶ | if (off < 0) off += size; |
Branch: 1 branch
| Branch | True | False | Total |
| if (off < 0) off += size; |
0 |
2 |
2 |
|
| 327 |
2 |
▶ | if (off < 0) croak("Modification of non-creatable array value attempted, subscript %" IVdf, off - size); |
Branch: 1 branch
| Branch | True | False | Total |
| if (off < 0) croak("Modification of non-creatable array value attempted, subscript %" IVdf, off - size); |
0 |
2 |
2 |
|
| 328 |
2 |
▶ | if (off > size) off = size; |
Branch: 1 branch
| Branch | True | False | Total |
| if (off > size) off = size; |
0 |
2 |
2 |
|
| 329 |
2 |
▶ | len = items > 2 && SvOK(ST(2)) ? SvIV(ST(2)) : size - off; |
Branch: 2 branches
| Branch | True | False | Total |
| len = items > 2 && SvOK(ST(2)) ? SvIV(ST(2)) : size - off; |
2 |
0 |
2 |
| len = items > 2 && SvOK(ST(2)) ? SvIV(ST(2)) : size - off; |
2 |
0 |
2 |
|
| 330 |
2 |
▶ | if (len < 0) len = size - off + len; |
Branch: 1 branch
| Branch | True | False | Total |
| if (len < 0) len = size - off + len; |
0 |
2 |
2 |
|
| 331 |
2 |
▶ | if (len < 0) len = 0; |
Branch: 1 branch
| Branch | True | False | Total |
| if (len < 0) len = 0; |
0 |
2 |
2 |
|
| 332 |
2 |
▶ | if (off + len > size) len = size - off; |
Branch: 1 branch
| Branch | True | False | Total |
| if (off + len > size) len = size - off; |
0 |
2 |
2 |
|
| 333 |
|
| |
| 334 |
5 |
▶ | for (i = 0; i < len; i++) |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < len; i++) |
3 |
2 |
5 |
|
| 335 |
3 |
| av_push(gone, context_vars_plain(aTHX_ context_vars_node_get(aTHX_ node, sv_2mortal(newSViv(off + i))))); |
| 336 |
|
| |
| 337 |
2 |
| mid = context_vars_vec_of_args(aTHX_ &ST(3), nnew); |
| 338 |
2 |
| cur = context_vars_vec_dup(aTHX_ node); |
| 339 |
2 |
| cut = (CONTEXT_VARS_HAMT->vec_remove)(aTHX_ cur, (size_t)off, (size_t)len, &st); |
| 340 |
2 |
| (CONTEXT_VARS_HAMT->vec_release)(aTHX_ cur); |
| 341 |
2 |
▶ | if (!cut) croak("Context::Vars: out of memory"); |
Branch: 1 branch
| Branch | True | False | Total |
| if (!cut) croak("Context::Vars: out of memory"); |
0 |
2 |
2 |
|
| 342 |
2 |
▶ | joined = nnew ? (CONTEXT_VARS_HAMT->vec_insert)(aTHX_ cut, (size_t)off, mid, &st) : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| joined = nnew ? (CONTEXT_VARS_HAMT->vec_insert)(aTHX_ cut, (size_t)off, mid, &st) : NULL; |
1 |
1 |
2 |
|
| 343 |
2 |
▶ | if (nnew) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (nnew) { |
1 |
1 |
2 |
|
| 344 |
1 |
| (CONTEXT_VARS_HAMT->vec_release)(aTHX_ cut); |
| 345 |
1 |
▶ | if (!joined) croak("Context::Vars: out of memory"); |
Branch: 1 branch
| Branch | True | False | Total |
| if (!joined) croak("Context::Vars: out of memory"); |
0 |
1 |
1 |
|
| 346 |
|
| } |
| 347 |
1 |
| else joined = cut; |
| 348 |
2 |
| (CONTEXT_VARS_HAMT->vec_release)(aTHX_ mid); |
| 349 |
2 |
| context_vars_path_put(aTHX_ path, context_vars_vec_sv(aTHX_ joined)); |
| 350 |
|
| |
| 351 |
2 |
▶ | if (gimme == G_ARRAY) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (gimme == G_ARRAY) { |
1 |
1 |
2 |
|
| 352 |
1 |
▶ | EXTEND(SP, len); |
Branch: 2 branches
| Branch | True | False | Total |
| EXTEND(SP, len); |
1 |
0 |
1 |
| EXTEND(SP, len); |
0 |
1 |
1 |
|
| 353 |
3 |
▶ | for (i = 0; i < len; i++) PUSHs(*av_fetch(gone, i, 0)); |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < len; i++) PUSHs(*av_fetch(gone, i, 0)); |
2 |
1 |
3 |
|
| 354 |
|
| } |
| 355 |
|
| else { |
| 356 |
1 |
▶ | XPUSHs(len ? *av_fetch(gone, len - 1, 0) : &PL_sv_undef); |
Branch: 2 branches
| Branch | True | False | Total |
| XPUSHs(len ? *av_fetch(gone, len - 1, 0) : &PL_sv_undef); |
0 |
1 |
1 |
| XPUSHs(len ? *av_fetch(gone, len - 1, 0) : &PL_sv_undef); |
1 |
0 |
1 |
|
| 357 |
|
| } |
| 358 |
|
| } |