| 1 |
|
| /* |
| 2 |
|
| * Parser-internal AST runtime layer only. |
| 3 |
|
| * |
| 4 |
|
| * Responsibility: parser AST helpers for lazy arrays, |
| 5 |
|
| * location context management, and token-driven AST node location assignment. |
| 6 |
|
| * |
| 7 |
|
| * This header is not part of the runtime/VM mainline. It exists only because |
| 8 |
|
| * the public parser surface still returns graphql-perl-compatible AST while |
| 9 |
|
| * some parser internals continue to use parser-shaped node helpers. |
| 10 |
|
| */ |
| 11 |
|
| static HV * |
| 12 |
0 |
| gql_parser_node_hv(SV *node_sv) { |
| 13 |
0 |
▶ | if (!node_sv || !SvROK(node_sv) || SvTYPE(SvRV(node_sv)) != SVt_PVHV) { |
Branch: 3 branches
| Branch | True | False | Total |
| if (!node_sv || !SvROK(node_sv) || SvTYPE(SvRV(node_sv)) != SVt_PVHV) { |
0 |
0 |
0 |
| if (!node_sv || !SvROK(node_sv) || SvTYPE(SvRV(node_sv)) != SVt_PVHV) { |
0 |
0 |
0 |
| if (!node_sv || !SvROK(node_sv) || SvTYPE(SvRV(node_sv)) != SVt_PVHV) { |
0 |
0 |
0 |
|
| 14 |
0 |
| return NULL; |
| 15 |
|
| } |
| 16 |
0 |
| return (HV *)SvRV(node_sv); |
| 17 |
|
| } |
| 18 |
|
| |
| 19 |
|
| static SV * |
| 20 |
0 |
| gql_parser_fetch_sv(HV *hv, const char *key) { |
| 21 |
|
| SV **svp; |
| 22 |
0 |
▶ | if (!hv) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!hv) { |
0 |
0 |
0 |
|
| 23 |
0 |
| return NULL; |
| 24 |
|
| } |
| 25 |
0 |
| svp = hv_fetch(hv, key, (I32)strlen(key), 0); |
| 26 |
0 |
▶ | return svp ? *svp : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| return svp ? *svp : NULL; |
0 |
0 |
0 |
|
| 27 |
|
| } |
| 28 |
|
| |
| 29 |
|
| static AV * |
| 30 |
0 |
| gql_parser_fetch_array(HV *hv, const char *key) { |
| 31 |
0 |
| SV *sv = gql_parser_fetch_sv(hv, key); |
| 32 |
|
| AV *av; |
| 33 |
|
| MAGIC *mg; |
| 34 |
0 |
▶ | if (!sv || !SvROK(sv) || SvTYPE(SvRV(sv)) != SVt_PVAV) { |
Branch: 3 branches
| Branch | True | False | Total |
| if (!sv || !SvROK(sv) || SvTYPE(SvRV(sv)) != SVt_PVAV) { |
0 |
0 |
0 |
| if (!sv || !SvROK(sv) || SvTYPE(SvRV(sv)) != SVt_PVAV) { |
0 |
0 |
0 |
| if (!sv || !SvROK(sv) || SvTYPE(SvRV(sv)) != SVt_PVAV) { |
0 |
0 |
0 |
|
| 35 |
0 |
| return NULL; |
| 36 |
|
| } |
| 37 |
0 |
| av = (AV *)SvRV(sv); |
| 38 |
0 |
| mg = mg_find((SV *)av, PERL_MAGIC_tied); |
| 39 |
0 |
▶ | if (mg && mg->mg_obj) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (mg && mg->mg_obj) { |
0 |
0 |
0 |
| if (mg && mg->mg_obj) { |
0 |
0 |
0 |
|
| 40 |
0 |
| HV *tied_hv = NULL; |
| 41 |
0 |
| SV *data_sv = NULL; |
| 42 |
0 |
| SV *state_sv = NULL; |
| 43 |
0 |
| SV *ptr_sv = NULL; |
| 44 |
0 |
| SV *kind_sv = NULL; |
| 45 |
|
| |
| 46 |
0 |
▶ | if (SvROK(mg->mg_obj) && SvTYPE(SvRV(mg->mg_obj)) == SVt_PVHV) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvROK(mg->mg_obj) && SvTYPE(SvRV(mg->mg_obj)) == SVt_PVHV) { |
0 |
0 |
0 |
| if (SvROK(mg->mg_obj) && SvTYPE(SvRV(mg->mg_obj)) == SVt_PVHV) { |
0 |
0 |
0 |
|
| 47 |
0 |
| tied_hv = (HV *)SvRV(mg->mg_obj); |
| 48 |
|
| /* These hash keys are part of the XS fast-path contract with |
| 49 |
|
| * GraphQL::Houtou::XS::LazyArray::*::TIEARRAY. Keep tests in sync if |
| 50 |
|
| * they ever change. */ |
| 51 |
0 |
| data_sv = gql_parser_fetch_sv(tied_hv, "data"); |
| 52 |
0 |
▶ | if (data_sv && SvROK(data_sv) && SvTYPE(SvRV(data_sv)) == SVt_PVAV) { |
Branch: 3 branches
| Branch | True | False | Total |
| if (data_sv && SvROK(data_sv) && SvTYPE(SvRV(data_sv)) == SVt_PVAV) { |
0 |
0 |
0 |
| if (data_sv && SvROK(data_sv) && SvTYPE(SvRV(data_sv)) == SVt_PVAV) { |
0 |
0 |
0 |
| if (data_sv && SvROK(data_sv) && SvTYPE(SvRV(data_sv)) == SVt_PVAV) { |
0 |
0 |
0 |
|
| 53 |
0 |
| return (AV *)SvRV(data_sv); |
| 54 |
|
| } |
| 55 |
0 |
| state_sv = gql_parser_fetch_sv(tied_hv, "state"); |
| 56 |
0 |
| ptr_sv = gql_parser_fetch_sv(tied_hv, "ptr"); |
| 57 |
0 |
| kind_sv = gql_parser_fetch_sv(tied_hv, "kind"); |
| 58 |
0 |
▶ | if (state_sv && ptr_sv && kind_sv && SvIOK(ptr_sv) && SvIOK(kind_sv)) { |
Branch: 5 branches
| Branch | True | False | Total |
| if (state_sv && ptr_sv && kind_sv && SvIOK(ptr_sv) && SvIOK(kind_sv)) { |
0 |
0 |
0 |
| if (state_sv && ptr_sv && kind_sv && SvIOK(ptr_sv) && SvIOK(kind_sv)) { |
0 |
0 |
0 |
| if (state_sv && ptr_sv && kind_sv && SvIOK(ptr_sv) && SvIOK(kind_sv)) { |
0 |
0 |
0 |
| if (state_sv && ptr_sv && kind_sv && SvIOK(ptr_sv) && SvIOK(kind_sv)) { |
0 |
0 |
0 |
| if (state_sv && ptr_sv && kind_sv && SvIOK(ptr_sv) && SvIOK(kind_sv)) { |
0 |
0 |
0 |
|
| 59 |
0 |
| AV *materialized_av = gql_parser_materialize_lazy_array(aTHX_ state_sv, SvUV(ptr_sv), SvIV(kind_sv)); |
| 60 |
0 |
| hv_stores(tied_hv, "data", newRV_noinc((SV *)materialized_av)); |
| 61 |
0 |
| return materialized_av; |
| 62 |
|
| } |
| 63 |
|
| } |
| 64 |
|
| { |
| 65 |
0 |
| dSP; |
| 66 |
|
| SV *materialized_sv; |
| 67 |
|
| |
| 68 |
0 |
| ENTER; |
| 69 |
0 |
| SAVETMPS; |
| 70 |
0 |
▶ | PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP); |
0 |
0 |
0 |
|
| 71 |
0 |
▶ | XPUSHs(sv_2mortal(newSVsv(mg->mg_obj))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVsv(mg->mg_obj))); |
0 |
0 |
0 |
|
| 72 |
0 |
| PUTBACK; |
| 73 |
0 |
| call_method("_materialize", G_SCALAR); |
| 74 |
0 |
| SPAGAIN; |
| 75 |
0 |
| materialized_sv = newSVsv(POPs); |
| 76 |
0 |
| PUTBACK; |
| 77 |
0 |
▶ | FREETMPS; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; |
0 |
0 |
0 |
|
| 78 |
0 |
| LEAVE; |
| 79 |
|
| |
| 80 |
0 |
▶ | if (!materialized_sv || !SvROK(materialized_sv) || SvTYPE(SvRV(materialized_sv)) != SVt_PVAV) { |
Branch: 3 branches
| Branch | True | False | Total |
| if (!materialized_sv || !SvROK(materialized_sv) || SvTYPE(SvRV(materialized_sv)) != SVt_PVAV) { |
0 |
0 |
0 |
| if (!materialized_sv || !SvROK(materialized_sv) || SvTYPE(SvRV(materialized_sv)) != SVt_PVAV) { |
0 |
0 |
0 |
| if (!materialized_sv || !SvROK(materialized_sv) || SvTYPE(SvRV(materialized_sv)) != SVt_PVAV) { |
0 |
0 |
0 |
|
| 81 |
0 |
| SvREFCNT_dec(materialized_sv); |
| 82 |
0 |
| croak("parser lazy array materialization returned a non-array reference"); |
| 83 |
|
| } |
| 84 |
0 |
| av = (AV *)SvRV(materialized_sv); |
| 85 |
0 |
| SvREFCNT_dec(materialized_sv); |
| 86 |
|
| } |
| 87 |
|
| } |
| 88 |
0 |
| return av; |
| 89 |
|
| } |
| 90 |
|
| |
| 91 |
|
| static const char * |
| 92 |
0 |
| gql_parser_fetch_kind(HV *hv) { |
| 93 |
0 |
| SV *sv = gql_parser_fetch_sv(hv, "kind"); |
| 94 |
|
| STRLEN len; |
| 95 |
0 |
▶ | if (!sv) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!sv) { |
0 |
0 |
0 |
|
| 96 |
0 |
| return NULL; |
| 97 |
|
| } |
| 98 |
0 |
| return SvPV(sv, len); |
| 99 |
|
| } |
| 100 |
|
| |
| 101 |
|
| static const char * |
| 102 |
0 |
| gql_parser_name_value(SV *node_sv) { |
| 103 |
0 |
| HV *hv = gql_parser_node_hv(node_sv); |
| 104 |
|
| HV *name_hv; |
| 105 |
|
| SV *value_sv; |
| 106 |
|
| STRLEN len; |
| 107 |
|
| |
| 108 |
0 |
▶ | if (!hv) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!hv) { |
0 |
0 |
0 |
|
| 109 |
0 |
| return NULL; |
| 110 |
|
| } |
| 111 |
|
| |
| 112 |
0 |
| value_sv = gql_parser_fetch_sv(hv, "value"); |
| 113 |
0 |
▶ | if (value_sv && !SvROK(value_sv)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (value_sv && !SvROK(value_sv)) { |
0 |
0 |
0 |
| if (value_sv && !SvROK(value_sv)) { |
0 |
0 |
0 |
|
| 114 |
0 |
| return SvPV(value_sv, len); |
| 115 |
|
| } |
| 116 |
|
| |
| 117 |
0 |
| value_sv = gql_parser_fetch_sv(hv, "name"); |
| 118 |
0 |
▶ | if (value_sv && SvROK(value_sv) && SvTYPE(SvRV(value_sv)) == SVt_PVHV) { |
Branch: 3 branches
| Branch | True | False | Total |
| if (value_sv && SvROK(value_sv) && SvTYPE(SvRV(value_sv)) == SVt_PVHV) { |
0 |
0 |
0 |
| if (value_sv && SvROK(value_sv) && SvTYPE(SvRV(value_sv)) == SVt_PVHV) { |
0 |
0 |
0 |
| if (value_sv && SvROK(value_sv) && SvTYPE(SvRV(value_sv)) == SVt_PVHV) { |
0 |
0 |
0 |
|
| 119 |
0 |
| name_hv = (HV *)SvRV(value_sv); |
| 120 |
0 |
| value_sv = gql_parser_fetch_sv(name_hv, "value"); |
| 121 |
0 |
▶ | if (value_sv) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (value_sv) { |
0 |
0 |
0 |
|
| 122 |
0 |
| return SvPV(value_sv, len); |
| 123 |
|
| } |
| 124 |
|
| } |
| 125 |
|
| |
| 126 |
0 |
| return NULL; |
| 127 |
|
| } |
| 128 |
|
| |
| 129 |
|
| static SV * |
| 130 |
0 |
| gql_parser_find_named_node(AV *av, const char *name) { |
| 131 |
|
| I32 i; |
| 132 |
0 |
▶ | if (!av || !name) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!av || !name) { |
0 |
0 |
0 |
| if (!av || !name) { |
0 |
0 |
0 |
|
| 133 |
0 |
| return NULL; |
| 134 |
|
| } |
| 135 |
0 |
▶ | for (i = 0; i <= av_len(av); i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i <= av_len(av); i++) { |
0 |
0 |
0 |
|
| 136 |
0 |
| SV **svp = av_fetch(av, i, 0); |
| 137 |
|
| const char *node_name; |
| 138 |
0 |
▶ | if (!svp) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!svp) { |
0 |
0 |
0 |
|
| 139 |
0 |
| continue; |
| 140 |
|
| } |
| 141 |
0 |
| node_name = gql_parser_name_value(*svp); |
| 142 |
0 |
▶ | if (node_name && strcmp(node_name, name) == 0) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (node_name && strcmp(node_name, name) == 0) { |
0 |
0 |
0 |
| if (node_name && strcmp(node_name, name) == 0) { |
0 |
0 |
0 |
|
| 143 |
0 |
| return *svp; |
| 144 |
|
| } |
| 145 |
|
| } |
| 146 |
0 |
| return NULL; |
| 147 |
|
| } |
| 148 |
|
| |
| 149 |
|
| static SV * |
| 150 |
0 |
| gql_parser_find_named_node_sv(AV *av, SV *name_sv) { |
| 151 |
|
| STRLEN len; |
| 152 |
|
| const char *name; |
| 153 |
|
| |
| 154 |
0 |
▶ | if (!name_sv) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!name_sv) { |
0 |
0 |
0 |
|
| 155 |
0 |
| return NULL; |
| 156 |
|
| } |
| 157 |
0 |
| name = SvPV(name_sv, len); |
| 158 |
0 |
| return gql_parser_find_named_node(av, name); |
| 159 |
|
| } |
| 160 |
|
| |
| 161 |
|
| static SV * |
| 162 |
0 |
| gql_parser_new_loc_sv(pTHX_ IV line, IV column) { |
| 163 |
0 |
| HV *loc_hv = newHV(); |
| 164 |
0 |
| hv_ksplit(loc_hv, 2); |
| 165 |
0 |
| hv_stores(loc_hv, "line", newSViv(line)); |
| 166 |
0 |
| hv_stores(loc_hv, "column", newSViv(column)); |
| 167 |
0 |
| return newRV_noinc((SV *)loc_hv); |
| 168 |
|
| } |
| 169 |
|
| |
| 170 |
|
| static SV * |
| 171 |
0 |
| gql_parser_new_lazy_loc_sv(pTHX_ UV start) { |
| 172 |
0 |
| AV *loc_av = newAV(); |
| 173 |
0 |
| HV *stash = gv_stashpv("GraphQL::Houtou::Parser::Internal::LazyLoc", GV_ADD); |
| 174 |
|
| SV *loc_sv; |
| 175 |
|
| |
| 176 |
0 |
| av_push(loc_av, newSVuv(start)); |
| 177 |
0 |
| loc_sv = newRV_noinc((SV *)loc_av); |
| 178 |
0 |
| return sv_bless(loc_sv, stash); |
| 179 |
|
| } |
| 180 |
|
| |
| 181 |
|
| static int |
| 182 |
0 |
| gql_parser_magic_free_state(pTHX_ SV *sv, MAGIC *mg) { |
| 183 |
0 |
▶ | SV *state_sv = mg && mg->mg_ptr ? (SV *)mg->mg_ptr : NULL; |
Branch: 2 branches
| Branch | True | False | Total |
| SV *state_sv = mg && mg->mg_ptr ? (SV *)mg->mg_ptr : NULL; |
0 |
0 |
0 |
| SV *state_sv = mg && mg->mg_ptr ? (SV *)mg->mg_ptr : NULL; |
0 |
0 |
0 |
|
| 184 |
|
| |
| 185 |
0 |
▶ | if (state_sv) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (state_sv) { |
0 |
0 |
0 |
|
| 186 |
0 |
| SvREFCNT_dec(state_sv); |
| 187 |
0 |
| mg->mg_ptr = NULL; |
| 188 |
|
| } |
| 189 |
0 |
| return 0; |
| 190 |
|
| } |
| 191 |
|
| |
| 192 |
|
| static MGVTBL gql_parser_lazy_state_vtbl = { |
| 193 |
|
| NULL, |
| 194 |
|
| NULL, |
| 195 |
|
| NULL, |
| 196 |
|
| NULL, |
| 197 |
|
| gql_parser_magic_free_state |
| 198 |
|
| #if PERL_VERSION_GE(5, 15, 0) |
| 199 |
|
| ,NULL |
| 200 |
|
| ,NULL |
| 201 |
|
| ,NULL |
| 202 |
|
| #endif |
| 203 |
|
| }; |
| 204 |
|
| |
| 205 |
|
| static void |
| 206 |
0 |
| gql_parser_lazy_state_destroy(gql_parser_lazy_state_t *state) { |
| 207 |
0 |
▶ | if (!state) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!state) { |
0 |
0 |
0 |
|
| 208 |
0 |
| return; |
| 209 |
|
| } |
| 210 |
0 |
▶ | if (state->source_sv) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (state->source_sv) { |
0 |
0 |
0 |
|
| 211 |
0 |
| SvREFCNT_dec(state->source_sv); |
| 212 |
0 |
| state->source_sv = NULL; |
| 213 |
|
| } |
| 214 |
0 |
▶ | if (state->has_ctx) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (state->has_ctx) { |
0 |
0 |
0 |
|
| 215 |
0 |
| gql_parser_loc_context_destroy(&state->ctx); |
| 216 |
0 |
| state->has_ctx = 0; |
| 217 |
|
| } |
| 218 |
0 |
▶ | if (state->document) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (state->document) { |
0 |
0 |
0 |
|
| 219 |
0 |
| gql_ir_free_document(state->document); |
| 220 |
0 |
| state->document = NULL; |
| 221 |
|
| } |
| 222 |
0 |
| Safefree(state); |
| 223 |
|
| } |
| 224 |
|
| |
| 225 |
|
| static gql_parser_lazy_state_t * |
| 226 |
0 |
| gql_parser_lazy_state_from_sv(SV *state_sv) { |
| 227 |
|
| SV *inner_sv; |
| 228 |
|
| |
| 229 |
0 |
▶ | if (!state_sv || !SvROK(state_sv)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!state_sv || !SvROK(state_sv)) { |
0 |
0 |
0 |
| if (!state_sv || !SvROK(state_sv)) { |
0 |
0 |
0 |
|
| 230 |
0 |
| croak("expected GraphQL::Houtou::XS::LazyState object"); |
| 231 |
|
| } |
| 232 |
0 |
| inner_sv = SvRV(state_sv); |
| 233 |
0 |
▶ | if (!SvIOK(inner_sv)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!SvIOK(inner_sv)) { |
0 |
0 |
0 |
|
| 234 |
0 |
| croak("invalid GraphQL::Houtou::XS::LazyState payload"); |
| 235 |
|
| } |
| 236 |
0 |
| return INT2PTR(gql_parser_lazy_state_t *, SvUV(inner_sv)); |
| 237 |
|
| } |
| 238 |
|
| |
| 239 |
|
| static AV * |
| 240 |
0 |
| gql_parser_materialize_lazy_array(pTHX_ SV *state_sv, UV ptr, IV kind) { |
| 241 |
0 |
| gql_parser_lazy_state_t *lazy_state = gql_parser_lazy_state_from_sv(state_sv); |
| 242 |
0 |
▶ | gql_parser_loc_context_t *ctx = lazy_state->has_ctx ? &lazy_state->ctx : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| gql_parser_loc_context_t *ctx = lazy_state->has_ctx ? &lazy_state->ctx : NULL; |
0 |
0 |
0 |
|
| 243 |
|
| |
| 244 |
0 |
| switch (kind) { |
| 245 |
0 |
| case GQLJS_LAZY_ARRAY_ARGUMENTS: |
| 246 |
0 |
| return gql_parser_build_arguments_from_ir( |
| 247 |
|
| aTHX_ ctx, |
| 248 |
|
| lazy_state->document, |
| 249 |
|
| INT2PTR(gql_ir_ptr_array_t *, ptr), |
| 250 |
|
| state_sv |
| 251 |
|
| ); |
| 252 |
0 |
| case GQLJS_LAZY_ARRAY_DIRECTIVES: |
| 253 |
0 |
| return gql_parser_build_directives_from_ir( |
| 254 |
|
| aTHX_ ctx, |
| 255 |
|
| lazy_state->document, |
| 256 |
|
| INT2PTR(gql_ir_ptr_array_t *, ptr), |
| 257 |
|
| state_sv |
| 258 |
|
| ); |
| 259 |
0 |
| case GQLJS_LAZY_ARRAY_VARIABLE_DEFINITIONS: |
| 260 |
0 |
| return gql_parser_build_variable_definitions_from_ir( |
| 261 |
|
| aTHX_ ctx, |
| 262 |
|
| lazy_state->document, |
| 263 |
|
| INT2PTR(gql_ir_ptr_array_t *, ptr), |
| 264 |
|
| state_sv |
| 265 |
|
| ); |
| 266 |
0 |
| case GQLJS_LAZY_ARRAY_OBJECT_FIELDS: |
| 267 |
0 |
| return gql_parser_build_object_fields_from_ir( |
| 268 |
|
| aTHX_ ctx, |
| 269 |
|
| lazy_state->document, |
| 270 |
|
| INT2PTR(gql_ir_ptr_array_t *, ptr), |
| 271 |
|
| state_sv |
| 272 |
|
| ); |
| 273 |
|
| } |
| 274 |
|
| |
| 275 |
0 |
| croak("Unknown parser lazy array kind %" IVdf, kind); |
| 276 |
|
| return NULL; |
| 277 |
|
| } |
| 278 |
|
| |
| 279 |
|
| static SV * |
| 280 |
0 |
| gql_parser_new_lazy_arguments_sv(pTHX_ SV *state_sv, gql_ir_ptr_array_t *arguments) { |
| 281 |
0 |
| dSP; |
| 282 |
|
| SV *ret_sv; |
| 283 |
|
| |
| 284 |
0 |
| ENTER; |
| 285 |
0 |
| SAVETMPS; |
| 286 |
0 |
▶ | PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP); |
0 |
0 |
0 |
|
| 287 |
0 |
▶ | XPUSHs(sv_2mortal(newSVsv(state_sv))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVsv(state_sv))); |
0 |
0 |
0 |
|
| 288 |
0 |
▶ | XPUSHs(sv_2mortal(newSVuv(PTR2UV(arguments)))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVuv(PTR2UV(arguments)))); |
0 |
0 |
0 |
|
| 289 |
0 |
| PUTBACK; |
| 290 |
0 |
| call_pv("GraphQL::Houtou::Parser::Internal::LazyArray::Arguments::_new", G_SCALAR); |
| 291 |
0 |
| SPAGAIN; |
| 292 |
0 |
| ret_sv = newSVsv(POPs); |
| 293 |
0 |
| PUTBACK; |
| 294 |
0 |
▶ | FREETMPS; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; |
0 |
0 |
0 |
|
| 295 |
0 |
| LEAVE; |
| 296 |
|
| |
| 297 |
0 |
| return ret_sv; |
| 298 |
|
| } |
| 299 |
|
| |
| 300 |
|
| static SV * |
| 301 |
0 |
| gql_parser_new_lazy_directives_sv(pTHX_ SV *state_sv, gql_ir_ptr_array_t *directives) { |
| 302 |
0 |
| dSP; |
| 303 |
|
| SV *ret_sv; |
| 304 |
|
| |
| 305 |
0 |
| ENTER; |
| 306 |
0 |
| SAVETMPS; |
| 307 |
0 |
▶ | PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP); |
0 |
0 |
0 |
|
| 308 |
0 |
▶ | XPUSHs(sv_2mortal(newSVsv(state_sv))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVsv(state_sv))); |
0 |
0 |
0 |
|
| 309 |
0 |
▶ | XPUSHs(sv_2mortal(newSVuv(PTR2UV(directives)))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVuv(PTR2UV(directives)))); |
0 |
0 |
0 |
|
| 310 |
0 |
| PUTBACK; |
| 311 |
0 |
| call_pv("GraphQL::Houtou::Parser::Internal::LazyArray::Directives::_new", G_SCALAR); |
| 312 |
0 |
| SPAGAIN; |
| 313 |
0 |
| ret_sv = newSVsv(POPs); |
| 314 |
0 |
| PUTBACK; |
| 315 |
0 |
▶ | FREETMPS; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; |
0 |
0 |
0 |
|
| 316 |
0 |
| LEAVE; |
| 317 |
|
| |
| 318 |
0 |
| return ret_sv; |
| 319 |
|
| } |
| 320 |
|
| |
| 321 |
|
| static SV * |
| 322 |
0 |
| gql_parser_new_lazy_object_fields_sv(pTHX_ SV *state_sv, gql_ir_ptr_array_t *fields) { |
| 323 |
0 |
| dSP; |
| 324 |
|
| SV *ret_sv; |
| 325 |
|
| |
| 326 |
0 |
| ENTER; |
| 327 |
0 |
| SAVETMPS; |
| 328 |
0 |
▶ | PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP); |
0 |
0 |
0 |
|
| 329 |
0 |
▶ | XPUSHs(sv_2mortal(newSVsv(state_sv))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVsv(state_sv))); |
0 |
0 |
0 |
|
| 330 |
0 |
▶ | XPUSHs(sv_2mortal(newSVuv(PTR2UV(fields)))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVuv(PTR2UV(fields)))); |
0 |
0 |
0 |
|
| 331 |
0 |
| PUTBACK; |
| 332 |
0 |
| call_pv("GraphQL::Houtou::Parser::Internal::LazyArray::ObjectFields::_new", G_SCALAR); |
| 333 |
0 |
| SPAGAIN; |
| 334 |
0 |
| ret_sv = newSVsv(POPs); |
| 335 |
0 |
| PUTBACK; |
| 336 |
0 |
▶ | FREETMPS; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; |
0 |
0 |
0 |
|
| 337 |
0 |
| LEAVE; |
| 338 |
|
| |
| 339 |
0 |
| return ret_sv; |
| 340 |
|
| } |
| 341 |
|
| |
| 342 |
|
| static UV |
| 343 |
0 |
| gql_parser_original_pos_from_rewritten_pos(gql_parser_loc_context_t *ctx, UV rewritten_pos) { |
| 344 |
0 |
| UV original_pos = rewritten_pos; |
| 345 |
|
| |
| 346 |
0 |
▶ | if (!ctx) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!ctx) { |
0 |
0 |
0 |
|
| 347 |
0 |
| return rewritten_pos; |
| 348 |
|
| } |
| 349 |
|
| |
| 350 |
0 |
▶ | if (ctx->rewrite_index_count > 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (ctx->rewrite_index_count > 0) { |
0 |
0 |
0 |
|
| 351 |
0 |
| IV rewritten_iv = (IV)rewritten_pos; |
| 352 |
0 |
| I32 low = 0; |
| 353 |
0 |
| I32 high = ctx->rewrite_index_count - 1; |
| 354 |
0 |
| I32 match = -1; |
| 355 |
|
| |
| 356 |
0 |
▶ | while (low <= high) { |
Branch: 1 branch
| Branch | True | False | Total |
| while (low <= high) { |
0 |
0 |
0 |
|
| 357 |
0 |
| I32 mid = low + ((high - low) / 2); |
| 358 |
0 |
| gql_parser_rewrite_index_t *entry = &ctx->rewrite_index[mid]; |
| 359 |
0 |
▶ | if (entry->rewritten_start <= rewritten_iv) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (entry->rewritten_start <= rewritten_iv) { |
0 |
0 |
0 |
|
| 360 |
0 |
| match = mid; |
| 361 |
0 |
| low = mid + 1; |
| 362 |
|
| } else { |
| 363 |
0 |
| high = mid - 1; |
| 364 |
|
| } |
| 365 |
|
| } |
| 366 |
|
| |
| 367 |
0 |
▶ | if (match >= 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (match >= 0) { |
0 |
0 |
0 |
|
| 368 |
0 |
| gql_parser_rewrite_index_t *entry = &ctx->rewrite_index[match]; |
| 369 |
0 |
▶ | if (rewritten_iv < entry->rewritten_end) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (rewritten_iv < entry->rewritten_end) { |
0 |
0 |
0 |
|
| 370 |
0 |
| original_pos = entry->original_start; |
| 371 |
|
| } else { |
| 372 |
0 |
| original_pos = (UV)(rewritten_iv + entry->delta_after); |
| 373 |
|
| } |
| 374 |
|
| } |
| 375 |
|
| } |
| 376 |
|
| |
| 377 |
0 |
| return original_pos; |
| 378 |
|
| } |
| 379 |
|
| |
| 380 |
|
| static SV * |
| 381 |
0 |
| gql_parser_loc_from_rewritten_pos(pTHX_ gql_parser_loc_context_t *ctx, UV rewritten_pos) { |
| 382 |
|
| UV original_pos; |
| 383 |
|
| I32 line_index; |
| 384 |
|
| SV *loc_sv; |
| 385 |
|
| |
| 386 |
0 |
▶ | if (!ctx) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!ctx) { |
0 |
0 |
0 |
|
| 387 |
0 |
| return &PL_sv_undef; |
| 388 |
|
| } |
| 389 |
|
| |
| 390 |
0 |
| original_pos = gql_parser_original_pos_from_rewritten_pos(ctx, rewritten_pos); |
| 391 |
|
| |
| 392 |
0 |
▶ | if (ctx->num_lines <= 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (ctx->num_lines <= 0) { |
0 |
0 |
0 |
|
| 393 |
0 |
| return ctx->lazy_location |
| 394 |
0 |
| ? gql_parser_new_lazy_loc_sv(aTHX_ original_pos) |
| 395 |
0 |
▶ | : gql_parser_new_loc_sv(aTHX_ 1, (IV)(original_pos + 1)); |
Branch: 1 branch
| Branch | True | False | Total |
| : gql_parser_new_loc_sv(aTHX_ 1, (IV)(original_pos + 1)); |
0 |
0 |
0 |
|
| 396 |
|
| } |
| 397 |
|
| |
| 398 |
0 |
▶ | if (ctx->has_last_line_index |
Branch: 1 branch
| Branch | True | False | Total |
| if (ctx->has_last_line_index |
0 |
0 |
0 |
|
| 399 |
0 |
▶ | && original_pos >= ctx->line_starts[ctx->last_line_index] |
Branch: 1 branch
| Branch | True | False | Total |
| && original_pos >= ctx->line_starts[ctx->last_line_index] |
0 |
0 |
0 |
|
| 400 |
0 |
▶ | && (ctx->last_line_index + 1 >= ctx->num_lines |
Branch: 1 branch
| Branch | True | False | Total |
| && (ctx->last_line_index + 1 >= ctx->num_lines |
0 |
0 |
0 |
|
| 401 |
0 |
▶ | || original_pos < ctx->line_starts[ctx->last_line_index + 1])) { |
Branch: 1 branch
| Branch | True | False | Total |
| || original_pos < ctx->line_starts[ctx->last_line_index + 1])) { |
0 |
0 |
0 |
|
| 402 |
0 |
| line_index = ctx->last_line_index; |
| 403 |
0 |
▶ | } else if (ctx->has_last_line_index && original_pos >= ctx->last_original_pos) { |
Branch: 2 branches
| Branch | True | False | Total |
| } else if (ctx->has_last_line_index && original_pos >= ctx->last_original_pos) { |
0 |
0 |
0 |
| } else if (ctx->has_last_line_index && original_pos >= ctx->last_original_pos) { |
0 |
0 |
0 |
|
| 404 |
0 |
| line_index = ctx->last_line_index; |
| 405 |
0 |
▶ | while (line_index + 1 < ctx->num_lines && ctx->line_starts[line_index + 1] <= original_pos) { |
Branch: 2 branches
| Branch | True | False | Total |
| while (line_index + 1 < ctx->num_lines && ctx->line_starts[line_index + 1] <= original_pos) { |
0 |
0 |
0 |
| while (line_index + 1 < ctx->num_lines && ctx->line_starts[line_index + 1] <= original_pos) { |
0 |
0 |
0 |
|
| 406 |
0 |
| line_index++; |
| 407 |
|
| } |
| 408 |
|
| } else { |
| 409 |
0 |
| I32 low = 0; |
| 410 |
0 |
| I32 high = ctx->num_lines - 1; |
| 411 |
0 |
| line_index = 0; |
| 412 |
|
| |
| 413 |
0 |
▶ | while (low <= high) { |
Branch: 1 branch
| Branch | True | False | Total |
| while (low <= high) { |
0 |
0 |
0 |
|
| 414 |
0 |
| I32 mid = low + ((high - low) / 2); |
| 415 |
0 |
▶ | if (ctx->line_starts[mid] <= original_pos) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (ctx->line_starts[mid] <= original_pos) { |
0 |
0 |
0 |
|
| 416 |
0 |
| line_index = mid; |
| 417 |
0 |
| low = mid + 1; |
| 418 |
|
| } else { |
| 419 |
0 |
| high = mid - 1; |
| 420 |
|
| } |
| 421 |
|
| } |
| 422 |
|
| } |
| 423 |
0 |
| ctx->last_original_pos = original_pos; |
| 424 |
0 |
| ctx->last_line_index = line_index; |
| 425 |
0 |
| ctx->has_last_line_index = 1; |
| 426 |
|
| |
| 427 |
0 |
▶ | if (ctx->lazy_location) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (ctx->lazy_location) { |
0 |
0 |
0 |
|
| 428 |
0 |
| loc_sv = gql_parser_new_lazy_loc_sv(aTHX_ original_pos); |
| 429 |
|
| } else { |
| 430 |
0 |
| loc_sv = gql_parser_new_loc_sv( |
| 431 |
|
| aTHX_ |
| 432 |
0 |
| (IV)(line_index + 1), |
| 433 |
0 |
| (IV)(original_pos - ctx->line_starts[line_index] + 1) |
| 434 |
|
| ); |
| 435 |
|
| } |
| 436 |
0 |
| return loc_sv; |
| 437 |
|
| } |
| 438 |
|
| |
| 439 |
|
| static void |
| 440 |
0 |
| gql_parser_loc_context_destroy(gql_parser_loc_context_t *ctx) { |
| 441 |
0 |
▶ | if (ctx->line_starts) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (ctx->line_starts) { |
0 |
0 |
0 |
|
| 442 |
0 |
| Safefree(ctx->line_starts); |
| 443 |
|
| } |
| 444 |
0 |
▶ | if (ctx->rewrite_index) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (ctx->rewrite_index) { |
0 |
0 |
0 |
|
| 445 |
0 |
| Safefree(ctx->rewrite_index); |
| 446 |
|
| } |
| 447 |
0 |
| ctx->line_starts = NULL; |
| 448 |
0 |
| ctx->num_lines = 0; |
| 449 |
0 |
| ctx->rewrite_index = NULL; |
| 450 |
0 |
| ctx->rewrite_index_count = 0; |
| 451 |
0 |
| ctx->last_original_pos = 0; |
| 452 |
0 |
| ctx->last_line_index = 0; |
| 453 |
0 |
| ctx->has_last_line_index = 0; |
| 454 |
0 |
| ctx->lazy_location = 0; |
| 455 |
0 |
| ctx->compact_location = 0; |
| 456 |
0 |
| } |
| 457 |
|
| |
| 458 |
|
| static SV * |
| 459 |
0 |
| gql_parser_locate_name_node(pTHX_ gql_parser_t *p, SV *node_sv) { |
| 460 |
|
| SV *loc; |
| 461 |
0 |
▶ | if (p->kind != TOK_NAME) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (p->kind != TOK_NAME) { |
0 |
0 |
0 |
|
| 462 |
0 |
| gql_throw_expected_token(aTHX_ p, TOK_NAME); |
| 463 |
|
| } |
| 464 |
0 |
| loc = sv_2mortal(gql_make_current_location(aTHX_ p)); |
| 465 |
0 |
| gql_parser_set_loc_node(aTHX_ node_sv, loc); |
| 466 |
0 |
| gql_advance(aTHX_ p); |
| 467 |
0 |
| return loc; |
| 468 |
|
| } |
| 469 |
|
| |
| 470 |
|
| static SV * |
| 471 |
0 |
| gql_parser_locate_type_node(pTHX_ gql_parser_t *p, SV *node_sv) { |
| 472 |
0 |
| HV *hv = gql_parser_node_hv(node_sv); |
| 473 |
0 |
| const char *kind = gql_parser_fetch_kind(hv); |
| 474 |
|
| SV *loc; |
| 475 |
|
| |
| 476 |
0 |
▶ | if (!kind) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!kind) { |
0 |
0 |
0 |
|
| 477 |
0 |
| croak("parser executable loc expected type node"); |
| 478 |
|
| } |
| 479 |
|
| |
| 480 |
0 |
▶ | if (strcmp(kind, "NamedType") == 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(kind, "NamedType") == 0) { |
0 |
0 |
0 |
|
| 481 |
0 |
| loc = gql_parser_locate_name_node(aTHX_ p, gql_parser_fetch_sv(hv, "name")); |
| 482 |
0 |
| gql_parser_set_loc_node(aTHX_ node_sv, loc); |
| 483 |
0 |
| return loc; |
| 484 |
|
| } |
| 485 |
0 |
▶ | if (strcmp(kind, "ListType") == 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(kind, "ListType") == 0) { |
0 |
0 |
0 |
|
| 486 |
0 |
| loc = sv_2mortal(gql_make_current_location(aTHX_ p)); |
| 487 |
0 |
| gql_expect(aTHX_ p, TOK_LBRACKET, NULL); |
| 488 |
0 |
| gql_parser_set_loc_node(aTHX_ node_sv, loc); |
| 489 |
0 |
| gql_parser_locate_type_node(aTHX_ p, gql_parser_fetch_sv(hv, "type")); |
| 490 |
0 |
| gql_expect(aTHX_ p, TOK_RBRACKET, NULL); |
| 491 |
0 |
| return loc; |
| 492 |
|
| } |
| 493 |
0 |
▶ | if (strcmp(kind, "NonNullType") == 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(kind, "NonNullType") == 0) { |
0 |
0 |
0 |
|
| 494 |
0 |
| loc = gql_parser_locate_type_node(aTHX_ p, gql_parser_fetch_sv(hv, "type")); |
| 495 |
0 |
| gql_expect(aTHX_ p, TOK_BANG, NULL); |
| 496 |
0 |
| gql_parser_set_loc_node(aTHX_ node_sv, loc); |
| 497 |
0 |
| return loc; |
| 498 |
|
| } |
| 499 |
|
| |
| 500 |
0 |
| croak("Unsupported parser executable type node %s", kind); |
| 501 |
|
| } |
| 502 |
|
| |
| 503 |
|
| static SV * |
| 504 |
0 |
| gql_parser_locate_value_node(pTHX_ gql_parser_t *p, SV *node_sv) { |
| 505 |
0 |
| HV *hv = gql_parser_node_hv(node_sv); |
| 506 |
0 |
| const char *kind = gql_parser_fetch_kind(hv); |
| 507 |
|
| SV *loc; |
| 508 |
|
| AV *av; |
| 509 |
|
| I32 i; |
| 510 |
|
| |
| 511 |
0 |
▶ | if (!kind) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!kind) { |
0 |
0 |
0 |
|
| 512 |
0 |
| croak("parser executable loc expected value node"); |
| 513 |
|
| } |
| 514 |
|
| |
| 515 |
0 |
▶ | if (strcmp(kind, "Variable") == 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(kind, "Variable") == 0) { |
0 |
0 |
0 |
|
| 516 |
0 |
| loc = sv_2mortal(gql_make_current_location(aTHX_ p)); |
| 517 |
0 |
| gql_expect(aTHX_ p, TOK_DOLLAR, NULL); |
| 518 |
0 |
| gql_parser_set_loc_node(aTHX_ node_sv, loc); |
| 519 |
0 |
| gql_parser_locate_name_node(aTHX_ p, gql_parser_fetch_sv(hv, "name")); |
| 520 |
0 |
| return loc; |
| 521 |
|
| } |
| 522 |
0 |
▶ | if (strcmp(kind, "IntValue") == 0 || strcmp(kind, "FloatValue") == 0) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (strcmp(kind, "IntValue") == 0 || strcmp(kind, "FloatValue") == 0) { |
0 |
0 |
0 |
| if (strcmp(kind, "IntValue") == 0 || strcmp(kind, "FloatValue") == 0) { |
0 |
0 |
0 |
|
| 523 |
0 |
▶ | if (p->kind != TOK_INT && p->kind != TOK_FLOAT) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (p->kind != TOK_INT && p->kind != TOK_FLOAT) { |
0 |
0 |
0 |
| if (p->kind != TOK_INT && p->kind != TOK_FLOAT) { |
0 |
0 |
0 |
|
| 524 |
0 |
| gql_throw_expected_message(aTHX_ p, p->tok_start, "Expected numeric token"); |
| 525 |
|
| } |
| 526 |
0 |
| loc = sv_2mortal(gql_make_current_location(aTHX_ p)); |
| 527 |
0 |
| gql_parser_set_loc_node(aTHX_ node_sv, loc); |
| 528 |
0 |
| gql_advance(aTHX_ p); |
| 529 |
0 |
| return loc; |
| 530 |
|
| } |
| 531 |
0 |
▶ | if (strcmp(kind, "StringValue") == 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(kind, "StringValue") == 0) { |
0 |
0 |
0 |
|
| 532 |
0 |
▶ | if (p->kind != TOK_STRING && p->kind != TOK_BLOCK_STRING) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (p->kind != TOK_STRING && p->kind != TOK_BLOCK_STRING) { |
0 |
0 |
0 |
| if (p->kind != TOK_STRING && p->kind != TOK_BLOCK_STRING) { |
0 |
0 |
0 |
|
| 533 |
0 |
| gql_throw(aTHX_ p, p->tok_start, "Expected string token"); |
| 534 |
|
| } |
| 535 |
0 |
| loc = sv_2mortal(gql_make_current_location(aTHX_ p)); |
| 536 |
0 |
| gql_parser_set_loc_node(aTHX_ node_sv, loc); |
| 537 |
0 |
| gql_advance(aTHX_ p); |
| 538 |
0 |
| return loc; |
| 539 |
|
| } |
| 540 |
0 |
▶ | if (strcmp(kind, "BooleanValue") == 0 || strcmp(kind, "NullValue") == 0 || strcmp(kind, "EnumValue") == 0) { |
Branch: 3 branches
| Branch | True | False | Total |
| if (strcmp(kind, "BooleanValue") == 0 || strcmp(kind, "NullValue") == 0 || strcmp(kind, "EnumValue") == 0) { |
0 |
0 |
0 |
| if (strcmp(kind, "BooleanValue") == 0 || strcmp(kind, "NullValue") == 0 || strcmp(kind, "EnumValue") == 0) { |
0 |
0 |
0 |
| if (strcmp(kind, "BooleanValue") == 0 || strcmp(kind, "NullValue") == 0 || strcmp(kind, "EnumValue") == 0) { |
0 |
0 |
0 |
|
| 541 |
0 |
| loc = sv_2mortal(gql_make_current_location(aTHX_ p)); |
| 542 |
0 |
| gql_expect(aTHX_ p, TOK_NAME, NULL); |
| 543 |
0 |
| gql_parser_set_loc_node(aTHX_ node_sv, loc); |
| 544 |
0 |
| return loc; |
| 545 |
|
| } |
| 546 |
0 |
▶ | if (strcmp(kind, "ListValue") == 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(kind, "ListValue") == 0) { |
0 |
0 |
0 |
|
| 547 |
0 |
| loc = sv_2mortal(gql_make_current_location(aTHX_ p)); |
| 548 |
0 |
| gql_expect(aTHX_ p, TOK_LBRACKET, NULL); |
| 549 |
0 |
| gql_parser_set_loc_node(aTHX_ node_sv, loc); |
| 550 |
0 |
| av = gql_parser_fetch_array(hv, "values"); |
| 551 |
0 |
▶ | if (av) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (av) { |
0 |
0 |
0 |
|
| 552 |
0 |
▶ | for (i = 0; i <= av_len(av); i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i <= av_len(av); i++) { |
0 |
0 |
0 |
|
| 553 |
0 |
| SV **svp = av_fetch(av, i, 0); |
| 554 |
0 |
▶ | if (svp) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (svp) { |
0 |
0 |
0 |
|
| 555 |
0 |
| gql_parser_locate_value_node(aTHX_ p, *svp); |
| 556 |
|
| } |
| 557 |
|
| } |
| 558 |
|
| } |
| 559 |
0 |
| gql_expect(aTHX_ p, TOK_RBRACKET, NULL); |
| 560 |
0 |
| return loc; |
| 561 |
|
| } |
| 562 |
0 |
▶ | if (strcmp(kind, "ObjectValue") == 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(kind, "ObjectValue") == 0) { |
0 |
0 |
0 |
|
| 563 |
0 |
| loc = sv_2mortal(gql_make_current_location(aTHX_ p)); |
| 564 |
0 |
| gql_expect(aTHX_ p, TOK_LBRACE, NULL); |
| 565 |
0 |
| gql_parser_set_loc_node(aTHX_ node_sv, loc); |
| 566 |
0 |
| av = gql_parser_fetch_array(hv, "fields"); |
| 567 |
0 |
▶ | while (p->kind != TOK_RBRACE) { |
Branch: 1 branch
| Branch | True | False | Total |
| while (p->kind != TOK_RBRACE) { |
0 |
0 |
0 |
|
| 568 |
0 |
| SV *name_sv = sv_2mortal(newSVpvn(p->src + p->tok_start, p->tok_end - p->tok_start)); |
| 569 |
0 |
| SV *field_sv = gql_parser_find_named_node_sv(av, name_sv); |
| 570 |
|
| HV *field_hv; |
| 571 |
|
| SV *field_loc; |
| 572 |
0 |
▶ | if (!field_sv) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!field_sv) { |
0 |
0 |
0 |
|
| 573 |
0 |
| croak("Missing object field node"); |
| 574 |
|
| } |
| 575 |
0 |
| field_hv = gql_parser_node_hv(field_sv); |
| 576 |
0 |
| field_loc = sv_2mortal(gql_make_current_location(aTHX_ p)); |
| 577 |
0 |
| gql_parser_set_loc_node(aTHX_ field_sv, field_loc); |
| 578 |
0 |
| gql_parser_locate_name_node(aTHX_ p, gql_parser_fetch_sv(field_hv, "name")); |
| 579 |
0 |
| gql_expect(aTHX_ p, TOK_COLON, NULL); |
| 580 |
0 |
| gql_parser_locate_value_node(aTHX_ p, gql_parser_fetch_sv(field_hv, "value")); |
| 581 |
|
| } |
| 582 |
0 |
| gql_expect(aTHX_ p, TOK_RBRACE, NULL); |
| 583 |
0 |
| return loc; |
| 584 |
|
| } |
| 585 |
|
| |
| 586 |
0 |
| croak("Unsupported parser executable value node %s", kind); |
| 587 |
|
| } |
| 588 |
|
| |
| 589 |
|
| static void |
| 590 |
0 |
| gql_parser_locate_arguments_nodes(pTHX_ gql_parser_t *p, AV *av) { |
| 591 |
0 |
▶ | if (!av || av_len(av) < 0) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!av || av_len(av) < 0) { |
0 |
0 |
0 |
| if (!av || av_len(av) < 0) { |
0 |
0 |
0 |
|
| 592 |
0 |
| return; |
| 593 |
|
| } |
| 594 |
0 |
| gql_expect(aTHX_ p, TOK_LPAREN, NULL); |
| 595 |
0 |
▶ | while (p->kind != TOK_RPAREN) { |
Branch: 1 branch
| Branch | True | False | Total |
| while (p->kind != TOK_RPAREN) { |
0 |
0 |
0 |
|
| 596 |
0 |
| SV *name_sv = sv_2mortal(newSVpvn(p->src + p->tok_start, p->tok_end - p->tok_start)); |
| 597 |
0 |
| SV *node_sv = gql_parser_find_named_node_sv(av, name_sv); |
| 598 |
|
| HV *node_hv; |
| 599 |
|
| SV *loc; |
| 600 |
0 |
▶ | if (!node_sv) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!node_sv) { |
0 |
0 |
0 |
|
| 601 |
0 |
| croak("Missing argument node"); |
| 602 |
|
| } |
| 603 |
0 |
| node_hv = gql_parser_node_hv(node_sv); |
| 604 |
0 |
| loc = sv_2mortal(gql_make_current_location(aTHX_ p)); |
| 605 |
0 |
| gql_parser_set_loc_node(aTHX_ node_sv, loc); |
| 606 |
0 |
| gql_parser_locate_name_node(aTHX_ p, gql_parser_fetch_sv(node_hv, "name")); |
| 607 |
0 |
| gql_expect(aTHX_ p, TOK_COLON, NULL); |
| 608 |
0 |
| gql_parser_locate_value_node(aTHX_ p, gql_parser_fetch_sv(node_hv, "value")); |
| 609 |
|
| } |
| 610 |
0 |
| gql_expect(aTHX_ p, TOK_RPAREN, NULL); |
| 611 |
|
| } |
| 612 |
|
| |
| 613 |
|
| static void |
| 614 |
0 |
| gql_parser_locate_directives_nodes(pTHX_ gql_parser_t *p, AV *av) { |
| 615 |
|
| I32 i; |
| 616 |
0 |
▶ | if (!av || av_len(av) < 0) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!av || av_len(av) < 0) { |
0 |
0 |
0 |
| if (!av || av_len(av) < 0) { |
0 |
0 |
0 |
|
| 617 |
0 |
| return; |
| 618 |
|
| } |
| 619 |
0 |
▶ | for (i = 0; i <= av_len(av); i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i <= av_len(av); i++) { |
0 |
0 |
0 |
|
| 620 |
0 |
| SV **svp = av_fetch(av, i, 0); |
| 621 |
|
| HV *hv; |
| 622 |
|
| SV *loc; |
| 623 |
0 |
▶ | if (!svp) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!svp) { |
0 |
0 |
0 |
|
| 624 |
0 |
| continue; |
| 625 |
|
| } |
| 626 |
0 |
| hv = gql_parser_node_hv(*svp); |
| 627 |
0 |
▶ | if (!hv) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!hv) { |
0 |
0 |
0 |
|
| 628 |
0 |
| continue; |
| 629 |
|
| } |
| 630 |
0 |
| loc = sv_2mortal(gql_make_current_location(aTHX_ p)); |
| 631 |
0 |
| gql_expect(aTHX_ p, TOK_AT, NULL); |
| 632 |
0 |
| gql_parser_set_loc_node(aTHX_ *svp, loc); |
| 633 |
0 |
| gql_parser_locate_name_node(aTHX_ p, gql_parser_fetch_sv(hv, "name")); |
| 634 |
0 |
| gql_parser_locate_arguments_nodes(aTHX_ p, gql_parser_fetch_array(hv, "arguments")); |
| 635 |
|
| } |
| 636 |
|
| } |
| 637 |
|
| |
| 638 |
|
| static SV * |
| 639 |
0 |
| gql_parser_locate_selection_set_node(pTHX_ gql_parser_t *p, SV *node_sv) { |
| 640 |
0 |
| HV *hv = gql_parser_node_hv(node_sv); |
| 641 |
0 |
| AV *av = gql_parser_fetch_array(hv, "selections"); |
| 642 |
|
| I32 i; |
| 643 |
0 |
| SV *loc = sv_2mortal(gql_make_current_location(aTHX_ p)); |
| 644 |
0 |
| gql_expect(aTHX_ p, TOK_LBRACE, NULL); |
| 645 |
0 |
| gql_parser_set_loc_node(aTHX_ node_sv, loc); |
| 646 |
0 |
▶ | if (av) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (av) { |
0 |
0 |
0 |
|
| 647 |
0 |
▶ | for (i = 0; i <= av_len(av); i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i <= av_len(av); i++) { |
0 |
0 |
0 |
|
| 648 |
0 |
| SV **svp = av_fetch(av, i, 0); |
| 649 |
0 |
▶ | if (svp) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (svp) { |
0 |
0 |
0 |
|
| 650 |
0 |
| gql_parser_locate_selection_node(aTHX_ p, *svp); |
| 651 |
|
| } |
| 652 |
|
| } |
| 653 |
|
| } |
| 654 |
0 |
| gql_expect(aTHX_ p, TOK_RBRACE, NULL); |
| 655 |
0 |
| return loc; |
| 656 |
|
| } |
| 657 |
|
| |
| 658 |
|
| static void |
| 659 |
0 |
| gql_parser_locate_selection_node(pTHX_ gql_parser_t *p, SV *node_sv) { |
| 660 |
0 |
| HV *hv = gql_parser_node_hv(node_sv); |
| 661 |
0 |
| const char *kind = gql_parser_fetch_kind(hv); |
| 662 |
|
| SV *loc; |
| 663 |
|
| |
| 664 |
0 |
▶ | if (!kind) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!kind) { |
0 |
0 |
0 |
|
| 665 |
0 |
| croak("parser executable loc expected selection node"); |
| 666 |
|
| } |
| 667 |
|
| |
| 668 |
0 |
▶ | if (strcmp(kind, "Field") == 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(kind, "Field") == 0) { |
0 |
0 |
0 |
|
| 669 |
0 |
| loc = sv_2mortal(gql_make_current_location(aTHX_ p)); |
| 670 |
0 |
▶ | if (gql_parser_fetch_sv(hv, "alias")) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (gql_parser_fetch_sv(hv, "alias")) { |
0 |
0 |
0 |
|
| 671 |
0 |
| gql_parser_locate_name_node(aTHX_ p, gql_parser_fetch_sv(hv, "alias")); |
| 672 |
0 |
| gql_expect(aTHX_ p, TOK_COLON, NULL); |
| 673 |
0 |
| gql_parser_locate_name_node(aTHX_ p, gql_parser_fetch_sv(hv, "name")); |
| 674 |
|
| } else { |
| 675 |
0 |
| gql_parser_locate_name_node(aTHX_ p, gql_parser_fetch_sv(hv, "name")); |
| 676 |
|
| } |
| 677 |
0 |
| gql_parser_set_loc_node(aTHX_ node_sv, loc); |
| 678 |
0 |
| gql_parser_locate_arguments_nodes(aTHX_ p, gql_parser_fetch_array(hv, "arguments")); |
| 679 |
0 |
| gql_parser_locate_directives_nodes(aTHX_ p, gql_parser_fetch_array(hv, "directives")); |
| 680 |
0 |
▶ | if (gql_parser_fetch_sv(hv, "selectionSet")) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (gql_parser_fetch_sv(hv, "selectionSet")) { |
0 |
0 |
0 |
|
| 681 |
0 |
| gql_parser_locate_selection_set_node(aTHX_ p, gql_parser_fetch_sv(hv, "selectionSet")); |
| 682 |
|
| } |
| 683 |
0 |
| return; |
| 684 |
|
| } |
| 685 |
0 |
▶ | if (strcmp(kind, "FragmentSpread") == 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(kind, "FragmentSpread") == 0) { |
0 |
0 |
0 |
|
| 686 |
0 |
| loc = sv_2mortal(gql_make_current_location(aTHX_ p)); |
| 687 |
0 |
| gql_expect(aTHX_ p, TOK_SPREAD, NULL); |
| 688 |
0 |
| gql_parser_set_loc_node(aTHX_ node_sv, loc); |
| 689 |
0 |
| gql_parser_locate_name_node(aTHX_ p, gql_parser_fetch_sv(hv, "name")); |
| 690 |
0 |
| gql_parser_locate_directives_nodes(aTHX_ p, gql_parser_fetch_array(hv, "directives")); |
| 691 |
0 |
| return; |
| 692 |
|
| } |
| 693 |
0 |
▶ | if (strcmp(kind, "InlineFragment") == 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(kind, "InlineFragment") == 0) { |
0 |
0 |
0 |
|
| 694 |
0 |
| loc = sv_2mortal(gql_make_current_location(aTHX_ p)); |
| 695 |
0 |
| gql_expect(aTHX_ p, TOK_SPREAD, NULL); |
| 696 |
0 |
| gql_parser_set_loc_node(aTHX_ node_sv, loc); |
| 697 |
0 |
▶ | if (gql_parser_fetch_sv(hv, "typeCondition")) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (gql_parser_fetch_sv(hv, "typeCondition")) { |
0 |
0 |
0 |
|
| 698 |
0 |
| gql_expect(aTHX_ p, TOK_NAME, NULL); |
| 699 |
0 |
| gql_parser_locate_type_node(aTHX_ p, gql_parser_fetch_sv(hv, "typeCondition")); |
| 700 |
|
| } |
| 701 |
0 |
| gql_parser_locate_directives_nodes(aTHX_ p, gql_parser_fetch_array(hv, "directives")); |
| 702 |
0 |
| gql_parser_locate_selection_set_node(aTHX_ p, gql_parser_fetch_sv(hv, "selectionSet")); |
| 703 |
0 |
| return; |
| 704 |
|
| } |
| 705 |
|
| |
| 706 |
0 |
| croak("Unsupported parser executable selection node %s", kind); |
| 707 |
|
| } |