| 1 |
|
| #define PERL_NO_GET_CONTEXT /* For performance */ |
| 2 |
|
| #include "EXTERN.h" |
| 3 |
|
| #include "perl.h" |
| 4 |
|
| #include "XSUB.h" |
| 5 |
|
| |
| 6 |
|
| #include "ppport.h" |
| 7 |
|
| |
| 8 |
|
| #undef call_method |
| 9 |
|
| #undef leave_scope |
| 10 |
|
| |
| 11 |
|
| #include "spvm_native.h" |
| 12 |
|
| |
| 13 |
|
| #if !defined(SvIsBOOL) |
| 14 |
|
| #define SvIsBOOL(value) 0 |
| 15 |
|
| #endif |
| 16 |
|
| |
| 17 |
|
| static const char* FILE_NAME = "SPVM.xs"; |
| 18 |
|
| |
| 19 |
845338 |
| void* SPVM_XS_UTIL_get_pointer(pTHX_ SV* sv_data) { |
| 20 |
|
| |
| 21 |
845338 |
▶ | if (SvOK(sv_data)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_data)) { |
845338 |
0 |
845338 |
|
| 22 |
845338 |
| HV* hv_data = (HV*)SvRV(sv_data); |
| 23 |
|
| |
| 24 |
845338 |
| SV** sv_pointer_ptr = hv_fetch(hv_data, "pointer", strlen("pointer"), 0); |
| 25 |
845338 |
▶ | SV* sv_pointer = sv_pointer_ptr ? *sv_pointer_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_pointer = sv_pointer_ptr ? *sv_pointer_ptr : &PL_sv_undef; |
845338 |
0 |
845338 |
|
| 26 |
845338 |
| size_t iv_pointer = SvIV(SvRV(sv_pointer)); |
| 27 |
845338 |
| void* pointer = INT2PTR(void*, iv_pointer); |
| 28 |
|
| |
| 29 |
845338 |
| return pointer; |
| 30 |
|
| } |
| 31 |
|
| else { |
| 32 |
0 |
| return NULL; |
| 33 |
|
| } |
| 34 |
|
| } |
| 35 |
|
| |
| 36 |
318795 |
| SPVM_ENV* SPVM_XS_UTIL_get_boot_env(pTHX_ SV* sv_invocant) { |
| 37 |
|
| |
| 38 |
318795 |
| SPVM_ENV* boot_env = NULL; |
| 39 |
318795 |
▶ | if (SvOK(sv_invocant)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_invocant)) { |
318795 |
0 |
318795 |
|
| 40 |
318795 |
| HV* hv_invocant = (HV*)SvRV(sv_invocant); |
| 41 |
|
| |
| 42 |
318795 |
| SV* sv_compiler = &PL_sv_undef; |
| 43 |
|
| |
| 44 |
318795 |
▶ | if (sv_isobject(sv_invocant) && sv_derived_from(sv_invocant, "SPVM::Builder::Native::Compiler")) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (sv_isobject(sv_invocant) && sv_derived_from(sv_invocant, "SPVM::Builder::Native::Compiler")) { |
318795 |
0 |
318795 |
| if (sv_isobject(sv_invocant) && sv_derived_from(sv_invocant, "SPVM::Builder::Native::Compiler")) { |
62718 |
256077 |
318795 |
|
| 45 |
62718 |
| sv_compiler = sv_invocant; |
| 46 |
|
| } |
| 47 |
|
| |
| 48 |
318795 |
▶ | if (!SvOK(sv_compiler)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!SvOK(sv_compiler)) { |
256077 |
62718 |
318795 |
|
| 49 |
256077 |
| SV** sv_compiler_ptr = hv_fetch(hv_invocant, "compiler", strlen("compiler"), 0); |
| 50 |
256077 |
▶ | sv_compiler = sv_compiler_ptr ? *sv_compiler_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| sv_compiler = sv_compiler_ptr ? *sv_compiler_ptr : &PL_sv_undef; |
96813 |
159264 |
256077 |
|
| 51 |
|
| } |
| 52 |
|
| |
| 53 |
318795 |
▶ | if (!SvOK(sv_compiler)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!SvOK(sv_compiler)) { |
159264 |
159531 |
318795 |
|
| 54 |
159264 |
| SV** sv_runtime_ptr = hv_fetch(hv_invocant, "runtime", strlen("runtime"), 0); |
| 55 |
159264 |
▶ | SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
159264 |
0 |
159264 |
|
| 56 |
159264 |
| HV* hv_runtime = (HV*)SvRV(sv_runtime); |
| 57 |
|
| |
| 58 |
159264 |
| SV** sv_compiler_ptr = hv_fetch(hv_runtime, "compiler", strlen("compiler"), 0); |
| 59 |
159264 |
▶ | sv_compiler = sv_compiler_ptr ? *sv_compiler_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| sv_compiler = sv_compiler_ptr ? *sv_compiler_ptr : &PL_sv_undef; |
159264 |
0 |
159264 |
|
| 60 |
|
| } |
| 61 |
|
| |
| 62 |
318795 |
▶ | if (!SvOK(sv_compiler)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!SvOK(sv_compiler)) { |
0 |
318795 |
318795 |
|
| 63 |
0 |
| croak("[Unexpected Error]boot_env is not found."); |
| 64 |
|
| } |
| 65 |
|
| |
| 66 |
318795 |
| HV* hv_compiler = (HV*)SvRV(sv_compiler); |
| 67 |
318795 |
| SV** sv_boot_env_ptr = hv_fetch(hv_compiler, "boot_env", strlen("boot_env"), 0); |
| 68 |
318795 |
▶ | SV* sv_boot_env = sv_boot_env_ptr ? *sv_boot_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_boot_env = sv_boot_env_ptr ? *sv_boot_env_ptr : &PL_sv_undef; |
318795 |
0 |
318795 |
|
| 69 |
|
| |
| 70 |
318795 |
▶ | if (!SvOK(sv_boot_env)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!SvOK(sv_boot_env)) { |
0 |
318795 |
318795 |
|
| 71 |
0 |
| croak("[Unexpected Error]boot_env is not defined."); |
| 72 |
|
| } |
| 73 |
|
| |
| 74 |
318795 |
| boot_env = SPVM_XS_UTIL_get_pointer(aTHX_ sv_boot_env); |
| 75 |
|
| |
| 76 |
|
| } |
| 77 |
|
| else { |
| 78 |
0 |
| croak("[Unexpected Error]The invocant sv_invocant must be defined."); |
| 79 |
|
| } |
| 80 |
|
| |
| 81 |
318795 |
| return boot_env; |
| 82 |
|
| } |
| 83 |
|
| |
| 84 |
5058 |
| void* SPVM_XS_UTIL_get_spvm_object(pTHX_ SV* sv_blessed_object) { |
| 85 |
|
| |
| 86 |
5058 |
▶ | if (SvOK(sv_blessed_object)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_blessed_object)) { |
5058 |
0 |
5058 |
|
| 87 |
5058 |
| HV* hv_blessed_object = (HV*)SvRV(sv_blessed_object); |
| 88 |
|
| |
| 89 |
5058 |
| SV** sv_spvm_object_ptr = hv_fetch(hv_blessed_object, "spvm_object", strlen("spvm_object"), 0); |
| 90 |
5058 |
▶ | SV* sv_spvm_object = sv_spvm_object_ptr ? *sv_spvm_object_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_spvm_object = sv_spvm_object_ptr ? *sv_spvm_object_ptr : &PL_sv_undef; |
5058 |
0 |
5058 |
|
| 91 |
5058 |
| void** spvm_object_ref = (void**)SvPV_nolen(sv_spvm_object); |
| 92 |
5058 |
| void* spvm_object = *spvm_object_ref; |
| 93 |
|
| |
| 94 |
5058 |
| return spvm_object; |
| 95 |
|
| } |
| 96 |
|
| else { |
| 97 |
0 |
| return NULL; |
| 98 |
|
| } |
| 99 |
|
| } |
| 100 |
|
| |
| 101 |
21179 |
| SPVM_ENV* SPVM_XS_UTIL_get_env(pTHX_ SV* sv_env) { |
| 102 |
|
| |
| 103 |
|
| SPVM_ENV* env; |
| 104 |
21179 |
▶ | if (sv_isobject(sv_env) && sv_derived_from(sv_env, "SPVM::Builder::Native::Env")) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (sv_isobject(sv_env) && sv_derived_from(sv_env, "SPVM::Builder::Native::Env")) { |
21179 |
0 |
21179 |
| if (sv_isobject(sv_env) && sv_derived_from(sv_env, "SPVM::Builder::Native::Env")) { |
21179 |
0 |
21179 |
|
| 105 |
21179 |
| env = SPVM_XS_UTIL_get_pointer(aTHX_ sv_env); |
| 106 |
|
| } |
| 107 |
|
| else { |
| 108 |
0 |
| croak("[Unexpected Error]The runtime environemnt must be a SPVM::Builder::Native::Env object."); |
| 109 |
|
| } |
| 110 |
|
| |
| 111 |
21179 |
| return env; |
| 112 |
|
| } |
| 113 |
|
| |
| 114 |
21179 |
| SPVM_VALUE* SPVM_XS_UTIL_get_stack(pTHX_ SV* sv_stack) { |
| 115 |
|
| |
| 116 |
|
| SPVM_VALUE* stack; |
| 117 |
21179 |
▶ | if (sv_isobject(sv_stack) && sv_derived_from(sv_stack, "SPVM::Builder::Native::Stack")) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (sv_isobject(sv_stack) && sv_derived_from(sv_stack, "SPVM::Builder::Native::Stack")) { |
21179 |
0 |
21179 |
| if (sv_isobject(sv_stack) && sv_derived_from(sv_stack, "SPVM::Builder::Native::Stack")) { |
21179 |
0 |
21179 |
|
| 118 |
21179 |
| stack = SPVM_XS_UTIL_get_pointer(aTHX_ sv_stack); |
| 119 |
|
| } |
| 120 |
|
| else { |
| 121 |
0 |
| croak("[Unexpected Error]The runtime stack must be a SPVM::Builder::Native::Stack object."); |
| 122 |
|
| } |
| 123 |
|
| |
| 124 |
21179 |
| return stack; |
| 125 |
|
| } |
| 126 |
|
| |
| 127 |
4856 |
| SV* SPVM_XS_UTIL_new_sv_blessed_object(pTHX_ SV* sv_api, void* spvm_object, const char* class) { |
| 128 |
|
| |
| 129 |
4856 |
| HV* hv_self = (HV*)SvRV(sv_api); |
| 130 |
|
| |
| 131 |
4856 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 132 |
4856 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
4856 |
0 |
4856 |
|
| 133 |
4856 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 134 |
|
| |
| 135 |
4856 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 136 |
4856 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
4856 |
0 |
4856 |
|
| 137 |
4856 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 138 |
|
| |
| 139 |
4856 |
| SV* sv_spvm_object = sv_2mortal(newSVpv("", 0)); |
| 140 |
4856 |
▶ | SvGROW(sv_spvm_object, sizeof(void*) + 1); |
Branch: 2 branches
| Branch | True | False | Total |
| SvGROW(sv_spvm_object, sizeof(void*) + 1); |
4856 |
0 |
4856 |
| SvGROW(sv_spvm_object, sizeof(void*) + 1); |
0 |
4856 |
4856 |
|
| 141 |
4856 |
| SPVM_OBJ** spvm_object_ref = (SPVM_OBJ**)SvPV_nolen(sv_spvm_object); |
| 142 |
4856 |
| *spvm_object_ref = NULL; |
| 143 |
|
| |
| 144 |
4856 |
| env->assign_object(env, stack, spvm_object_ref, spvm_object); |
| 145 |
|
| |
| 146 |
4856 |
| HV* hv_blessed_object = (HV*)sv_2mortal((SV*)newHV()); |
| 147 |
4856 |
| SV* sv_blessed_object = sv_2mortal(newRV_inc((SV*)hv_blessed_object)); |
| 148 |
|
| |
| 149 |
4856 |
| (void)hv_store(hv_blessed_object, "spvm_object", strlen("spvm_object"), SvREFCNT_inc(sv_spvm_object), 0); |
| 150 |
|
| |
| 151 |
4856 |
▶ | if (SvOK(sv_api)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_api)) { |
4856 |
0 |
4856 |
|
| 152 |
4856 |
| (void)hv_store(hv_blessed_object, "__api", strlen("__api"), SvREFCNT_inc(sv_api), 0); |
| 153 |
|
| } |
| 154 |
|
| |
| 155 |
4856 |
| HV* hv_class = gv_stashpv(class, 0); |
| 156 |
4856 |
| sv_bless(sv_blessed_object, hv_class); |
| 157 |
|
| |
| 158 |
4856 |
| return sv_blessed_object; |
| 159 |
|
| } |
| 160 |
|
| |
| 161 |
124208 |
| SV* SPVM_XS_UTIL_new_sv_pointer_object(pTHX_ void* pointer, const char* class) { |
| 162 |
|
| |
| 163 |
124208 |
| size_t iv_pointer = PTR2IV(pointer); |
| 164 |
124208 |
| SV* sviv_pointer = sv_2mortal(newSViv(iv_pointer)); |
| 165 |
124208 |
| SV* sv_pointer = sv_2mortal(newRV_inc(sviv_pointer)); |
| 166 |
|
| |
| 167 |
124208 |
| HV* hv_pointer_object = (HV*)sv_2mortal((SV*)newHV()); |
| 168 |
124208 |
| (void)hv_store(hv_pointer_object, "pointer", strlen("pointer"), SvREFCNT_inc(sv_pointer), 0); |
| 169 |
124208 |
| SV* sv_pointer_object = sv_2mortal(newRV_inc((SV*)hv_pointer_object)); |
| 170 |
|
| |
| 171 |
124208 |
| HV* hv_class = gv_stashpv(class, 0); |
| 172 |
124208 |
| sv_bless(sv_pointer_object, hv_class); |
| 173 |
|
| |
| 174 |
124208 |
| return sv_pointer_object; |
| 175 |
|
| } |
| 176 |
|
| |
| 177 |
4215 |
| SV* SPVM_XS_UTIL_new_string(pTHX_ SV* sv_api, SV* sv_string, SV** sv_error) { |
| 178 |
|
| |
| 179 |
4215 |
| HV* hv_self = (HV*)SvRV(sv_api); |
| 180 |
|
| |
| 181 |
4215 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 182 |
4215 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
4215 |
0 |
4215 |
|
| 183 |
4215 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 184 |
|
| |
| 185 |
4215 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 186 |
4215 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
4215 |
0 |
4215 |
|
| 187 |
4215 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 188 |
|
| |
| 189 |
4215 |
▶ | if (SvOK(sv_string)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_string)) { |
4215 |
0 |
4215 |
|
| 190 |
4215 |
▶ | if (sv_isobject(sv_string) && sv_derived_from(sv_string, "SPVM::BlessedObject::String")) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (sv_isobject(sv_string) && sv_derived_from(sv_string, "SPVM::BlessedObject::String")) { |
0 |
4215 |
4215 |
| if (sv_isobject(sv_string) && sv_derived_from(sv_string, "SPVM::BlessedObject::String")) { |
0 |
0 |
0 |
|
| 191 |
|
| // Nothing |
| 192 |
|
| } |
| 193 |
4215 |
▶ | else if (SvROK(sv_string)) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if (SvROK(sv_string)) { |
0 |
4215 |
4215 |
|
| 194 |
0 |
| *sv_error = sv_2mortal(newSVpvf(" cannnot be a reference")); |
| 195 |
0 |
| return &PL_sv_undef; |
| 196 |
|
| } |
| 197 |
|
| else { |
| 198 |
4215 |
| STRLEN length = -1; |
| 199 |
4215 |
| const char* string = SvPV(sv_string, length); |
| 200 |
4215 |
| void* spvm_string = env->new_string_no_mortal(env, stack, string, (int32_t)length); |
| 201 |
4215 |
| sv_string = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_api, spvm_string, "SPVM::BlessedObject::String"); |
| 202 |
|
| } |
| 203 |
|
| } |
| 204 |
|
| else { |
| 205 |
0 |
| sv_string = &PL_sv_undef; |
| 206 |
|
| } |
| 207 |
|
| |
| 208 |
4215 |
| return sv_string; |
| 209 |
|
| } |
| 210 |
|
| |
| 211 |
0 |
| SV* SPVM_XS_UTIL_new_address_object(pTHX_ SV* sv_api, SV* sv_address, SV** sv_error) { |
| 212 |
0 |
| HV* hv_self = (HV*)SvRV(sv_api); |
| 213 |
|
| |
| 214 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 215 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 216 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 217 |
|
| |
| 218 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 219 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 220 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 221 |
|
| |
| 222 |
0 |
| int32_t error_id = 0; |
| 223 |
|
| |
| 224 |
0 |
| *sv_error = &PL_sv_undef; |
| 225 |
|
| |
| 226 |
0 |
▶ | if (SvOK(sv_address)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_address)) { |
0 |
0 |
0 |
|
| 227 |
0 |
▶ | if (sv_isobject(sv_address) && sv_derived_from(sv_address, "SPVM::BlessedObject::Class")) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (sv_isobject(sv_address) && sv_derived_from(sv_address, "SPVM::BlessedObject::Class")) { |
0 |
0 |
0 |
| if (sv_isobject(sv_address) && sv_derived_from(sv_address, "SPVM::BlessedObject::Class")) { |
0 |
0 |
0 |
|
| 228 |
0 |
| void* spvm_address = SPVM_XS_UTIL_get_spvm_object(aTHX_ sv_address); |
| 229 |
0 |
| int32_t type_dimension = 1; |
| 230 |
0 |
▶ | if (!env->is_type_by_name(env, stack, spvm_address, "Address", type_dimension)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!env->is_type_by_name(env, stack, spvm_address, "Address", type_dimension)) { |
0 |
0 |
0 |
|
| 231 |
0 |
| *sv_error = sv_2mortal(newSVpvf(": If it is an SPVM::BlessedObject::Class object, it must be the Address type")); |
| 232 |
0 |
| return &PL_sv_undef; |
| 233 |
|
| } |
| 234 |
|
| } |
| 235 |
0 |
▶ | else if (SvROK(sv_address)) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if (SvROK(sv_address)) { |
0 |
0 |
0 |
|
| 236 |
0 |
| *sv_error = sv_2mortal(newSVpvf(" cannnot be a reference")); |
| 237 |
0 |
| return &PL_sv_undef; |
| 238 |
|
| } |
| 239 |
|
| else { |
| 240 |
0 |
| void* address = (void*)(intptr_t)SvIV(sv_address); |
| 241 |
0 |
| void* basic_type = env->get_basic_type(env, stack, "Address"); |
| 242 |
|
| |
| 243 |
0 |
| void* spvm_address = env->new_pointer_object_no_mortal(env, stack, basic_type, address); |
| 244 |
|
| |
| 245 |
0 |
| sv_address = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_api, spvm_address, "SPVM::BlessedObject::Class"); |
| 246 |
|
| } |
| 247 |
|
| } |
| 248 |
|
| else { |
| 249 |
0 |
| sv_address = &PL_sv_undef; |
| 250 |
|
| } |
| 251 |
|
| |
| 252 |
0 |
| return sv_address; |
| 253 |
|
| } |
| 254 |
|
| |
| 255 |
0 |
| SV* SPVM_XS_UTIL_new_byte_array(pTHX_ SV* sv_api, SV* sv_array, SV** sv_error) { |
| 256 |
0 |
| HV* hv_self = (HV*)SvRV(sv_api); |
| 257 |
|
| |
| 258 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 259 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 260 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 261 |
|
| |
| 262 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 263 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 264 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 265 |
|
| |
| 266 |
0 |
| *sv_error = &PL_sv_undef; |
| 267 |
|
| |
| 268 |
0 |
▶ | if (SvOK(sv_array)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_array)) { |
0 |
0 |
0 |
|
| 269 |
0 |
▶ | if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
0 |
0 |
0 |
| if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
0 |
0 |
0 |
|
| 270 |
0 |
| void* spvm_array = SPVM_XS_UTIL_get_spvm_object(aTHX_ sv_array); |
| 271 |
0 |
| const char* spvm_array_basic_type_name = env->get_object_basic_type_name(env, stack, spvm_array); |
| 272 |
0 |
| int32_t spvm_array_type_dimension = env->get_object_type_dimension(env, stack, spvm_array); |
| 273 |
0 |
▶ | if (!(strcmp(spvm_array_basic_type_name, "byte") == 0 && spvm_array_type_dimension == 1)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(strcmp(spvm_array_basic_type_name, "byte") == 0 && spvm_array_type_dimension == 1)) { |
0 |
0 |
0 |
| if (!(strcmp(spvm_array_basic_type_name, "byte") == 0 && spvm_array_type_dimension == 1)) { |
0 |
0 |
0 |
|
| 274 |
0 |
| *sv_error = sv_2mortal(newSVpvf(": If it is an SPVM::BlessedObject::Array object, the type must be the byte[] type")); |
| 275 |
0 |
| return &PL_sv_undef; |
| 276 |
|
| } |
| 277 |
|
| } |
| 278 |
0 |
▶ | else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
Branch: 2 branches
| Branch | True | False | Total |
| else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
0 |
0 |
0 |
| else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
0 |
0 |
0 |
|
| 279 |
0 |
| *sv_error = sv_2mortal(newSVpvf(": If it is a reference, it must be an array reference")); |
| 280 |
0 |
| return &PL_sv_undef; |
| 281 |
|
| } |
| 282 |
|
| else { |
| 283 |
|
| // Elements |
| 284 |
0 |
| AV* av_array = (AV*)SvRV(sv_array); |
| 285 |
|
| |
| 286 |
|
| // Array length |
| 287 |
0 |
| int32_t length = av_len(av_array) + 1; |
| 288 |
|
| |
| 289 |
|
| // New array |
| 290 |
0 |
| void* spvm_array = env->new_byte_array_no_mortal(env, stack, length); |
| 291 |
|
| |
| 292 |
0 |
| int8_t* elems = env->get_elems_byte(env, stack, spvm_array); |
| 293 |
0 |
▶ | for (int32_t i = 0; i < length; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int32_t i = 0; i < length; i++) { |
0 |
0 |
0 |
|
| 294 |
0 |
| SV** sv_elem_ptr = av_fetch(av_array, i, 0); |
| 295 |
0 |
▶ | SV* sv_elem = sv_elem_ptr ? *sv_elem_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_elem = sv_elem_ptr ? *sv_elem_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 296 |
|
| |
| 297 |
0 |
▶ | if (!(SvOK(sv_elem) && !SvROK(sv_elem))) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(SvOK(sv_elem) && !SvROK(sv_elem))) { |
0 |
0 |
0 |
| if (!(SvOK(sv_elem) && !SvROK(sv_elem))) { |
0 |
0 |
0 |
|
| 298 |
0 |
| *sv_error = sv_2mortal(newSVpvf("'s %dth element must be a non-reference scalar", i + 1)); |
| 299 |
0 |
| return &PL_sv_undef; |
| 300 |
|
| } |
| 301 |
0 |
| elems[i] = (int8_t)SvIV(sv_elem); |
| 302 |
|
| } |
| 303 |
|
| |
| 304 |
0 |
| sv_array = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_api, spvm_array, "SPVM::BlessedObject::Array"); |
| 305 |
|
| } |
| 306 |
|
| } |
| 307 |
|
| else { |
| 308 |
0 |
| sv_array = &PL_sv_undef; |
| 309 |
|
| } |
| 310 |
|
| |
| 311 |
0 |
| return sv_array; |
| 312 |
|
| } |
| 313 |
|
| |
| 314 |
0 |
| SV* SPVM_XS_UTIL_new_byte_array_unsigned(pTHX_ SV* sv_api, SV* sv_array, SV** sv_error) { |
| 315 |
0 |
| HV* hv_self = (HV*)SvRV(sv_api); |
| 316 |
|
| |
| 317 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 318 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 319 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 320 |
|
| |
| 321 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 322 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 323 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 324 |
|
| |
| 325 |
0 |
| *sv_error = &PL_sv_undef; |
| 326 |
|
| |
| 327 |
0 |
▶ | if (SvOK(sv_array)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_array)) { |
0 |
0 |
0 |
|
| 328 |
0 |
▶ | if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
0 |
0 |
0 |
| if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
0 |
0 |
0 |
|
| 329 |
0 |
| void* spvm_array = SPVM_XS_UTIL_get_spvm_object(aTHX_ sv_array); |
| 330 |
0 |
| const char* spvm_array_basic_type_name = env->get_object_basic_type_name(env, stack, spvm_array); |
| 331 |
0 |
| int32_t spvm_array_type_dimension = env->get_object_type_dimension(env, stack, spvm_array); |
| 332 |
0 |
▶ | if (!(strcmp(spvm_array_basic_type_name, "byte") == 0 && spvm_array_type_dimension == 1)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(strcmp(spvm_array_basic_type_name, "byte") == 0 && spvm_array_type_dimension == 1)) { |
0 |
0 |
0 |
| if (!(strcmp(spvm_array_basic_type_name, "byte") == 0 && spvm_array_type_dimension == 1)) { |
0 |
0 |
0 |
|
| 333 |
0 |
| *sv_error = sv_2mortal(newSVpvf(": If it is an SPVM::BlessedObject::Array object, the type must be the byte[] type")); |
| 334 |
0 |
| return &PL_sv_undef; |
| 335 |
|
| } |
| 336 |
|
| } |
| 337 |
0 |
▶ | else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
Branch: 2 branches
| Branch | True | False | Total |
| else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
0 |
0 |
0 |
| else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
0 |
0 |
0 |
|
| 338 |
0 |
| *sv_error = sv_2mortal(newSVpvf(": If it is a reference, it must be an array reference")); |
| 339 |
0 |
| return &PL_sv_undef; |
| 340 |
|
| } |
| 341 |
|
| else { |
| 342 |
|
| // Elements |
| 343 |
0 |
| AV* av_array = (AV*)SvRV(sv_array); |
| 344 |
|
| |
| 345 |
|
| // Array length |
| 346 |
0 |
| int32_t length = av_len(av_array) + 1; |
| 347 |
|
| |
| 348 |
|
| // New array |
| 349 |
0 |
| void* spvm_array = env->new_byte_array_no_mortal(env, stack, length); |
| 350 |
|
| |
| 351 |
0 |
| int8_t* elems = env->get_elems_byte(env, stack, spvm_array); |
| 352 |
0 |
▶ | for (int32_t i = 0; i < length; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int32_t i = 0; i < length; i++) { |
0 |
0 |
0 |
|
| 353 |
0 |
| SV** sv_elem_ptr = av_fetch(av_array, i, 0); |
| 354 |
0 |
▶ | SV* sv_elem = sv_elem_ptr ? *sv_elem_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_elem = sv_elem_ptr ? *sv_elem_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 355 |
|
| |
| 356 |
0 |
▶ | if (!(SvOK(sv_elem) && !SvROK(sv_elem))) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(SvOK(sv_elem) && !SvROK(sv_elem))) { |
0 |
0 |
0 |
| if (!(SvOK(sv_elem) && !SvROK(sv_elem))) { |
0 |
0 |
0 |
|
| 357 |
0 |
| *sv_error = sv_2mortal(newSVpvf("'s %dth element must be a non-reference scalar", i + 1)); |
| 358 |
0 |
| return &PL_sv_undef; |
| 359 |
|
| } |
| 360 |
0 |
| elems[i] = (int8_t)(uint8_t)SvUV(sv_elem); |
| 361 |
|
| } |
| 362 |
|
| |
| 363 |
0 |
| sv_array = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_api, spvm_array, "SPVM::BlessedObject::Array"); |
| 364 |
|
| } |
| 365 |
|
| } |
| 366 |
|
| else { |
| 367 |
0 |
| sv_array = &PL_sv_undef; |
| 368 |
|
| } |
| 369 |
|
| |
| 370 |
0 |
| return sv_array; |
| 371 |
|
| } |
| 372 |
|
| |
| 373 |
0 |
| SV* SPVM_XS_UTIL_new_short_array(pTHX_ SV* sv_api, SV* sv_array, SV** sv_error) { |
| 374 |
0 |
| HV* hv_self = (HV*)SvRV(sv_api); |
| 375 |
|
| |
| 376 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 377 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 378 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 379 |
|
| |
| 380 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 381 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 382 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 383 |
|
| |
| 384 |
0 |
| *sv_error = &PL_sv_undef; |
| 385 |
|
| |
| 386 |
0 |
▶ | if (SvOK(sv_array)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_array)) { |
0 |
0 |
0 |
|
| 387 |
0 |
▶ | if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
0 |
0 |
0 |
| if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
0 |
0 |
0 |
|
| 388 |
0 |
| void* spvm_array = SPVM_XS_UTIL_get_spvm_object(aTHX_ sv_array); |
| 389 |
0 |
| const char* spvm_array_basic_type_name = env->get_object_basic_type_name(env, stack, spvm_array); |
| 390 |
0 |
| int32_t spvm_array_type_dimension = env->get_object_type_dimension(env, stack, spvm_array); |
| 391 |
0 |
▶ | if (!(strcmp(spvm_array_basic_type_name, "short") == 0 && spvm_array_type_dimension == 1)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(strcmp(spvm_array_basic_type_name, "short") == 0 && spvm_array_type_dimension == 1)) { |
0 |
0 |
0 |
| if (!(strcmp(spvm_array_basic_type_name, "short") == 0 && spvm_array_type_dimension == 1)) { |
0 |
0 |
0 |
|
| 392 |
0 |
| *sv_error = sv_2mortal(newSVpvf(": If it is an SPVM::BlessedObject::Array object, the type must be the short[] type")); |
| 393 |
0 |
| return &PL_sv_undef; |
| 394 |
|
| } |
| 395 |
|
| } |
| 396 |
0 |
▶ | else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
Branch: 2 branches
| Branch | True | False | Total |
| else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
0 |
0 |
0 |
| else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
0 |
0 |
0 |
|
| 397 |
0 |
| *sv_error = sv_2mortal(newSVpvf(": If it is a reference, it must be an array reference")); |
| 398 |
0 |
| return &PL_sv_undef; |
| 399 |
|
| } |
| 400 |
|
| else { |
| 401 |
|
| // Elements |
| 402 |
0 |
| AV* av_array = (AV*)SvRV(sv_array); |
| 403 |
|
| |
| 404 |
|
| // Array length |
| 405 |
0 |
| int32_t length = av_len(av_array) + 1; |
| 406 |
|
| |
| 407 |
|
| // New array |
| 408 |
0 |
| void* spvm_array = env->new_short_array_no_mortal(env, stack, length); |
| 409 |
|
| |
| 410 |
0 |
| int16_t* elems = env->get_elems_short(env, stack, spvm_array); |
| 411 |
0 |
▶ | for (int32_t i = 0; i < length; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int32_t i = 0; i < length; i++) { |
0 |
0 |
0 |
|
| 412 |
0 |
| SV** sv_elem_ptr = av_fetch(av_array, i, 0); |
| 413 |
0 |
▶ | SV* sv_elem = sv_elem_ptr ? *sv_elem_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_elem = sv_elem_ptr ? *sv_elem_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 414 |
|
| |
| 415 |
0 |
▶ | if (!(SvOK(sv_elem) && !SvROK(sv_elem))) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(SvOK(sv_elem) && !SvROK(sv_elem))) { |
0 |
0 |
0 |
| if (!(SvOK(sv_elem) && !SvROK(sv_elem))) { |
0 |
0 |
0 |
|
| 416 |
0 |
| *sv_error = sv_2mortal(newSVpvf("'s %dth element must be a non-reference scalar", i + 1)); |
| 417 |
0 |
| return &PL_sv_undef; |
| 418 |
|
| } |
| 419 |
0 |
| elems[i] = (int16_t)SvIV(sv_elem); |
| 420 |
|
| } |
| 421 |
|
| |
| 422 |
0 |
| sv_array = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_api, spvm_array, "SPVM::BlessedObject::Array"); |
| 423 |
|
| } |
| 424 |
|
| } |
| 425 |
|
| else { |
| 426 |
0 |
| sv_array = &PL_sv_undef; |
| 427 |
|
| } |
| 428 |
|
| |
| 429 |
0 |
| return sv_array; |
| 430 |
|
| } |
| 431 |
|
| |
| 432 |
0 |
| SV* SPVM_XS_UTIL_new_short_array_unsigned(pTHX_ SV* sv_api, SV* sv_array, SV** sv_error) { |
| 433 |
0 |
| HV* hv_self = (HV*)SvRV(sv_api); |
| 434 |
|
| |
| 435 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 436 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 437 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 438 |
|
| |
| 439 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 440 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 441 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 442 |
|
| |
| 443 |
0 |
| *sv_error = &PL_sv_undef; |
| 444 |
|
| |
| 445 |
0 |
▶ | if (SvOK(sv_array)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_array)) { |
0 |
0 |
0 |
|
| 446 |
0 |
▶ | if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
0 |
0 |
0 |
| if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
0 |
0 |
0 |
|
| 447 |
0 |
| void* spvm_array = SPVM_XS_UTIL_get_spvm_object(aTHX_ sv_array); |
| 448 |
0 |
| const char* spvm_array_basic_type_name = env->get_object_basic_type_name(env, stack, spvm_array); |
| 449 |
0 |
| int32_t spvm_array_type_dimension = env->get_object_type_dimension(env, stack, spvm_array); |
| 450 |
0 |
▶ | if (!(strcmp(spvm_array_basic_type_name, "short") == 0 && spvm_array_type_dimension == 1)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(strcmp(spvm_array_basic_type_name, "short") == 0 && spvm_array_type_dimension == 1)) { |
0 |
0 |
0 |
| if (!(strcmp(spvm_array_basic_type_name, "short") == 0 && spvm_array_type_dimension == 1)) { |
0 |
0 |
0 |
|
| 451 |
0 |
| *sv_error = sv_2mortal(newSVpvf(": If it is an SPVM::BlessedObject::Array object, the type must be the short[] type")); |
| 452 |
0 |
| return &PL_sv_undef; |
| 453 |
|
| } |
| 454 |
|
| } |
| 455 |
0 |
▶ | else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
Branch: 2 branches
| Branch | True | False | Total |
| else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
0 |
0 |
0 |
| else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
0 |
0 |
0 |
|
| 456 |
0 |
| *sv_error = sv_2mortal(newSVpvf(": If it is a reference, it must be an array reference")); |
| 457 |
0 |
| return &PL_sv_undef; |
| 458 |
|
| } |
| 459 |
|
| else { |
| 460 |
|
| // Elements |
| 461 |
0 |
| AV* av_array = (AV*)SvRV(sv_array); |
| 462 |
|
| |
| 463 |
|
| // Array length |
| 464 |
0 |
| int32_t length = av_len(av_array) + 1; |
| 465 |
|
| |
| 466 |
|
| // New array |
| 467 |
0 |
| void* spvm_array = env->new_short_array_no_mortal(env, stack, length); |
| 468 |
|
| |
| 469 |
0 |
| int16_t* elems = env->get_elems_short(env, stack, spvm_array); |
| 470 |
0 |
▶ | for (int32_t i = 0; i < length; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int32_t i = 0; i < length; i++) { |
0 |
0 |
0 |
|
| 471 |
0 |
| SV** sv_elem_ptr = av_fetch(av_array, i, 0); |
| 472 |
0 |
▶ | SV* sv_elem = sv_elem_ptr ? *sv_elem_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_elem = sv_elem_ptr ? *sv_elem_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 473 |
|
| |
| 474 |
0 |
▶ | if (!(SvOK(sv_elem) && !SvROK(sv_elem))) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(SvOK(sv_elem) && !SvROK(sv_elem))) { |
0 |
0 |
0 |
| if (!(SvOK(sv_elem) && !SvROK(sv_elem))) { |
0 |
0 |
0 |
|
| 475 |
0 |
| *sv_error = sv_2mortal(newSVpvf("'s %dth element must be a non-reference scalar", i + 1)); |
| 476 |
0 |
| return &PL_sv_undef; |
| 477 |
|
| } |
| 478 |
0 |
| elems[i] = (int16_t)(uint16_t)SvUV(sv_elem); |
| 479 |
|
| } |
| 480 |
|
| |
| 481 |
0 |
| sv_array = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_api, spvm_array, "SPVM::BlessedObject::Array"); |
| 482 |
|
| } |
| 483 |
|
| } |
| 484 |
|
| else { |
| 485 |
0 |
| sv_array = &PL_sv_undef; |
| 486 |
|
| } |
| 487 |
|
| |
| 488 |
0 |
| return sv_array; |
| 489 |
|
| } |
| 490 |
|
| |
| 491 |
0 |
| SV* SPVM_XS_UTIL_new_int_array(pTHX_ SV* sv_api, SV* sv_array, SV** sv_error) { |
| 492 |
0 |
| HV* hv_self = (HV*)SvRV(sv_api); |
| 493 |
|
| |
| 494 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 495 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 496 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 497 |
|
| |
| 498 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 499 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 500 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 501 |
|
| |
| 502 |
0 |
| *sv_error = &PL_sv_undef; |
| 503 |
|
| |
| 504 |
0 |
▶ | if (SvOK(sv_array)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_array)) { |
0 |
0 |
0 |
|
| 505 |
0 |
▶ | if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
0 |
0 |
0 |
| if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
0 |
0 |
0 |
|
| 506 |
0 |
| void* spvm_array = SPVM_XS_UTIL_get_spvm_object(aTHX_ sv_array); |
| 507 |
0 |
| const char* spvm_array_basic_type_name = env->get_object_basic_type_name(env, stack, spvm_array); |
| 508 |
0 |
| int32_t spvm_array_type_dimension = env->get_object_type_dimension(env, stack, spvm_array); |
| 509 |
0 |
▶ | if (!(strcmp(spvm_array_basic_type_name, "int") == 0 && spvm_array_type_dimension == 1)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(strcmp(spvm_array_basic_type_name, "int") == 0 && spvm_array_type_dimension == 1)) { |
0 |
0 |
0 |
| if (!(strcmp(spvm_array_basic_type_name, "int") == 0 && spvm_array_type_dimension == 1)) { |
0 |
0 |
0 |
|
| 510 |
0 |
| *sv_error = sv_2mortal(newSVpvf(": If it is an SPVM::BlessedObject::Array object, the type must be the int[] type")); |
| 511 |
0 |
| return &PL_sv_undef; |
| 512 |
|
| } |
| 513 |
|
| } |
| 514 |
0 |
▶ | else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
Branch: 2 branches
| Branch | True | False | Total |
| else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
0 |
0 |
0 |
| else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
0 |
0 |
0 |
|
| 515 |
0 |
| *sv_error = sv_2mortal(newSVpvf(": If it is a reference, it must be an array reference")); |
| 516 |
0 |
| return &PL_sv_undef; |
| 517 |
|
| } |
| 518 |
|
| else { |
| 519 |
|
| // Elements |
| 520 |
0 |
| AV* av_array = (AV*)SvRV(sv_array); |
| 521 |
|
| |
| 522 |
|
| // Array length |
| 523 |
0 |
| int32_t length = av_len(av_array) + 1; |
| 524 |
|
| |
| 525 |
|
| // New array |
| 526 |
0 |
| void* spvm_array = env->new_int_array_no_mortal(env, stack, length); |
| 527 |
|
| |
| 528 |
0 |
| int32_t* elems = env->get_elems_int(env, stack, spvm_array); |
| 529 |
0 |
▶ | for (int32_t i = 0; i < length; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int32_t i = 0; i < length; i++) { |
0 |
0 |
0 |
|
| 530 |
0 |
| SV** sv_elem_ptr = av_fetch(av_array, i, 0); |
| 531 |
0 |
▶ | SV* sv_elem = sv_elem_ptr ? *sv_elem_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_elem = sv_elem_ptr ? *sv_elem_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 532 |
|
| |
| 533 |
0 |
▶ | if (!(SvOK(sv_elem) && !SvROK(sv_elem))) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(SvOK(sv_elem) && !SvROK(sv_elem))) { |
0 |
0 |
0 |
| if (!(SvOK(sv_elem) && !SvROK(sv_elem))) { |
0 |
0 |
0 |
|
| 534 |
0 |
| *sv_error = sv_2mortal(newSVpvf("'s %dth element must be a non-reference scalar", i + 1)); |
| 535 |
0 |
| return &PL_sv_undef; |
| 536 |
|
| } |
| 537 |
0 |
| elems[i] = (int32_t)SvIV(sv_elem); |
| 538 |
|
| } |
| 539 |
|
| |
| 540 |
0 |
| sv_array = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_api, spvm_array, "SPVM::BlessedObject::Array"); |
| 541 |
|
| } |
| 542 |
|
| } |
| 543 |
|
| else { |
| 544 |
0 |
| sv_array = &PL_sv_undef; |
| 545 |
|
| } |
| 546 |
|
| |
| 547 |
0 |
| return sv_array; |
| 548 |
|
| } |
| 549 |
|
| |
| 550 |
0 |
| SV* SPVM_XS_UTIL_new_int_array_unsigned(pTHX_ SV* sv_api, SV* sv_array, SV** sv_error) { |
| 551 |
|
| |
| 552 |
0 |
| *sv_error = &PL_sv_undef; |
| 553 |
|
| |
| 554 |
0 |
| HV* hv_self = (HV*)SvRV(sv_api); |
| 555 |
|
| |
| 556 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 557 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 558 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 559 |
|
| |
| 560 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 561 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 562 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 563 |
|
| |
| 564 |
0 |
▶ | if (SvOK(sv_array)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_array)) { |
0 |
0 |
0 |
|
| 565 |
0 |
▶ | if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
0 |
0 |
0 |
| if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
0 |
0 |
0 |
|
| 566 |
0 |
| void* spvm_array = SPVM_XS_UTIL_get_spvm_object(aTHX_ sv_array); |
| 567 |
0 |
| const char* spvm_array_basic_type_name = env->get_object_basic_type_name(env, stack, spvm_array); |
| 568 |
0 |
| int32_t spvm_array_type_dimension = env->get_object_type_dimension(env, stack, spvm_array); |
| 569 |
0 |
▶ | if (!(strcmp(spvm_array_basic_type_name, "int") == 0 && spvm_array_type_dimension == 1)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(strcmp(spvm_array_basic_type_name, "int") == 0 && spvm_array_type_dimension == 1)) { |
0 |
0 |
0 |
| if (!(strcmp(spvm_array_basic_type_name, "int") == 0 && spvm_array_type_dimension == 1)) { |
0 |
0 |
0 |
|
| 570 |
0 |
| *sv_error = sv_2mortal(newSVpvf(": If it is an SPVM::BlessedObject::Array object, the type must be the int[] type")); |
| 571 |
0 |
| return &PL_sv_undef; |
| 572 |
|
| } |
| 573 |
|
| } |
| 574 |
0 |
▶ | else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
Branch: 2 branches
| Branch | True | False | Total |
| else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
0 |
0 |
0 |
| else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
0 |
0 |
0 |
|
| 575 |
0 |
| *sv_error = sv_2mortal(newSVpvf(": If it is a reference, it must be an array reference")); |
| 576 |
0 |
| return &PL_sv_undef; |
| 577 |
|
| } |
| 578 |
|
| else { |
| 579 |
|
| // Elements |
| 580 |
0 |
| AV* av_array = (AV*)SvRV(sv_array); |
| 581 |
|
| |
| 582 |
|
| // Array length |
| 583 |
0 |
| int32_t length = av_len(av_array) + 1; |
| 584 |
|
| |
| 585 |
|
| // New array |
| 586 |
0 |
| void* spvm_array = env->new_int_array_no_mortal(env, stack, length); |
| 587 |
|
| |
| 588 |
0 |
| int32_t* elems = env->get_elems_int(env, stack, spvm_array); |
| 589 |
0 |
▶ | for (int32_t i = 0; i < length; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int32_t i = 0; i < length; i++) { |
0 |
0 |
0 |
|
| 590 |
0 |
| SV** sv_elem_ptr = av_fetch(av_array, i, 0); |
| 591 |
0 |
▶ | SV* sv_elem = sv_elem_ptr ? *sv_elem_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_elem = sv_elem_ptr ? *sv_elem_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 592 |
|
| |
| 593 |
0 |
▶ | if (!(SvOK(sv_elem) && !SvROK(sv_elem))) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(SvOK(sv_elem) && !SvROK(sv_elem))) { |
0 |
0 |
0 |
| if (!(SvOK(sv_elem) && !SvROK(sv_elem))) { |
0 |
0 |
0 |
|
| 594 |
0 |
| *sv_error = sv_2mortal(newSVpvf("'s %dth element must be a non-reference scalar", i + 1)); |
| 595 |
0 |
| return &PL_sv_undef; |
| 596 |
|
| } |
| 597 |
0 |
| elems[i] = (int32_t)(uint32_t)SvUV(sv_elem); |
| 598 |
|
| } |
| 599 |
|
| |
| 600 |
0 |
| sv_array = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_api, spvm_array, "SPVM::BlessedObject::Array"); |
| 601 |
|
| } |
| 602 |
|
| } |
| 603 |
|
| else { |
| 604 |
0 |
| sv_array = &PL_sv_undef; |
| 605 |
|
| } |
| 606 |
|
| |
| 607 |
0 |
| return sv_array; |
| 608 |
|
| } |
| 609 |
|
| |
| 610 |
0 |
| SV* SPVM_XS_UTIL_new_long_array(pTHX_ SV* sv_api, SV* sv_array, SV** sv_error) { |
| 611 |
|
| |
| 612 |
0 |
| *sv_error = &PL_sv_undef; |
| 613 |
|
| |
| 614 |
0 |
| HV* hv_self = (HV*)SvRV(sv_api); |
| 615 |
|
| |
| 616 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 617 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 618 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 619 |
|
| |
| 620 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 621 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 622 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 623 |
|
| |
| 624 |
0 |
▶ | if (SvOK(sv_array)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_array)) { |
0 |
0 |
0 |
|
| 625 |
0 |
▶ | if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
0 |
0 |
0 |
| if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
0 |
0 |
0 |
|
| 626 |
0 |
| void* spvm_array = SPVM_XS_UTIL_get_spvm_object(aTHX_ sv_array); |
| 627 |
0 |
| const char* spvm_array_basic_type_name = env->get_object_basic_type_name(env, stack, spvm_array); |
| 628 |
0 |
| int32_t spvm_array_type_dimension = env->get_object_type_dimension(env, stack, spvm_array); |
| 629 |
0 |
▶ | if (!(strcmp(spvm_array_basic_type_name, "long") == 0 && spvm_array_type_dimension == 1)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(strcmp(spvm_array_basic_type_name, "long") == 0 && spvm_array_type_dimension == 1)) { |
0 |
0 |
0 |
| if (!(strcmp(spvm_array_basic_type_name, "long") == 0 && spvm_array_type_dimension == 1)) { |
0 |
0 |
0 |
|
| 630 |
0 |
| *sv_error = sv_2mortal(newSVpvf(": If it is an SPVM::BlessedObject::Array object, the type must be the long[] type")); |
| 631 |
0 |
| return &PL_sv_undef; |
| 632 |
|
| } |
| 633 |
|
| } |
| 634 |
0 |
▶ | else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
Branch: 2 branches
| Branch | True | False | Total |
| else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
0 |
0 |
0 |
| else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
0 |
0 |
0 |
|
| 635 |
0 |
| *sv_error = sv_2mortal(newSVpvf(": If it is a reference, it must be an array reference")); |
| 636 |
0 |
| return &PL_sv_undef; |
| 637 |
|
| } |
| 638 |
|
| else { |
| 639 |
|
| // Elements |
| 640 |
0 |
| AV* av_array = (AV*)SvRV(sv_array); |
| 641 |
|
| |
| 642 |
|
| // Array length |
| 643 |
0 |
| int32_t length = av_len(av_array) + 1; |
| 644 |
|
| |
| 645 |
|
| // New array |
| 646 |
0 |
| void* spvm_array = env->new_long_array_no_mortal(env, stack, length); |
| 647 |
|
| |
| 648 |
0 |
| int64_t* elems = env->get_elems_long(env, stack, spvm_array); |
| 649 |
0 |
▶ | for (int32_t i = 0; i < length; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int32_t i = 0; i < length; i++) { |
0 |
0 |
0 |
|
| 650 |
0 |
| SV** sv_elem_ptr = av_fetch(av_array, i, 0); |
| 651 |
0 |
▶ | SV* sv_elem = sv_elem_ptr ? *sv_elem_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_elem = sv_elem_ptr ? *sv_elem_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 652 |
|
| |
| 653 |
0 |
▶ | if (!(SvOK(sv_elem) && !SvROK(sv_elem))) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(SvOK(sv_elem) && !SvROK(sv_elem))) { |
0 |
0 |
0 |
| if (!(SvOK(sv_elem) && !SvROK(sv_elem))) { |
0 |
0 |
0 |
|
| 654 |
0 |
| *sv_error = sv_2mortal(newSVpvf("'s %dth element must be a non-reference scalar", i + 1)); |
| 655 |
0 |
| return &PL_sv_undef; |
| 656 |
|
| } |
| 657 |
0 |
| elems[i] = (int64_t)SvIV(sv_elem); |
| 658 |
|
| } |
| 659 |
|
| |
| 660 |
0 |
| sv_array = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_api, spvm_array, "SPVM::BlessedObject::Array"); |
| 661 |
|
| } |
| 662 |
|
| } |
| 663 |
|
| else { |
| 664 |
0 |
| sv_array = &PL_sv_undef; |
| 665 |
|
| } |
| 666 |
|
| |
| 667 |
0 |
| return sv_array; |
| 668 |
|
| } |
| 669 |
|
| |
| 670 |
0 |
| SV* SPVM_XS_UTIL_new_long_array_unsigned(pTHX_ SV* sv_api, SV* sv_array, SV** sv_error) { |
| 671 |
|
| |
| 672 |
0 |
| *sv_error = &PL_sv_undef; |
| 673 |
|
| |
| 674 |
0 |
| HV* hv_self = (HV*)SvRV(sv_api); |
| 675 |
|
| |
| 676 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 677 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 678 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 679 |
|
| |
| 680 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 681 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 682 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 683 |
|
| |
| 684 |
0 |
▶ | if (SvOK(sv_array)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_array)) { |
0 |
0 |
0 |
|
| 685 |
0 |
▶ | if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
0 |
0 |
0 |
| if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
0 |
0 |
0 |
|
| 686 |
0 |
| void* spvm_array = SPVM_XS_UTIL_get_spvm_object(aTHX_ sv_array); |
| 687 |
0 |
| const char* spvm_array_basic_type_name = env->get_object_basic_type_name(env, stack, spvm_array); |
| 688 |
0 |
| int32_t spvm_array_type_dimension = env->get_object_type_dimension(env, stack, spvm_array); |
| 689 |
0 |
▶ | if (!(strcmp(spvm_array_basic_type_name, "long") == 0 && spvm_array_type_dimension == 1)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(strcmp(spvm_array_basic_type_name, "long") == 0 && spvm_array_type_dimension == 1)) { |
0 |
0 |
0 |
| if (!(strcmp(spvm_array_basic_type_name, "long") == 0 && spvm_array_type_dimension == 1)) { |
0 |
0 |
0 |
|
| 690 |
0 |
| *sv_error = sv_2mortal(newSVpvf(": If it is an SPVM::BlessedObject::Array object, the type must be the long[] type")); |
| 691 |
0 |
| return &PL_sv_undef; |
| 692 |
|
| } |
| 693 |
|
| } |
| 694 |
0 |
▶ | else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
Branch: 2 branches
| Branch | True | False | Total |
| else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
0 |
0 |
0 |
| else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
0 |
0 |
0 |
|
| 695 |
0 |
| *sv_error = sv_2mortal(newSVpvf(": If it is a reference, it must be an array reference")); |
| 696 |
0 |
| return &PL_sv_undef; |
| 697 |
|
| } |
| 698 |
|
| else { |
| 699 |
|
| // Elements |
| 700 |
0 |
| AV* av_array = (AV*)SvRV(sv_array); |
| 701 |
|
| |
| 702 |
|
| // Array length |
| 703 |
0 |
| int32_t length = av_len(av_array) + 1; |
| 704 |
|
| |
| 705 |
|
| // New array |
| 706 |
0 |
| void* spvm_array = env->new_long_array_no_mortal(env, stack, length); |
| 707 |
|
| |
| 708 |
0 |
| int64_t* elems = env->get_elems_long(env, stack, spvm_array); |
| 709 |
0 |
▶ | for (int32_t i = 0; i < length; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int32_t i = 0; i < length; i++) { |
0 |
0 |
0 |
|
| 710 |
0 |
| SV** sv_elem_ptr = av_fetch(av_array, i, 0); |
| 711 |
0 |
▶ | SV* sv_elem = sv_elem_ptr ? *sv_elem_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_elem = sv_elem_ptr ? *sv_elem_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 712 |
|
| |
| 713 |
0 |
▶ | if (!(SvOK(sv_elem) && !SvROK(sv_elem))) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(SvOK(sv_elem) && !SvROK(sv_elem))) { |
0 |
0 |
0 |
| if (!(SvOK(sv_elem) && !SvROK(sv_elem))) { |
0 |
0 |
0 |
|
| 714 |
0 |
| *sv_error = sv_2mortal(newSVpvf("'s %dth element must be a non-reference scalar", i + 1)); |
| 715 |
0 |
| return &PL_sv_undef; |
| 716 |
|
| } |
| 717 |
0 |
| elems[i] = (int64_t)(uint64_t)SvUV(sv_elem); |
| 718 |
|
| } |
| 719 |
|
| |
| 720 |
0 |
| sv_array = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_api, spvm_array, "SPVM::BlessedObject::Array"); |
| 721 |
|
| } |
| 722 |
|
| } |
| 723 |
|
| else { |
| 724 |
0 |
| sv_array = &PL_sv_undef; |
| 725 |
|
| } |
| 726 |
|
| |
| 727 |
0 |
| return sv_array; |
| 728 |
|
| } |
| 729 |
|
| |
| 730 |
0 |
| SV* SPVM_XS_UTIL_new_float_array(pTHX_ SV* sv_api, SV* sv_array, SV** sv_error) { |
| 731 |
|
| |
| 732 |
0 |
| *sv_error = &PL_sv_undef; |
| 733 |
|
| |
| 734 |
0 |
| HV* hv_self = (HV*)SvRV(sv_api); |
| 735 |
|
| |
| 736 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 737 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 738 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 739 |
|
| |
| 740 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 741 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 742 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 743 |
|
| |
| 744 |
0 |
▶ | if (SvOK(sv_array)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_array)) { |
0 |
0 |
0 |
|
| 745 |
0 |
▶ | if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
0 |
0 |
0 |
| if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
0 |
0 |
0 |
|
| 746 |
0 |
| void* spvm_array = SPVM_XS_UTIL_get_spvm_object(aTHX_ sv_array); |
| 747 |
0 |
| const char* spvm_array_basic_type_name = env->get_object_basic_type_name(env, stack, spvm_array); |
| 748 |
0 |
| int32_t spvm_array_type_dimension = env->get_object_type_dimension(env, stack, spvm_array); |
| 749 |
0 |
▶ | if (!(strcmp(spvm_array_basic_type_name, "float") == 0 && spvm_array_type_dimension == 1)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(strcmp(spvm_array_basic_type_name, "float") == 0 && spvm_array_type_dimension == 1)) { |
0 |
0 |
0 |
| if (!(strcmp(spvm_array_basic_type_name, "float") == 0 && spvm_array_type_dimension == 1)) { |
0 |
0 |
0 |
|
| 750 |
0 |
| *sv_error = sv_2mortal(newSVpvf(": If it is an SPVM::BlessedObject::Array object, the type must be the float[] type")); |
| 751 |
0 |
| return &PL_sv_undef; |
| 752 |
|
| } |
| 753 |
|
| } |
| 754 |
0 |
▶ | else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
Branch: 2 branches
| Branch | True | False | Total |
| else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
0 |
0 |
0 |
| else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
0 |
0 |
0 |
|
| 755 |
0 |
| *sv_error = sv_2mortal(newSVpvf(": If it is a reference, it must be an array reference")); |
| 756 |
0 |
| return &PL_sv_undef; |
| 757 |
|
| } |
| 758 |
|
| else { |
| 759 |
|
| // Elements |
| 760 |
0 |
| AV* av_array = (AV*)SvRV(sv_array); |
| 761 |
|
| |
| 762 |
|
| // Array length |
| 763 |
0 |
| int32_t length = av_len(av_array) + 1; |
| 764 |
|
| |
| 765 |
|
| // New array |
| 766 |
0 |
| void* spvm_array = env->new_float_array_no_mortal(env, stack, length); |
| 767 |
|
| |
| 768 |
0 |
| float* elems = env->get_elems_float(env, stack, spvm_array); |
| 769 |
0 |
▶ | for (int32_t i = 0; i < length; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int32_t i = 0; i < length; i++) { |
0 |
0 |
0 |
|
| 770 |
0 |
| SV** sv_elem_ptr = av_fetch(av_array, i, 0); |
| 771 |
0 |
▶ | SV* sv_elem = sv_elem_ptr ? *sv_elem_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_elem = sv_elem_ptr ? *sv_elem_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 772 |
|
| |
| 773 |
0 |
▶ | if (!(SvOK(sv_elem) && !SvROK(sv_elem))) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(SvOK(sv_elem) && !SvROK(sv_elem))) { |
0 |
0 |
0 |
| if (!(SvOK(sv_elem) && !SvROK(sv_elem))) { |
0 |
0 |
0 |
|
| 774 |
0 |
| *sv_error = sv_2mortal(newSVpvf("'s %dth element must be a non-reference scalar", i + 1)); |
| 775 |
0 |
| return &PL_sv_undef; |
| 776 |
|
| } |
| 777 |
0 |
| elems[i] = (float)SvNV(sv_elem); |
| 778 |
|
| } |
| 779 |
|
| |
| 780 |
0 |
| sv_array = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_api, spvm_array, "SPVM::BlessedObject::Array"); |
| 781 |
|
| } |
| 782 |
|
| } |
| 783 |
|
| else { |
| 784 |
0 |
| sv_array = &PL_sv_undef; |
| 785 |
|
| } |
| 786 |
|
| |
| 787 |
0 |
| return sv_array; |
| 788 |
|
| } |
| 789 |
|
| |
| 790 |
0 |
| SV* SPVM_XS_UTIL_new_double_array(pTHX_ SV* sv_api, SV* sv_array, SV** sv_error) { |
| 791 |
|
| |
| 792 |
0 |
| *sv_error = &PL_sv_undef; |
| 793 |
|
| |
| 794 |
0 |
| HV* hv_self = (HV*)SvRV(sv_api); |
| 795 |
|
| |
| 796 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 797 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 798 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 799 |
|
| |
| 800 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 801 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 802 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 803 |
|
| |
| 804 |
0 |
▶ | if (SvOK(sv_array)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_array)) { |
0 |
0 |
0 |
|
| 805 |
0 |
▶ | if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
0 |
0 |
0 |
| if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
0 |
0 |
0 |
|
| 806 |
0 |
| void* spvm_array = SPVM_XS_UTIL_get_spvm_object(aTHX_ sv_array); |
| 807 |
0 |
| const char* spvm_array_basic_type_name = env->get_object_basic_type_name(env, stack, spvm_array); |
| 808 |
0 |
| int32_t spvm_array_type_dimension = env->get_object_type_dimension(env, stack, spvm_array); |
| 809 |
0 |
▶ | if (!(strcmp(spvm_array_basic_type_name, "double") == 0 && spvm_array_type_dimension == 1)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(strcmp(spvm_array_basic_type_name, "double") == 0 && spvm_array_type_dimension == 1)) { |
0 |
0 |
0 |
| if (!(strcmp(spvm_array_basic_type_name, "double") == 0 && spvm_array_type_dimension == 1)) { |
0 |
0 |
0 |
|
| 810 |
0 |
| *sv_error = sv_2mortal(newSVpvf(": If it is an SPVM::BlessedObject::Array object, the type must be the double[] type")); |
| 811 |
0 |
| return &PL_sv_undef; |
| 812 |
|
| } |
| 813 |
|
| } |
| 814 |
0 |
▶ | else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
Branch: 2 branches
| Branch | True | False | Total |
| else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
0 |
0 |
0 |
| else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
0 |
0 |
0 |
|
| 815 |
0 |
| *sv_error = sv_2mortal(newSVpvf(": If it is a reference, it must be an array reference")); |
| 816 |
0 |
| return &PL_sv_undef; |
| 817 |
|
| } |
| 818 |
|
| else { |
| 819 |
|
| // Elements |
| 820 |
0 |
| AV* av_array = (AV*)SvRV(sv_array); |
| 821 |
|
| |
| 822 |
|
| // Array length |
| 823 |
0 |
| int32_t length = av_len(av_array) + 1; |
| 824 |
|
| |
| 825 |
|
| // New array |
| 826 |
0 |
| void* spvm_array = env->new_double_array_no_mortal(env, stack, length); |
| 827 |
|
| |
| 828 |
0 |
| double* elems = env->get_elems_double(env, stack, spvm_array); |
| 829 |
0 |
▶ | for (int32_t i = 0; i < length; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int32_t i = 0; i < length; i++) { |
0 |
0 |
0 |
|
| 830 |
0 |
| SV** sv_elem_ptr = av_fetch(av_array, i, 0); |
| 831 |
0 |
▶ | SV* sv_elem = sv_elem_ptr ? *sv_elem_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_elem = sv_elem_ptr ? *sv_elem_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 832 |
|
| |
| 833 |
0 |
▶ | if (!(SvOK(sv_elem) && !SvROK(sv_elem))) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(SvOK(sv_elem) && !SvROK(sv_elem))) { |
0 |
0 |
0 |
| if (!(SvOK(sv_elem) && !SvROK(sv_elem))) { |
0 |
0 |
0 |
|
| 834 |
0 |
| *sv_error = sv_2mortal(newSVpvf("'s %dth element must be a non-reference scalar", i + 1)); |
| 835 |
0 |
| return &PL_sv_undef; |
| 836 |
|
| } |
| 837 |
0 |
| elems[i] = (double)SvNV(sv_elem); |
| 838 |
|
| } |
| 839 |
|
| |
| 840 |
0 |
| sv_array = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_api, spvm_array, "SPVM::BlessedObject::Array"); |
| 841 |
|
| } |
| 842 |
|
| } |
| 843 |
|
| else { |
| 844 |
0 |
| sv_array = &PL_sv_undef; |
| 845 |
|
| } |
| 846 |
|
| |
| 847 |
0 |
| return sv_array; |
| 848 |
|
| } |
| 849 |
|
| |
| 850 |
0 |
| SV* SPVM_XS_UTIL_new_string_array(pTHX_ SV* sv_api, SV* sv_array, SV** sv_error) { |
| 851 |
|
| |
| 852 |
0 |
| *sv_error = &PL_sv_undef; |
| 853 |
|
| |
| 854 |
0 |
| HV* hv_self = (HV*)SvRV(sv_api); |
| 855 |
|
| |
| 856 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 857 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 858 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 859 |
|
| |
| 860 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 861 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 862 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 863 |
|
| |
| 864 |
0 |
▶ | if (SvOK(sv_array)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_array)) { |
0 |
0 |
0 |
|
| 865 |
0 |
▶ | if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
0 |
0 |
0 |
| if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
0 |
0 |
0 |
|
| 866 |
0 |
| void* spvm_array = SPVM_XS_UTIL_get_spvm_object(aTHX_ sv_array); |
| 867 |
0 |
| const char* spvm_array_basic_type_name = env->get_object_basic_type_name(env, stack, spvm_array); |
| 868 |
0 |
| int32_t spvm_array_type_dimension = env->get_object_type_dimension(env, stack, spvm_array); |
| 869 |
0 |
▶ | if (!(strcmp(spvm_array_basic_type_name, "string") == 0 && spvm_array_type_dimension == 1)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(strcmp(spvm_array_basic_type_name, "string") == 0 && spvm_array_type_dimension == 1)) { |
0 |
0 |
0 |
| if (!(strcmp(spvm_array_basic_type_name, "string") == 0 && spvm_array_type_dimension == 1)) { |
0 |
0 |
0 |
|
| 870 |
0 |
| *sv_error = sv_2mortal(newSVpvf(": If it is an SPVM::BlessedObject::Array object, the type must be the string[] type")); |
| 871 |
0 |
| return &PL_sv_undef; |
| 872 |
|
| } |
| 873 |
|
| } |
| 874 |
0 |
▶ | else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
Branch: 2 branches
| Branch | True | False | Total |
| else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
0 |
0 |
0 |
| else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
0 |
0 |
0 |
|
| 875 |
0 |
| *sv_error = sv_2mortal(newSVpvf(": If it is a reference, it must be an array reference")); |
| 876 |
0 |
| return &PL_sv_undef; |
| 877 |
|
| } |
| 878 |
|
| else { |
| 879 |
|
| // Elements |
| 880 |
0 |
| AV* av_array = (AV*)SvRV(sv_array); |
| 881 |
|
| |
| 882 |
|
| // Array length |
| 883 |
0 |
| int32_t length = av_len(av_array) + 1; |
| 884 |
|
| |
| 885 |
|
| // New array |
| 886 |
0 |
| void* spvm_array = env->new_string_array_no_mortal(env, stack, length); |
| 887 |
|
| |
| 888 |
0 |
▶ | for (int32_t i = 0; i < length; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int32_t i = 0; i < length; i++) { |
0 |
0 |
0 |
|
| 889 |
0 |
| SV** sv_elem_ptr = av_fetch(av_array, i, 0); |
| 890 |
0 |
▶ | SV* sv_elem = sv_elem_ptr ? *sv_elem_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_elem = sv_elem_ptr ? *sv_elem_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 891 |
0 |
| SV* sv_error_elem = &PL_sv_undef; |
| 892 |
0 |
| sv_elem = SPVM_XS_UTIL_new_string(aTHX_ sv_api, sv_elem, &sv_error_elem); |
| 893 |
|
| |
| 894 |
0 |
▶ | if (SvOK(sv_error_elem)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_error_elem)) { |
0 |
0 |
0 |
|
| 895 |
0 |
| *sv_error = sv_2mortal(newSVpvf("'s %dth element must be a non-reference scalar", i + 1)); |
| 896 |
0 |
| return &PL_sv_undef; |
| 897 |
|
| } |
| 898 |
0 |
| void* spvm_elem = SPVM_XS_UTIL_get_spvm_object(aTHX_ sv_elem); |
| 899 |
0 |
| env->set_elem_string(env, stack, spvm_array, i, spvm_elem); |
| 900 |
|
| } |
| 901 |
|
| |
| 902 |
0 |
| sv_array = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_api, spvm_array, "SPVM::BlessedObject::Array"); |
| 903 |
|
| } |
| 904 |
|
| } |
| 905 |
|
| else { |
| 906 |
0 |
| sv_array = &PL_sv_undef; |
| 907 |
|
| } |
| 908 |
|
| |
| 909 |
0 |
| return sv_array; |
| 910 |
|
| } |
| 911 |
|
| |
| 912 |
402 |
| SV* SPVM_XS_UTIL_new_object_array(pTHX_ SV* sv_api, void* basic_type, SV* sv_array, SV** sv_error) { |
| 913 |
|
| |
| 914 |
402 |
| *sv_error = &PL_sv_undef; |
| 915 |
|
| |
| 916 |
402 |
| HV* hv_self = (HV*)SvRV(sv_api); |
| 917 |
|
| |
| 918 |
402 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 919 |
402 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
402 |
0 |
402 |
|
| 920 |
402 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 921 |
|
| |
| 922 |
402 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 923 |
402 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
402 |
0 |
402 |
|
| 924 |
402 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 925 |
|
| |
| 926 |
402 |
▶ | if (SvOK(sv_array)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_array)) { |
402 |
0 |
402 |
|
| 927 |
603 |
▶ | if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
201 |
201 |
402 |
| if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
201 |
0 |
201 |
|
| 928 |
201 |
| void* spvm_array = SPVM_XS_UTIL_get_spvm_object(aTHX_ sv_array); |
| 929 |
201 |
| int32_t type_dimension = 1; |
| 930 |
201 |
▶ | if (!env->isa(env, stack, spvm_array, basic_type, type_dimension)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!env->isa(env, stack, spvm_array, basic_type, type_dimension)) { |
0 |
201 |
201 |
|
| 931 |
0 |
| *sv_error = sv_2mortal(newSVpvf(": If it is an SPVM::BlessedObject::Array object, the type must satisfy type requirement")); |
| 932 |
0 |
| return &PL_sv_undef; |
| 933 |
|
| } |
| 934 |
|
| } |
| 935 |
201 |
▶ | else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
Branch: 2 branches
| Branch | True | False | Total |
| else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
201 |
0 |
201 |
| else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
0 |
201 |
201 |
|
| 936 |
0 |
| *sv_error = sv_2mortal(newSVpvf(": If it is a reference, it must be an array reference")); |
| 937 |
0 |
| return &PL_sv_undef; |
| 938 |
|
| } |
| 939 |
|
| else { |
| 940 |
|
| // Elements |
| 941 |
201 |
| AV* av_array = (AV*)SvRV(sv_array); |
| 942 |
|
| |
| 943 |
|
| // Array length |
| 944 |
201 |
| int32_t length = av_len(av_array) + 1; |
| 945 |
|
| |
| 946 |
|
| // New array |
| 947 |
201 |
| void* spvm_array = env->new_object_array_no_mortal(env, stack, basic_type, length); |
| 948 |
|
| |
| 949 |
402 |
▶ | for (int32_t index = 0; index < length; index++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int32_t index = 0; index < length; index++) { |
201 |
201 |
402 |
|
| 950 |
201 |
| SV** sv_elem_ptr = av_fetch(av_array, index, 0); |
| 951 |
201 |
▶ | SV* sv_elem = sv_elem_ptr ? *sv_elem_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_elem = sv_elem_ptr ? *sv_elem_ptr : &PL_sv_undef; |
201 |
0 |
201 |
|
| 952 |
|
| |
| 953 |
201 |
▶ | if (!SvOK(sv_elem)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!SvOK(sv_elem)) { |
0 |
201 |
201 |
|
| 954 |
0 |
| env->set_elem_object(env, stack, spvm_array, index, NULL); |
| 955 |
|
| } |
| 956 |
402 |
▶ | else if (sv_isobject(sv_elem) && sv_derived_from(sv_elem, "SPVM::BlessedObject")) { |
Branch: 2 branches
| Branch | True | False | Total |
| else if (sv_isobject(sv_elem) && sv_derived_from(sv_elem, "SPVM::BlessedObject")) { |
201 |
0 |
201 |
| else if (sv_isobject(sv_elem) && sv_derived_from(sv_elem, "SPVM::BlessedObject")) { |
201 |
0 |
201 |
|
| 957 |
201 |
| void* elem = SPVM_XS_UTIL_get_spvm_object(aTHX_ sv_elem); |
| 958 |
|
| |
| 959 |
201 |
| int32_t elem_isa = env->elem_isa(env, stack, spvm_array, elem); |
| 960 |
201 |
▶ | if (elem_isa) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (elem_isa) { |
201 |
0 |
201 |
|
| 961 |
201 |
| env->set_elem_object(env, stack, spvm_array, index, elem); |
| 962 |
|
| } |
| 963 |
|
| else { |
| 964 |
0 |
| void* spvm_elem_type_name = env->get_type_name(env, stack, elem); |
| 965 |
0 |
| const char* elem_type_name = env->get_chars(env, stack, spvm_elem_type_name); |
| 966 |
0 |
| *sv_error = sv_2mortal(newSVpvf("'s %dth element must be the \"%s\" assignable type", index + 1, elem_type_name)); |
| 967 |
0 |
| return &PL_sv_undef; |
| 968 |
|
| } |
| 969 |
|
| } |
| 970 |
|
| else { |
| 971 |
0 |
| *sv_error = sv_2mortal(newSVpvf("'s %dth element must be an SPVM::BlessedObject or undef", index + 1)); |
| 972 |
0 |
| return &PL_sv_undef; |
| 973 |
|
| } |
| 974 |
|
| } |
| 975 |
|
| |
| 976 |
201 |
| sv_array = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_api, spvm_array, "SPVM::BlessedObject::Array"); |
| 977 |
|
| } |
| 978 |
|
| } |
| 979 |
|
| else { |
| 980 |
0 |
| sv_array = &PL_sv_undef; |
| 981 |
|
| } |
| 982 |
|
| |
| 983 |
402 |
| return sv_array; |
| 984 |
|
| } |
| 985 |
|
| |
| 986 |
0 |
| SV* SPVM_XS_UTIL_new_muldim_array(pTHX_ SV* sv_api, void* basic_type, int32_t type_dimension, SV* sv_array, SV** sv_error) { |
| 987 |
|
| |
| 988 |
0 |
| *sv_error = &PL_sv_undef; |
| 989 |
|
| |
| 990 |
0 |
| HV* hv_self = (HV*)SvRV(sv_api); |
| 991 |
|
| |
| 992 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 993 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 994 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 995 |
|
| |
| 996 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 997 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 998 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 999 |
|
| |
| 1000 |
0 |
▶ | if (SvOK(sv_array)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_array)) { |
0 |
0 |
0 |
|
| 1001 |
0 |
▶ | if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
0 |
0 |
0 |
| if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
0 |
0 |
0 |
|
| 1002 |
0 |
| void* spvm_array = SPVM_XS_UTIL_get_spvm_object(aTHX_ sv_array); |
| 1003 |
0 |
▶ | if (!env->isa(env, stack, spvm_array, basic_type, type_dimension)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!env->isa(env, stack, spvm_array, basic_type, type_dimension)) { |
0 |
0 |
0 |
|
| 1004 |
0 |
| *sv_error = sv_2mortal(newSVpvf(": If it is an SPVM::BlessedObject::Array object, the type must satisfy type requirement")); |
| 1005 |
0 |
| return &PL_sv_undef; |
| 1006 |
|
| } |
| 1007 |
|
| } |
| 1008 |
0 |
▶ | else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
Branch: 2 branches
| Branch | True | False | Total |
| else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
0 |
0 |
0 |
| else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
0 |
0 |
0 |
|
| 1009 |
0 |
| *sv_error = sv_2mortal(newSVpvf(": If it is a reference, it must be an array reference")); |
| 1010 |
0 |
| return &PL_sv_undef; |
| 1011 |
|
| } |
| 1012 |
|
| else { |
| 1013 |
|
| // Elements |
| 1014 |
0 |
| AV* av_array = (AV*)SvRV(sv_array); |
| 1015 |
|
| |
| 1016 |
|
| // Array length |
| 1017 |
0 |
| int32_t length = av_len(av_array) + 1; |
| 1018 |
|
| |
| 1019 |
|
| // New array |
| 1020 |
0 |
| void* spvm_array = env->new_muldim_array_no_mortal(env, stack, basic_type, type_dimension, length); |
| 1021 |
|
| |
| 1022 |
0 |
▶ | for (int32_t index = 0; index < length; index++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int32_t index = 0; index < length; index++) { |
0 |
0 |
0 |
|
| 1023 |
0 |
| SV** sv_elem_ptr = av_fetch(av_array, index, 0); |
| 1024 |
0 |
▶ | SV* sv_elem = sv_elem_ptr ? *sv_elem_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_elem = sv_elem_ptr ? *sv_elem_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 1025 |
|
| |
| 1026 |
0 |
▶ | if (!SvOK(sv_elem)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!SvOK(sv_elem)) { |
0 |
0 |
0 |
|
| 1027 |
0 |
| env->set_elem_object(env, stack, spvm_array, index, NULL); |
| 1028 |
|
| } |
| 1029 |
0 |
▶ | else if (sv_isobject(sv_elem) && sv_derived_from(sv_elem, "SPVM::BlessedObject")) { |
Branch: 2 branches
| Branch | True | False | Total |
| else if (sv_isobject(sv_elem) && sv_derived_from(sv_elem, "SPVM::BlessedObject")) { |
0 |
0 |
0 |
| else if (sv_isobject(sv_elem) && sv_derived_from(sv_elem, "SPVM::BlessedObject")) { |
0 |
0 |
0 |
|
| 1030 |
0 |
| void* elem = SPVM_XS_UTIL_get_spvm_object(aTHX_ sv_elem); |
| 1031 |
|
| |
| 1032 |
0 |
| int32_t elem_isa = env->elem_isa(env, stack, spvm_array, elem); |
| 1033 |
0 |
▶ | if (elem_isa) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (elem_isa) { |
0 |
0 |
0 |
|
| 1034 |
0 |
| env->set_elem_object(env, stack, spvm_array, index, elem); |
| 1035 |
|
| } |
| 1036 |
|
| else { |
| 1037 |
0 |
| void* spvm_elem_type_name = env->get_type_name(env, stack, elem); |
| 1038 |
0 |
| const char* elem_type_name = env->get_chars(env, stack, spvm_elem_type_name); |
| 1039 |
0 |
| *sv_error = sv_2mortal(newSVpvf("'s %dth element must be the \"%s\" assignable type", index + 1, elem_type_name)); |
| 1040 |
0 |
| return &PL_sv_undef; |
| 1041 |
|
| } |
| 1042 |
|
| } |
| 1043 |
|
| else { |
| 1044 |
0 |
| *sv_error = sv_2mortal(newSVpvf("'s %dth element must be an SPVM::BlessedObject or undef", index + 1)); |
| 1045 |
0 |
| return &PL_sv_undef; |
| 1046 |
|
| } |
| 1047 |
|
| } |
| 1048 |
|
| |
| 1049 |
0 |
| sv_array = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_api, spvm_array, "SPVM::BlessedObject::Array"); |
| 1050 |
|
| } |
| 1051 |
|
| } |
| 1052 |
|
| else { |
| 1053 |
0 |
| sv_array = &PL_sv_undef; |
| 1054 |
|
| } |
| 1055 |
|
| |
| 1056 |
0 |
| return sv_array; |
| 1057 |
|
| } |
| 1058 |
|
| |
| 1059 |
0 |
| SV* SPVM_XS_UTIL_new_mulnum_array(pTHX_ SV* sv_api, void* basic_type, SV* sv_array, SV** sv_error) { |
| 1060 |
|
| |
| 1061 |
0 |
| *sv_error = &PL_sv_undef; |
| 1062 |
|
| |
| 1063 |
0 |
| HV* hv_self = (HV*)SvRV(sv_api); |
| 1064 |
|
| |
| 1065 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 1066 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 1067 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 1068 |
|
| |
| 1069 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 1070 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 1071 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 1072 |
|
| |
| 1073 |
0 |
▶ | if (SvOK(sv_array)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_array)) { |
0 |
0 |
0 |
|
| 1074 |
0 |
▶ | if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
0 |
0 |
0 |
| if (sv_isobject(sv_array) && sv_derived_from(sv_array, "SPVM::BlessedObject::Array")) { |
0 |
0 |
0 |
|
| 1075 |
0 |
| void* spvm_array = SPVM_XS_UTIL_get_spvm_object(aTHX_ sv_array); |
| 1076 |
0 |
| int32_t type_dimension = 1; |
| 1077 |
0 |
▶ | if (!env->isa(env, stack, spvm_array, basic_type, type_dimension)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!env->isa(env, stack, spvm_array, basic_type, type_dimension)) { |
0 |
0 |
0 |
|
| 1078 |
0 |
| *sv_error = sv_2mortal(newSVpvf(": If it is an SPVM::BlessedObject::Array object, the type must satisfy type requirement")); |
| 1079 |
0 |
| return &PL_sv_undef; |
| 1080 |
|
| } |
| 1081 |
|
| } |
| 1082 |
0 |
▶ | else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
Branch: 2 branches
| Branch | True | False | Total |
| else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
0 |
0 |
0 |
| else if (!(SvROK(sv_array) && sv_derived_from(sv_array, "ARRAY"))) { |
0 |
0 |
0 |
|
| 1083 |
0 |
| *sv_error = sv_2mortal(newSVpvf(": If it is a reference, it must be an array reference")); |
| 1084 |
0 |
| return &PL_sv_undef; |
| 1085 |
|
| } |
| 1086 |
|
| else { |
| 1087 |
0 |
| AV* av_array = (AV*)SvRV(sv_array); |
| 1088 |
|
| |
| 1089 |
0 |
| int32_t length = av_len(av_array) + 1; |
| 1090 |
|
| |
| 1091 |
|
| // Runtime |
| 1092 |
0 |
| void* runtime = env->runtime; |
| 1093 |
|
| |
| 1094 |
|
| // New array |
| 1095 |
0 |
| void* spvm_array = env->new_mulnum_array_no_mortal(env, stack, basic_type, length); |
| 1096 |
|
| |
| 1097 |
0 |
▶ | for (int32_t index = 0; index < length; index++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int32_t index = 0; index < length; index++) { |
0 |
0 |
0 |
|
| 1098 |
0 |
| SV** sv_elem_ptr = av_fetch(av_array, index, 0); |
| 1099 |
0 |
▶ | SV* sv_elem = sv_elem_ptr ? *sv_elem_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_elem = sv_elem_ptr ? *sv_elem_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 1100 |
|
| |
| 1101 |
0 |
▶ | if (SvROK(sv_elem) && sv_derived_from(sv_elem, "HASH")) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvROK(sv_elem) && sv_derived_from(sv_elem, "HASH")) { |
0 |
0 |
0 |
| if (SvROK(sv_elem) && sv_derived_from(sv_elem, "HASH")) { |
0 |
0 |
0 |
|
| 1102 |
|
| |
| 1103 |
0 |
| const char* basic_type_name = env->api->basic_type->get_name(env->runtime, basic_type); |
| 1104 |
0 |
| int32_t basic_type_fields_length = env->api->basic_type->get_fields_length(env->runtime, basic_type); |
| 1105 |
|
| |
| 1106 |
0 |
| void* elems = (void*)env->get_elems_int(env, stack, spvm_array); |
| 1107 |
|
| |
| 1108 |
0 |
| HV* hv_value = (HV*)SvRV(sv_elem); |
| 1109 |
0 |
| int32_t fields_length = basic_type_fields_length; |
| 1110 |
|
| // Field exists check |
| 1111 |
0 |
| int32_t hash_keys_length = 0; |
| 1112 |
0 |
▶ | while (hv_iternext(hv_value)) { |
Branch: 1 branch
| Branch | True | False | Total |
| while (hv_iternext(hv_value)) { |
0 |
0 |
0 |
|
| 1113 |
0 |
| hash_keys_length++; |
| 1114 |
|
| } |
| 1115 |
|
| |
| 1116 |
0 |
▶ | for (int32_t field_index = 0; field_index < basic_type_fields_length; field_index++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int32_t field_index = 0; field_index < basic_type_fields_length; field_index++) { |
0 |
0 |
0 |
|
| 1117 |
0 |
| void* mulnum_field = env->api->basic_type->get_field_by_index(runtime, basic_type, field_index); |
| 1118 |
|
| |
| 1119 |
0 |
| const char* mulnum_field_name = env->api->field->get_name(env->runtime, mulnum_field); |
| 1120 |
|
| |
| 1121 |
0 |
| SV** sv_field_value_ptr = hv_fetch(hv_value, mulnum_field_name, strlen(mulnum_field_name), 0); |
| 1122 |
|
| SV* sv_field_value; |
| 1123 |
0 |
▶ | if (sv_field_value_ptr) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (sv_field_value_ptr) { |
0 |
0 |
0 |
|
| 1124 |
0 |
| sv_field_value = *sv_field_value_ptr; |
| 1125 |
|
| } |
| 1126 |
|
| else { |
| 1127 |
0 |
| *sv_error = sv_2mortal(newSVpvf("'s %dth element's hash reference must have \"%s\" key for %s#%s field\n %s at %s line %d\n", index + 1, mulnum_field_name, basic_type_name, mulnum_field_name, __func__, FILE_NAME, __LINE__)); |
| 1128 |
0 |
| return &PL_sv_undef; |
| 1129 |
|
| } |
| 1130 |
|
| |
| 1131 |
0 |
| void* mulnum_field_basic_type = env->api->field->get_basic_type(env->runtime, mulnum_field); |
| 1132 |
0 |
| int32_t mulnum_field_basic_type_id = env->api->basic_type->get_id(env->runtime, mulnum_field_basic_type); |
| 1133 |
0 |
| switch (mulnum_field_basic_type_id) { |
| 1134 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_BYTE: { |
| 1135 |
0 |
| ((int8_t*)elems)[(fields_length * index) + field_index] = (int8_t)SvIV(sv_field_value); |
| 1136 |
0 |
| break; |
| 1137 |
|
| } |
| 1138 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_SHORT: { |
| 1139 |
0 |
| ((int16_t*)elems)[(fields_length * index) + field_index] = (int16_t)SvIV(sv_field_value); |
| 1140 |
0 |
| break; |
| 1141 |
|
| } |
| 1142 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_INT: { |
| 1143 |
0 |
| ((int32_t*)elems)[(fields_length * index) + field_index] = (int32_t)SvIV(sv_field_value); |
| 1144 |
0 |
| break; |
| 1145 |
|
| } |
| 1146 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_LONG: { |
| 1147 |
0 |
| ((int64_t*)elems)[(fields_length * index) + field_index] = (int64_t)SvIV(sv_field_value); |
| 1148 |
0 |
| break; |
| 1149 |
|
| } |
| 1150 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_FLOAT: { |
| 1151 |
0 |
| ((float*)elems)[(fields_length * index) + field_index] = (float)SvNV(sv_field_value); |
| 1152 |
0 |
| break; |
| 1153 |
|
| } |
| 1154 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_DOUBLE: { |
| 1155 |
0 |
| ((double*)elems)[(fields_length * index) + field_index] = (double)SvNV(sv_field_value); |
| 1156 |
0 |
| break; |
| 1157 |
|
| } |
| 1158 |
0 |
| default: { |
| 1159 |
|
| assert(0); |
| 1160 |
|
| } |
| 1161 |
|
| } |
| 1162 |
|
| } |
| 1163 |
|
| } |
| 1164 |
|
| else { |
| 1165 |
0 |
| *sv_error = sv_2mortal(newSVpvf("'s %dth element must be a hash reference\n %s at %s line %d\n", index + 1, __func__, FILE_NAME, __LINE__)); |
| 1166 |
0 |
| return &PL_sv_undef; |
| 1167 |
|
| } |
| 1168 |
|
| } |
| 1169 |
|
| |
| 1170 |
0 |
| sv_array = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_api, spvm_array, "SPVM::BlessedObject::Array"); |
| 1171 |
|
| } |
| 1172 |
|
| } |
| 1173 |
|
| else { |
| 1174 |
0 |
| sv_array = &PL_sv_undef; |
| 1175 |
|
| } |
| 1176 |
|
| |
| 1177 |
0 |
| return sv_array; |
| 1178 |
|
| } |
| 1179 |
|
| |
| 1180 |
|
| MODULE = SPVM::ExchangeAPI PACKAGE = SPVM::ExchangeAPI |
| 1181 |
|
| |
| 1182 |
|
| SV* |
| 1183 |
|
| _xs_call_method(...) |
| 1184 |
|
| PPCODE: |
| 1185 |
|
| { |
| 1186 |
|
| |
| 1187 |
5739 |
| int32_t args_length = items; |
| 1188 |
|
| |
| 1189 |
5739 |
| SV* sv_error_ret = &PL_sv_undef; |
| 1190 |
5739 |
| SV* sv_caller_info = &PL_sv_undef; |
| 1191 |
|
| |
| 1192 |
5739 |
| const char* method_abs_name = __func__; |
| 1193 |
5739 |
| const char* file = __FILE__; |
| 1194 |
5739 |
| int32_t line = 0; |
| 1195 |
|
| |
| 1196 |
11476 |
▶ | while (args_length > 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| while (args_length > 0) { |
11476 |
0 |
11476 |
|
| 1197 |
11476 |
| SV* sv_last = ST(args_length - 1); |
| 1198 |
11476 |
▶ | if (!sv_isobject(sv_last)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!sv_isobject(sv_last)) { |
5538 |
5938 |
11476 |
|
| 1199 |
5538 |
| break; |
| 1200 |
|
| } |
| 1201 |
|
| |
| 1202 |
5938 |
▶ | if (sv_derived_from(sv_last, "SPVM::ExchangeAPI::Error")) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (sv_derived_from(sv_last, "SPVM::ExchangeAPI::Error")) { |
0 |
5938 |
5938 |
|
| 1203 |
0 |
| sv_error_ret = sv_last; |
| 1204 |
0 |
| args_length -= 1; |
| 1205 |
|
| } |
| 1206 |
5938 |
▶ | else if (sv_derived_from(sv_last, "SPVM::ExchangeAPI::CallerInfo")) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if (sv_derived_from(sv_last, "SPVM::ExchangeAPI::CallerInfo")) { |
5737 |
201 |
5938 |
|
| 1207 |
5737 |
| sv_caller_info = sv_last; |
| 1208 |
5737 |
| args_length -= 1; |
| 1209 |
5737 |
| HV* hv_caller_info = (HV*)SvRV(sv_last); |
| 1210 |
|
| |
| 1211 |
5737 |
| SV** svp_method_abs_name = hv_fetch(hv_caller_info, "method_abs_name", 15, 0); |
| 1212 |
5737 |
▶ | if (svp_method_abs_name && SvPOK(*svp_method_abs_name)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (svp_method_abs_name && SvPOK(*svp_method_abs_name)) { |
5737 |
0 |
5737 |
| if (svp_method_abs_name && SvPOK(*svp_method_abs_name)) { |
5737 |
0 |
5737 |
|
| 1213 |
11474 |
| method_abs_name = SvPV_nolen(*svp_method_abs_name); |
| 1214 |
|
| } |
| 1215 |
|
| |
| 1216 |
5737 |
| SV** svp_file = hv_fetch(hv_caller_info, "file", 4, 0); |
| 1217 |
5737 |
▶ | if (svp_file && SvPOK(*svp_file)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (svp_file && SvPOK(*svp_file)) { |
5737 |
0 |
5737 |
| if (svp_file && SvPOK(*svp_file)) { |
5737 |
0 |
5737 |
|
| 1218 |
11474 |
| file = SvPV_nolen(*svp_file); |
| 1219 |
|
| } |
| 1220 |
|
| |
| 1221 |
5737 |
| SV** svp_line = hv_fetch(hv_caller_info, "line", 4, 0); |
| 1222 |
5737 |
▶ | if (svp_line && SvIOK(*svp_line)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (svp_line && SvIOK(*svp_line)) { |
5737 |
0 |
5737 |
| if (svp_line && SvIOK(*svp_line)) { |
5737 |
0 |
5737 |
|
| 1223 |
5737 |
| line = SvIV(*svp_line); |
| 1224 |
|
| } |
| 1225 |
|
| } |
| 1226 |
|
| else { |
| 1227 |
201 |
| break; |
| 1228 |
|
| } |
| 1229 |
|
| } |
| 1230 |
|
| |
| 1231 |
5739 |
| SV* sv_self = ST(0); |
| 1232 |
5739 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 1233 |
|
| |
| 1234 |
|
| // Env |
| 1235 |
5739 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 1236 |
5739 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
5739 |
0 |
5739 |
|
| 1237 |
5739 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 1238 |
|
| |
| 1239 |
|
| // Stack |
| 1240 |
5739 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 1241 |
5739 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
5739 |
0 |
5739 |
|
| 1242 |
5739 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 1243 |
|
| |
| 1244 |
|
| // Invocant |
| 1245 |
5739 |
| SV* sv_invocant = ST(1); |
| 1246 |
|
| |
| 1247 |
|
| // Method name |
| 1248 |
5739 |
| SV* sv_method_name = ST(2); |
| 1249 |
5739 |
| const char* method_name = SvPV_nolen(sv_method_name); |
| 1250 |
|
| |
| 1251 |
|
| // Basic Type Name |
| 1252 |
5739 |
| void* method = NULL; |
| 1253 |
5739 |
| const char* basic_type_name = NULL; |
| 1254 |
|
| int32_t class_method_call; |
| 1255 |
5739 |
▶ | if (sv_isobject(sv_invocant)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (sv_isobject(sv_invocant)) { |
5 |
5734 |
5739 |
|
| 1256 |
5 |
| class_method_call = 0; |
| 1257 |
5 |
▶ | if (!(sv_isobject(sv_invocant) && sv_derived_from(sv_invocant, "SPVM::BlessedObject::Class"))) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(sv_isobject(sv_invocant) && sv_derived_from(sv_invocant, "SPVM::BlessedObject::Class"))) { |
5 |
0 |
5 |
| if (!(sv_isobject(sv_invocant) && sv_derived_from(sv_invocant, "SPVM::BlessedObject::Class"))) { |
0 |
5 |
5 |
|
| 1258 |
0 |
| croak("$invocant must be an SPVM::BlessedObject::Class object\n %s at %s line %d\n", method_abs_name, file, line); |
| 1259 |
|
| } |
| 1260 |
|
| |
| 1261 |
5 |
| HV* hv_invocant = (HV*)SvRV(sv_invocant); |
| 1262 |
|
| |
| 1263 |
5 |
| void* object = SPVM_XS_UTIL_get_spvm_object(aTHX_ sv_invocant); |
| 1264 |
5 |
| basic_type_name = env->get_object_basic_type_name(env, stack, object); |
| 1265 |
|
| |
| 1266 |
5 |
| char* found_char = strrchr(method_name, ':'); |
| 1267 |
5 |
▶ | if (found_char) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (found_char) { |
0 |
5 |
5 |
|
| 1268 |
0 |
▶ | if (!(*(found_char - 1) == ':')) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!(*(found_char - 1) == ':')) { |
0 |
0 |
0 |
|
| 1269 |
0 |
| croak("The static method call must be valid\n %s at %s line %d\n", method_abs_name, file, line); |
| 1270 |
|
| } |
| 1271 |
0 |
| *(found_char - 1) = '\0'; |
| 1272 |
0 |
| const char* basic_type_name = method_name; |
| 1273 |
0 |
| method_name = found_char + 1; |
| 1274 |
|
| |
| 1275 |
0 |
| void* static_call_basic_type = env->api->runtime->get_basic_type_by_name(env->runtime, basic_type_name); |
| 1276 |
0 |
▶ | if (!static_call_basic_type) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!static_call_basic_type) { |
0 |
0 |
0 |
|
| 1277 |
0 |
| croak("%s class is not found\n %s at %s line %d\n", basic_type_name, method_abs_name, file, line); |
| 1278 |
|
| } |
| 1279 |
|
| |
| 1280 |
0 |
| int32_t isa = env->isa(env, stack, object, static_call_basic_type, 0); |
| 1281 |
0 |
▶ | if (!isa) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!isa) { |
0 |
0 |
0 |
|
| 1282 |
0 |
| croak("The invocant must be assinged to %s class\n %s at %s line %d\n", basic_type_name, method_abs_name, file, line); |
| 1283 |
|
| } |
| 1284 |
|
| |
| 1285 |
0 |
| method = env->api->basic_type->get_method_by_name(env->runtime, static_call_basic_type, method_name); |
| 1286 |
0 |
| *(found_char - 1) = ':'; |
| 1287 |
|
| } |
| 1288 |
|
| else { |
| 1289 |
5 |
| method = env->get_instance_method(env, stack, object, method_name); |
| 1290 |
|
| } |
| 1291 |
|
| |
| 1292 |
5 |
▶ | if (method) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (method) { |
5 |
0 |
5 |
|
| 1293 |
5 |
| int32_t is_class_method = env->api->method->is_class_method(env->runtime, method); |
| 1294 |
5 |
▶ | if (is_class_method) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (is_class_method) { |
0 |
5 |
5 |
|
| 1295 |
0 |
| method = NULL; |
| 1296 |
|
| } |
| 1297 |
|
| } |
| 1298 |
|
| |
| 1299 |
5 |
| ST(1) = sv_method_name; |
| 1300 |
5 |
| ST(2) = sv_invocant; |
| 1301 |
|
| } |
| 1302 |
|
| else { |
| 1303 |
5734 |
| class_method_call = 1; |
| 1304 |
5734 |
| basic_type_name = SvPV_nolen(sv_invocant); |
| 1305 |
5734 |
| void* basic_type = env->api->runtime->get_basic_type_by_name(env->runtime, basic_type_name); |
| 1306 |
|
| |
| 1307 |
5734 |
| method = env->api->basic_type->get_method_by_name(env->runtime, basic_type, method_name); |
| 1308 |
|
| |
| 1309 |
5734 |
▶ | if (method) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (method) { |
5734 |
0 |
5734 |
|
| 1310 |
5734 |
| int32_t is_class_method = env->api->method->is_class_method(env->runtime, method); |
| 1311 |
5734 |
▶ | if (!is_class_method) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!is_class_method) { |
0 |
5734 |
5734 |
|
| 1312 |
0 |
| method = NULL; |
| 1313 |
|
| } |
| 1314 |
|
| } |
| 1315 |
|
| } |
| 1316 |
|
| |
| 1317 |
|
| // Runtime |
| 1318 |
5739 |
| void* runtime = env->runtime; |
| 1319 |
|
| |
| 1320 |
|
| // Method not found |
| 1321 |
5739 |
▶ | if (!method) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!method) { |
0 |
5739 |
5739 |
|
| 1322 |
0 |
| croak("%s#%s method is not found\n %s at %s line %d\n", basic_type_name, method_name, method_abs_name, file, line); |
| 1323 |
|
| } |
| 1324 |
|
| |
| 1325 |
|
| // Base index of SPVM arguments |
| 1326 |
|
| int32_t spvm_args_base; |
| 1327 |
5739 |
▶ | if (class_method_call) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (class_method_call) { |
5734 |
5 |
5739 |
|
| 1328 |
5734 |
| spvm_args_base = 3; |
| 1329 |
|
| } |
| 1330 |
|
| else { |
| 1331 |
5 |
| spvm_args_base = 2; |
| 1332 |
|
| } |
| 1333 |
|
| |
| 1334 |
5739 |
| int32_t method_args_length = env->api->method->get_args_length(env->runtime, method); |
| 1335 |
5739 |
| int32_t method_required_args_length = env->api->method->get_required_args_length(env->runtime, method); |
| 1336 |
|
| |
| 1337 |
|
| // Check argument count |
| 1338 |
5739 |
| int32_t call_method_args_length = args_length - spvm_args_base; |
| 1339 |
|
| |
| 1340 |
5739 |
▶ | if (call_method_args_length < method_required_args_length) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (call_method_args_length < method_required_args_length) { |
0 |
5739 |
5739 |
|
| 1341 |
0 |
| croak("Too few arguments are passed to %s#%s method\n %s at %s line %d\n", basic_type_name, method_name, method_abs_name, file, line); |
| 1342 |
|
| } |
| 1343 |
5739 |
▶ | else if (call_method_args_length > method_args_length) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if (call_method_args_length > method_args_length) { |
0 |
5739 |
5739 |
|
| 1344 |
0 |
| call_method_args_length = method_args_length; |
| 1345 |
|
| } |
| 1346 |
|
| |
| 1347 |
5739 |
| int32_t stack_index = 0; |
| 1348 |
|
| |
| 1349 |
5739 |
| AV* av_refs = NULL; |
| 1350 |
|
| |
| 1351 |
5739 |
| int32_t has_ref_arg = 0; |
| 1352 |
10341 |
▶ | for (int32_t arg_index = 0; arg_index < method_args_length; arg_index++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int32_t arg_index = 0; arg_index < method_args_length; arg_index++) { |
4602 |
5739 |
10341 |
|
| 1353 |
4602 |
| void* arg = env->api->method->get_arg_by_index(env->runtime, method, arg_index); |
| 1354 |
4602 |
| int32_t arg_type_flag = env->api->arg->get_type_flag(env->runtime, arg); |
| 1355 |
4602 |
▶ | if (arg_type_flag & SPVM_NATIVE_C_TYPE_FLAG_REF) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (arg_type_flag & SPVM_NATIVE_C_TYPE_FLAG_REF) { |
0 |
4602 |
4602 |
|
| 1356 |
0 |
| has_ref_arg = 1; |
| 1357 |
0 |
| av_refs = (AV*)sv_2mortal((SV*)newAV()); |
| 1358 |
0 |
| break; |
| 1359 |
|
| } |
| 1360 |
|
| } |
| 1361 |
|
| |
| 1362 |
|
| // Arguments conversion |
| 1363 |
10341 |
▶ | for (int32_t arg_index = 0; arg_index < method_args_length; arg_index++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int32_t arg_index = 0; arg_index < method_args_length; arg_index++) { |
4602 |
5739 |
10341 |
|
| 1364 |
|
| |
| 1365 |
4602 |
▶ | if (arg_index >= call_method_args_length) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (arg_index >= call_method_args_length) { |
0 |
4602 |
4602 |
|
| 1366 |
0 |
| break; |
| 1367 |
|
| } |
| 1368 |
|
| |
| 1369 |
4602 |
| int32_t arg_index_nth = arg_index + (spvm_args_base - 2); |
| 1370 |
|
| |
| 1371 |
|
| // Get value from Perl argument native_stack |
| 1372 |
4602 |
| SV* sv_value = ST(spvm_args_base + arg_index); |
| 1373 |
|
| |
| 1374 |
4602 |
| void* arg = env->api->method->get_arg_by_index(env->runtime, method, arg_index); |
| 1375 |
4602 |
| void* arg_basic_type = env->api->arg->get_basic_type(env->runtime, arg); |
| 1376 |
4602 |
| int32_t arg_basic_type_id = env->api->basic_type->get_id(env->runtime, arg_basic_type); |
| 1377 |
4602 |
| int32_t arg_type_dimension = env->api->arg->get_type_dimension(env->runtime, arg); |
| 1378 |
4602 |
| int32_t arg_type_flag = env->api->arg->get_type_flag(env->runtime, arg); |
| 1379 |
4602 |
| int32_t arg_basic_type_category = env->api->basic_type->get_category(env->runtime, arg_basic_type); |
| 1380 |
|
| |
| 1381 |
4602 |
| int32_t arg_type_is_not_ref = !(arg_type_flag & SPVM_NATIVE_C_TYPE_FLAG_REF); |
| 1382 |
|
| |
| 1383 |
|
| // Argument conversion |
| 1384 |
4602 |
▶ | if (arg_type_dimension == 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (arg_type_dimension == 0) { |
4401 |
201 |
4602 |
|
| 1385 |
4401 |
▶ | if (arg_type_is_not_ref) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (arg_type_is_not_ref) { |
4401 |
0 |
4401 |
|
| 1386 |
4401 |
| switch (arg_basic_type_category) { |
| 1387 |
192 |
| case SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_NUMERIC: { |
| 1388 |
192 |
▶ | if (!(SvOK(sv_value) && !SvROK(sv_value))) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(SvOK(sv_value) && !SvROK(sv_value))) { |
192 |
0 |
192 |
| if (!(SvOK(sv_value) && !SvROK(sv_value))) { |
0 |
192 |
192 |
|
| 1389 |
0 |
| croak("The %dth argument of %s#%s method must be a non-reference scalar\n %s at %s line %d\n", arg_index_nth, basic_type_name, method_name, method_abs_name, file, line); |
| 1390 |
|
| } |
| 1391 |
|
| |
| 1392 |
192 |
| switch(arg_basic_type_id) { |
| 1393 |
|
| // Argument conversion - byte |
| 1394 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_BYTE : { |
| 1395 |
0 |
| int8_t value = (int8_t)SvIV(sv_value); |
| 1396 |
0 |
| stack[stack_index].bval = value; |
| 1397 |
0 |
| break; |
| 1398 |
|
| } |
| 1399 |
|
| // Argument conversion - short |
| 1400 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_SHORT : { |
| 1401 |
0 |
| int16_t value = (int16_t)SvIV(sv_value); |
| 1402 |
0 |
| stack[stack_index].sval = value; |
| 1403 |
0 |
| break; |
| 1404 |
|
| } |
| 1405 |
|
| // Argument conversion - int |
| 1406 |
91 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_INT : { |
| 1407 |
91 |
| int32_t value = (int32_t)SvIV(sv_value); |
| 1408 |
91 |
| stack[stack_index].ival = value; |
| 1409 |
91 |
| break; |
| 1410 |
|
| } |
| 1411 |
|
| // Argument conversion - long |
| 1412 |
77 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_LONG : { |
| 1413 |
77 |
| int64_t value = (int64_t)SvIV(sv_value); |
| 1414 |
77 |
| stack[stack_index].lval = value; |
| 1415 |
77 |
| break; |
| 1416 |
|
| } |
| 1417 |
|
| // Argument conversion - float |
| 1418 |
12 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_FLOAT : { |
| 1419 |
12 |
| float value = (float)SvNV(sv_value); |
| 1420 |
12 |
| stack[stack_index].fval = value; |
| 1421 |
12 |
| break; |
| 1422 |
|
| } |
| 1423 |
|
| // Argument conversion - double |
| 1424 |
12 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_DOUBLE : { |
| 1425 |
12 |
| double value = (double)SvNV(sv_value); |
| 1426 |
12 |
| stack[stack_index].dval = value; |
| 1427 |
12 |
| break; |
| 1428 |
|
| } |
| 1429 |
192 |
| default: { |
| 1430 |
|
| assert(0); |
| 1431 |
|
| } |
| 1432 |
|
| } |
| 1433 |
192 |
| stack_index++; |
| 1434 |
192 |
| break; |
| 1435 |
|
| } |
| 1436 |
4204 |
| case SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_STRING: { |
| 1437 |
|
| // Argument conversion - string |
| 1438 |
4204 |
| SV* sv_error = &PL_sv_undef; |
| 1439 |
4204 |
| sv_value = SPVM_XS_UTIL_new_string(aTHX_ sv_self, sv_value, &sv_error); |
| 1440 |
4204 |
▶ | if (SvOK(sv_error)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_error)) { |
0 |
4204 |
4204 |
|
| 1441 |
0 |
| croak("The %dth argument of %s#%s method%s\n %s at %s line %d\n", arg_index_nth, basic_type_name, method_name, SvPV_nolen(sv_error), method_abs_name, file, line); |
| 1442 |
|
| } |
| 1443 |
4204 |
| void* spvm_string = SPVM_XS_UTIL_get_spvm_object(aTHX_ sv_value); |
| 1444 |
|
| |
| 1445 |
4204 |
| stack[stack_index].oval = spvm_string; |
| 1446 |
|
| |
| 1447 |
4204 |
| stack_index++; |
| 1448 |
4204 |
| break; |
| 1449 |
|
| } |
| 1450 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_ANY_OBJECT: { |
| 1451 |
|
| // Argument conversion - any object |
| 1452 |
|
| void* spvm_value; |
| 1453 |
0 |
▶ | if (!SvOK(sv_value)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!SvOK(sv_value)) { |
0 |
0 |
0 |
|
| 1454 |
0 |
| spvm_value = NULL; |
| 1455 |
|
| } |
| 1456 |
|
| else { |
| 1457 |
0 |
▶ | int32_t created_as_string = SvPOK(sv_value) && !SvIsBOOL(sv_value); |
Branch: 2 branches
| Branch | True | False | Total |
| int32_t created_as_string = SvPOK(sv_value) && !SvIsBOOL(sv_value); |
0 |
0 |
0 |
| int32_t created_as_string = SvPOK(sv_value) && !SvIsBOOL(sv_value); |
0 |
0 |
0 |
|
| 1458 |
|
| |
| 1459 |
0 |
▶ | if (sv_isobject(sv_value) && sv_derived_from(sv_value, "SPVM::BlessedObject")) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (sv_isobject(sv_value) && sv_derived_from(sv_value, "SPVM::BlessedObject")) { |
0 |
0 |
0 |
| if (sv_isobject(sv_value) && sv_derived_from(sv_value, "SPVM::BlessedObject")) { |
0 |
0 |
0 |
|
| 1460 |
0 |
| spvm_value = SPVM_XS_UTIL_get_spvm_object(aTHX_ sv_value); |
| 1461 |
|
| } |
| 1462 |
0 |
▶ | else if (created_as_string) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if (created_as_string) { |
0 |
0 |
0 |
|
| 1463 |
0 |
| STRLEN length = -1; |
| 1464 |
0 |
| const char* string = SvPV(sv_value, length); |
| 1465 |
0 |
| spvm_value = env->new_string_no_mortal(env, stack, string, (int32_t)length); |
| 1466 |
0 |
| SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_self, spvm_value, "SPVM::BlessedObject::String"); |
| 1467 |
|
| } |
| 1468 |
|
| else { |
| 1469 |
0 |
| croak("The %dth argument of %s#%s method must be an SPVM::BlessedObject object or a string or undef\n %s at %s line %d\n", arg_index_nth, basic_type_name, method_name, method_abs_name, file, line); |
| 1470 |
|
| } |
| 1471 |
|
| } |
| 1472 |
0 |
| stack[stack_index].oval = spvm_value; |
| 1473 |
|
| |
| 1474 |
0 |
| stack_index++; |
| 1475 |
0 |
| break; |
| 1476 |
|
| } |
| 1477 |
5 |
| case SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_CLASS: |
| 1478 |
|
| case SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_INTERFACE: |
| 1479 |
|
| { |
| 1480 |
5 |
| int32_t error = 0; |
| 1481 |
|
| void* spvm_value; |
| 1482 |
5 |
▶ | if (!SvOK(sv_value)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!SvOK(sv_value)) { |
0 |
5 |
5 |
|
| 1483 |
0 |
| spvm_value = NULL; |
| 1484 |
|
| } |
| 1485 |
5 |
▶ | else if (sv_isobject(sv_value) && sv_derived_from(sv_value, "SPVM::BlessedObject::Class")) { |
Branch: 2 branches
| Branch | True | False | Total |
| else if (sv_isobject(sv_value) && sv_derived_from(sv_value, "SPVM::BlessedObject::Class")) { |
5 |
0 |
5 |
| else if (sv_isobject(sv_value) && sv_derived_from(sv_value, "SPVM::BlessedObject::Class")) { |
5 |
0 |
5 |
|
| 1486 |
5 |
| spvm_value = SPVM_XS_UTIL_get_spvm_object(aTHX_ sv_value); |
| 1487 |
|
| |
| 1488 |
5 |
▶ | if (!env->isa(env, stack, spvm_value, arg_basic_type, arg_type_dimension)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!env->isa(env, stack, spvm_value, arg_basic_type, arg_type_dimension)) { |
0 |
5 |
5 |
|
| 1489 |
0 |
| error = 1; |
| 1490 |
|
| } |
| 1491 |
|
| } |
| 1492 |
|
| else { |
| 1493 |
0 |
| error = 1; |
| 1494 |
|
| } |
| 1495 |
|
| |
| 1496 |
5 |
▶ | if (error) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (error) { |
0 |
5 |
5 |
|
| 1497 |
0 |
| const char* arg_basic_type_name = env->api->basic_type->get_name(env->runtime, arg_basic_type); |
| 1498 |
0 |
| void* spvm_compile_type_name = env->get_compile_type_name(env, stack, arg_basic_type_name, arg_type_dimension, arg_type_flag); |
| 1499 |
0 |
| const char* compile_type_name = env->get_chars(env, stack, spvm_compile_type_name); |
| 1500 |
0 |
| croak("The %dth argument of %s#%s method must be an SPVM::BlessedObject::Class object of a \"%s\" assignable type or undef\n %s at %s line %d\n", arg_index_nth, basic_type_name, method_name, compile_type_name, method_abs_name, file, line); |
| 1501 |
|
| } |
| 1502 |
|
| |
| 1503 |
5 |
| stack[stack_index].oval = spvm_value; |
| 1504 |
|
| |
| 1505 |
5 |
| stack_index++; |
| 1506 |
5 |
| break; |
| 1507 |
|
| } |
| 1508 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_MULNUM: |
| 1509 |
|
| { |
| 1510 |
|
| // Argument conversion - multi-numeric |
| 1511 |
0 |
▶ | if (!(SvROK(sv_value) && sv_derived_from(sv_value, "HASH"))) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(SvROK(sv_value) && sv_derived_from(sv_value, "HASH"))) { |
0 |
0 |
0 |
| if (!(SvROK(sv_value) && sv_derived_from(sv_value, "HASH"))) { |
0 |
0 |
0 |
|
| 1512 |
0 |
| croak("The %dth argument of %s#%s method must be a hash reference\n %s at %s line %d\n", arg_index_nth, basic_type_name, method_name, method_abs_name, file, line); |
| 1513 |
|
| } |
| 1514 |
|
| |
| 1515 |
0 |
| int32_t arg_basic_type_fields_length = env->api->basic_type->get_fields_length(env->runtime, arg_basic_type); |
| 1516 |
0 |
| void* arg_basic_type_field_first = env->api->basic_type->get_field_by_index(runtime, arg_basic_type, 0); |
| 1517 |
|
| |
| 1518 |
0 |
| void* arg_basic_type_field_basic_type = env->api->field->get_basic_type(env->runtime, arg_basic_type_field_first); |
| 1519 |
0 |
| int32_t arg_basic_type_field_basic_type_id = env->api->basic_type->get_id(env->runtime, arg_basic_type_field_basic_type); |
| 1520 |
|
| assert(arg_basic_type_field_basic_type_id >= 0); |
| 1521 |
|
| |
| 1522 |
0 |
| HV* hv_value = (HV*)SvRV(sv_value); |
| 1523 |
0 |
▶ | for (int32_t field_index = 0; field_index < arg_basic_type_fields_length; field_index++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int32_t field_index = 0; field_index < arg_basic_type_fields_length; field_index++) { |
0 |
0 |
0 |
|
| 1524 |
0 |
| void* mulnum_field = env->api->basic_type->get_field_by_index(runtime, arg_basic_type, field_index); |
| 1525 |
0 |
| const char* mulnum_field_name = env->api->field->get_name(env->runtime, mulnum_field); |
| 1526 |
0 |
| SV** sv_field_value_ptr = hv_fetch(hv_value, mulnum_field_name, strlen(mulnum_field_name), 0); |
| 1527 |
|
| SV* sv_field_value; |
| 1528 |
0 |
▶ | if (sv_field_value_ptr) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (sv_field_value_ptr) { |
0 |
0 |
0 |
|
| 1529 |
0 |
| sv_field_value = *sv_field_value_ptr; |
| 1530 |
|
| } |
| 1531 |
|
| else { |
| 1532 |
0 |
| const char* arg_basic_type_name = env->api->basic_type->get_name(env->runtime, arg_basic_type); |
| 1533 |
0 |
| croak("The hash reference for the %dth argument of %s#%s method must have \"%s\" key for %s#%s field\n %s at %s line %d\n", arg_index_nth, basic_type_name, method_name, mulnum_field_name, arg_basic_type_name, mulnum_field_name, method_abs_name, file, line); |
| 1534 |
|
| |
| 1535 |
|
| } |
| 1536 |
|
| |
| 1537 |
0 |
| switch (arg_basic_type_field_basic_type_id) { |
| 1538 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_BYTE: { |
| 1539 |
|
| // Argument conversion - multi-numeric byte |
| 1540 |
0 |
| int8_t value = (int8_t)SvIV(sv_field_value); |
| 1541 |
0 |
| stack[stack_index + field_index].bval = value; |
| 1542 |
0 |
| break; |
| 1543 |
|
| } |
| 1544 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_SHORT: { |
| 1545 |
|
| // Argument conversion - multi-numeric short |
| 1546 |
0 |
| int16_t value = (int16_t)SvIV(sv_field_value); |
| 1547 |
0 |
| stack[stack_index + field_index].sval = value; |
| 1548 |
0 |
| break; |
| 1549 |
|
| } |
| 1550 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_INT: { |
| 1551 |
|
| // Argument conversion - multi-numeric int |
| 1552 |
0 |
| int32_t value = (int32_t)SvIV(sv_field_value); |
| 1553 |
0 |
| stack[stack_index + field_index].ival = value; |
| 1554 |
0 |
| break; |
| 1555 |
|
| } |
| 1556 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_LONG: { |
| 1557 |
|
| // Argument conversion - multi-numeric long |
| 1558 |
0 |
| int64_t value = (int64_t)SvIV(sv_field_value); |
| 1559 |
0 |
| stack[stack_index + field_index].lval = value; |
| 1560 |
0 |
| break; |
| 1561 |
|
| } |
| 1562 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_FLOAT: { |
| 1563 |
|
| // Argument conversion - multi-numeric float |
| 1564 |
0 |
| float value = (float)SvNV(sv_field_value); |
| 1565 |
0 |
| stack[stack_index + field_index].fval = value; |
| 1566 |
0 |
| break; |
| 1567 |
|
| } |
| 1568 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_DOUBLE: { |
| 1569 |
|
| // Argument conversion - multi-numeric double |
| 1570 |
0 |
| double value = (double)SvNV(sv_field_value); |
| 1571 |
0 |
| stack[stack_index + field_index].dval = value; |
| 1572 |
0 |
| break; |
| 1573 |
|
| } |
| 1574 |
0 |
| default: { |
| 1575 |
|
| assert(0); |
| 1576 |
|
| } |
| 1577 |
|
| } |
| 1578 |
|
| } |
| 1579 |
0 |
| stack_index += arg_basic_type_fields_length; |
| 1580 |
0 |
| break; |
| 1581 |
|
| } |
| 1582 |
4401 |
| default: { |
| 1583 |
|
| assert(0); |
| 1584 |
|
| } |
| 1585 |
|
| } |
| 1586 |
|
| } |
| 1587 |
|
| // Reference argument |
| 1588 |
|
| else { |
| 1589 |
|
| |
| 1590 |
0 |
| switch (arg_basic_type_category) { |
| 1591 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_NUMERIC: { |
| 1592 |
|
| // Argument conversion - numeric reference |
| 1593 |
0 |
▶ | if (!(SvROK(sv_value) && sv_derived_from(sv_value , "SCALAR"))) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(SvROK(sv_value) && sv_derived_from(sv_value , "SCALAR"))) { |
0 |
0 |
0 |
| if (!(SvROK(sv_value) && sv_derived_from(sv_value , "SCALAR"))) { |
0 |
0 |
0 |
|
| 1594 |
0 |
| croak("The %dth argument of %s#%s method must be a scalar reference\n %s at %s line %d\n", arg_index_nth, basic_type_name, method_name, method_abs_name, file, line); |
| 1595 |
|
| } |
| 1596 |
|
| |
| 1597 |
0 |
| SV* sv_value_deref = SvRV(sv_value); |
| 1598 |
|
| |
| 1599 |
0 |
| switch (arg_basic_type_id) { |
| 1600 |
|
| // Argument conversion - byte reference |
| 1601 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_BYTE: { |
| 1602 |
0 |
| int8_t value = (int8_t)SvIV(sv_value_deref); |
| 1603 |
|
| |
| 1604 |
0 |
| SV* sv_ref = sv_2mortal(newSVpv("", 0)); |
| 1605 |
0 |
▶ | SvGROW(sv_ref, sizeof(int8_t) + 1); |
Branch: 2 branches
| Branch | True | False | Total |
| SvGROW(sv_ref, sizeof(int8_t) + 1); |
0 |
0 |
0 |
| SvGROW(sv_ref, sizeof(int8_t) + 1); |
0 |
0 |
0 |
|
| 1606 |
0 |
| int8_t* ref = (int8_t*)SvPV_nolen(sv_ref); |
| 1607 |
0 |
| memcpy((void*)ref, &value, sizeof(int8_t)); |
| 1608 |
0 |
| av_store(av_refs, arg_index,SvREFCNT_inc(sv_ref)); |
| 1609 |
0 |
| stack[stack_index].bref = ref; |
| 1610 |
|
| |
| 1611 |
0 |
| break; |
| 1612 |
|
| } |
| 1613 |
|
| // Argument conversion - short reference |
| 1614 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_SHORT: { |
| 1615 |
0 |
| int16_t value = (int16_t)SvIV(sv_value_deref); |
| 1616 |
|
| |
| 1617 |
0 |
| SV* sv_ref = sv_2mortal(newSVpv("", 0)); |
| 1618 |
0 |
▶ | SvGROW(sv_ref, sizeof(int16_t) + 1); |
Branch: 2 branches
| Branch | True | False | Total |
| SvGROW(sv_ref, sizeof(int16_t) + 1); |
0 |
0 |
0 |
| SvGROW(sv_ref, sizeof(int16_t) + 1); |
0 |
0 |
0 |
|
| 1619 |
0 |
| int16_t* ref = (int16_t*)SvPV_nolen(sv_ref); |
| 1620 |
0 |
| memcpy((void*)ref, &value, sizeof(int16_t)); |
| 1621 |
0 |
| av_store(av_refs, arg_index,SvREFCNT_inc(sv_ref)); |
| 1622 |
0 |
| stack[stack_index].sref = ref; |
| 1623 |
|
| |
| 1624 |
0 |
| break; |
| 1625 |
|
| } |
| 1626 |
|
| // Argument conversion - int reference |
| 1627 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_INT: { |
| 1628 |
0 |
| int32_t value = (int32_t)SvIV(sv_value_deref); |
| 1629 |
|
| |
| 1630 |
0 |
| SV* sv_ref = sv_2mortal(newSVpv("", 0)); |
| 1631 |
0 |
▶ | SvGROW(sv_ref, sizeof(int32_t) + 1); |
Branch: 2 branches
| Branch | True | False | Total |
| SvGROW(sv_ref, sizeof(int32_t) + 1); |
0 |
0 |
0 |
| SvGROW(sv_ref, sizeof(int32_t) + 1); |
0 |
0 |
0 |
|
| 1632 |
0 |
| int32_t* ref = (int32_t*)SvPV_nolen(sv_ref); |
| 1633 |
0 |
| memcpy((void*)ref, &value, sizeof(int32_t)); |
| 1634 |
0 |
| av_store(av_refs, arg_index,SvREFCNT_inc(sv_ref)); |
| 1635 |
0 |
| stack[stack_index].iref = ref; |
| 1636 |
|
| |
| 1637 |
0 |
| break; |
| 1638 |
|
| } |
| 1639 |
|
| // Argument conversion - long reference |
| 1640 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_LONG: { |
| 1641 |
0 |
| int64_t value = (int64_t)SvIV(sv_value_deref); |
| 1642 |
|
| |
| 1643 |
0 |
| SV* sv_ref = sv_2mortal(newSVpv("", 0)); |
| 1644 |
0 |
▶ | SvGROW(sv_ref, sizeof(int64_t) + 1); |
Branch: 2 branches
| Branch | True | False | Total |
| SvGROW(sv_ref, sizeof(int64_t) + 1); |
0 |
0 |
0 |
| SvGROW(sv_ref, sizeof(int64_t) + 1); |
0 |
0 |
0 |
|
| 1645 |
0 |
| int64_t* ref = (int64_t*)SvPV_nolen(sv_ref); |
| 1646 |
0 |
| memcpy((void*)ref, &value, sizeof(int64_t)); |
| 1647 |
0 |
| av_store(av_refs, arg_index,SvREFCNT_inc(sv_ref)); |
| 1648 |
0 |
| stack[stack_index].lref = ref; |
| 1649 |
|
| |
| 1650 |
0 |
| break; |
| 1651 |
|
| } |
| 1652 |
|
| // Argument conversion - float reference |
| 1653 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_FLOAT: { |
| 1654 |
0 |
| float value = (float)SvNV(sv_value_deref); |
| 1655 |
|
| |
| 1656 |
0 |
| SV* sv_ref = sv_2mortal(newSVpv("", 0)); |
| 1657 |
0 |
▶ | SvGROW(sv_ref, sizeof(float) + 1); |
Branch: 2 branches
| Branch | True | False | Total |
| SvGROW(sv_ref, sizeof(float) + 1); |
0 |
0 |
0 |
| SvGROW(sv_ref, sizeof(float) + 1); |
0 |
0 |
0 |
|
| 1658 |
0 |
| float* ref = (float*)SvPV_nolen(sv_ref); |
| 1659 |
0 |
| memcpy((void*)ref, &value, sizeof(float)); |
| 1660 |
0 |
| av_store(av_refs, arg_index,SvREFCNT_inc(sv_ref)); |
| 1661 |
0 |
| stack[stack_index].fref = ref; |
| 1662 |
|
| |
| 1663 |
0 |
| break; |
| 1664 |
|
| } |
| 1665 |
|
| // Argument conversion - double reference |
| 1666 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_DOUBLE: { |
| 1667 |
0 |
| double value = (double)SvNV(sv_value_deref); |
| 1668 |
|
| |
| 1669 |
0 |
| SV* sv_ref = sv_2mortal(newSVpv("", 0)); |
| 1670 |
0 |
▶ | SvGROW(sv_ref, sizeof(double) + 1); |
Branch: 2 branches
| Branch | True | False | Total |
| SvGROW(sv_ref, sizeof(double) + 1); |
0 |
0 |
0 |
| SvGROW(sv_ref, sizeof(double) + 1); |
0 |
0 |
0 |
|
| 1671 |
0 |
| double* ref = (double*)SvPV_nolen(sv_ref); |
| 1672 |
0 |
| memcpy((void*)ref, &value, sizeof(double)); |
| 1673 |
0 |
| av_store(av_refs, arg_index,SvREFCNT_inc(sv_ref)); |
| 1674 |
0 |
| stack[stack_index].dref = ref; |
| 1675 |
|
| |
| 1676 |
0 |
| break; |
| 1677 |
|
| } |
| 1678 |
|
| } |
| 1679 |
|
| |
| 1680 |
0 |
| stack_index++; |
| 1681 |
|
| |
| 1682 |
0 |
| break; |
| 1683 |
|
| } |
| 1684 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_MULNUM: |
| 1685 |
|
| { |
| 1686 |
|
| // Argument conversion - multi-numeric reference |
| 1687 |
0 |
▶ | if (!(SvROK(sv_value) && SvROK(SvRV(sv_value)) && sv_derived_from(SvRV(sv_value) , "HASH"))) { |
Branch: 3 branches
| Branch | True | False | Total |
| if (!(SvROK(sv_value) && SvROK(SvRV(sv_value)) && sv_derived_from(SvRV(sv_value) , "HASH"))) { |
0 |
0 |
0 |
| if (!(SvROK(sv_value) && SvROK(SvRV(sv_value)) && sv_derived_from(SvRV(sv_value) , "HASH"))) { |
0 |
0 |
0 |
| if (!(SvROK(sv_value) && SvROK(SvRV(sv_value)) && sv_derived_from(SvRV(sv_value) , "HASH"))) { |
0 |
0 |
0 |
|
| 1688 |
0 |
| croak("The %dth argument of %s#%s method must be a reference to a hash reference\n %s at %s line %d\n", arg_index_nth, basic_type_name, method_name, method_abs_name, file, line); |
| 1689 |
|
| } |
| 1690 |
|
| |
| 1691 |
0 |
| SV* hv_value_ref = SvRV(sv_value); |
| 1692 |
|
| |
| 1693 |
0 |
| HV* hv_value = (HV*)SvRV(hv_value_ref); |
| 1694 |
0 |
| int32_t arg_basic_type_fields_length = env->api->basic_type->get_fields_length(env->runtime, arg_basic_type); |
| 1695 |
0 |
| void* arg_basic_type_field_first = env->api->basic_type->get_field_by_index(runtime, arg_basic_type, 0); |
| 1696 |
0 |
| void* arg_basic_type_field_basic_type = env->api->field->get_basic_type(env->runtime, arg_basic_type_field_first); |
| 1697 |
0 |
| int32_t arg_basic_type_field_basic_type_id = env->api->basic_type->get_id(env->runtime, arg_basic_type_field_basic_type); |
| 1698 |
|
| assert(arg_basic_type_field_basic_type_id >= 0); |
| 1699 |
|
| |
| 1700 |
0 |
| switch(arg_basic_type_field_basic_type_id) { |
| 1701 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_BYTE: { |
| 1702 |
0 |
| SV* sv_ref = sv_2mortal(newSVpv("", 0)); |
| 1703 |
0 |
▶ | SvGROW(sv_ref, sizeof(int8_t) * arg_basic_type_fields_length + 1); |
Branch: 2 branches
| Branch | True | False | Total |
| SvGROW(sv_ref, sizeof(int8_t) * arg_basic_type_fields_length + 1); |
0 |
0 |
0 |
| SvGROW(sv_ref, sizeof(int8_t) * arg_basic_type_fields_length + 1); |
0 |
0 |
0 |
|
| 1704 |
0 |
| int8_t* ref = (int8_t*)SvPV_nolen(sv_ref); |
| 1705 |
0 |
| av_store(av_refs, arg_index,SvREFCNT_inc(sv_ref)); |
| 1706 |
0 |
| stack[stack_index].bref = ref; |
| 1707 |
|
| |
| 1708 |
0 |
| break; |
| 1709 |
|
| } |
| 1710 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_SHORT: { |
| 1711 |
0 |
| SV* sv_ref = sv_2mortal(newSVpv("", 0)); |
| 1712 |
0 |
▶ | SvGROW(sv_ref, sizeof(int16_t) * arg_basic_type_fields_length + 1); |
Branch: 2 branches
| Branch | True | False | Total |
| SvGROW(sv_ref, sizeof(int16_t) * arg_basic_type_fields_length + 1); |
0 |
0 |
0 |
| SvGROW(sv_ref, sizeof(int16_t) * arg_basic_type_fields_length + 1); |
0 |
0 |
0 |
|
| 1713 |
0 |
| int16_t* ref = (int16_t*)SvPV_nolen(sv_ref); |
| 1714 |
0 |
| av_store(av_refs, arg_index,SvREFCNT_inc(sv_ref)); |
| 1715 |
0 |
| stack[stack_index].sref = ref; |
| 1716 |
|
| |
| 1717 |
0 |
| break; |
| 1718 |
|
| } |
| 1719 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_INT: { |
| 1720 |
0 |
| SV* sv_ref = sv_2mortal(newSVpv("", 0)); |
| 1721 |
0 |
▶ | SvGROW(sv_ref, sizeof(int32_t) * arg_basic_type_fields_length + 1); |
Branch: 2 branches
| Branch | True | False | Total |
| SvGROW(sv_ref, sizeof(int32_t) * arg_basic_type_fields_length + 1); |
0 |
0 |
0 |
| SvGROW(sv_ref, sizeof(int32_t) * arg_basic_type_fields_length + 1); |
0 |
0 |
0 |
|
| 1722 |
0 |
| int32_t* ref = (int32_t*)SvPV_nolen(sv_ref); |
| 1723 |
0 |
| av_store(av_refs, arg_index,SvREFCNT_inc(sv_ref)); |
| 1724 |
0 |
| stack[stack_index].iref = ref; |
| 1725 |
|
| |
| 1726 |
0 |
| break; |
| 1727 |
|
| } |
| 1728 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_LONG: { |
| 1729 |
0 |
| SV* sv_ref = sv_2mortal(newSVpv("", 0)); |
| 1730 |
0 |
▶ | SvGROW(sv_ref, sizeof(int64_t) * arg_basic_type_fields_length + 1); |
Branch: 2 branches
| Branch | True | False | Total |
| SvGROW(sv_ref, sizeof(int64_t) * arg_basic_type_fields_length + 1); |
0 |
0 |
0 |
| SvGROW(sv_ref, sizeof(int64_t) * arg_basic_type_fields_length + 1); |
0 |
0 |
0 |
|
| 1731 |
0 |
| int64_t* ref = (int64_t*)SvPV_nolen(sv_ref); |
| 1732 |
0 |
| av_store(av_refs, arg_index,SvREFCNT_inc(sv_ref)); |
| 1733 |
0 |
| stack[stack_index].lref = ref; |
| 1734 |
|
| |
| 1735 |
0 |
| break; |
| 1736 |
|
| } |
| 1737 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_FLOAT: { |
| 1738 |
0 |
| SV* sv_ref = sv_2mortal(newSVpv("", 0)); |
| 1739 |
0 |
▶ | SvGROW(sv_ref, sizeof(float) * arg_basic_type_fields_length + 1); |
Branch: 2 branches
| Branch | True | False | Total |
| SvGROW(sv_ref, sizeof(float) * arg_basic_type_fields_length + 1); |
0 |
0 |
0 |
| SvGROW(sv_ref, sizeof(float) * arg_basic_type_fields_length + 1); |
0 |
0 |
0 |
|
| 1740 |
0 |
| float* ref = (float*)SvPV_nolen(sv_ref); |
| 1741 |
0 |
| av_store(av_refs, arg_index,SvREFCNT_inc(sv_ref)); |
| 1742 |
0 |
| stack[stack_index].fref = ref; |
| 1743 |
|
| |
| 1744 |
0 |
| break; |
| 1745 |
|
| } |
| 1746 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_DOUBLE: { |
| 1747 |
0 |
| SV* sv_ref = sv_2mortal(newSVpv("", 0)); |
| 1748 |
0 |
▶ | SvGROW(sv_ref, sizeof(double) * arg_basic_type_fields_length + 1); |
Branch: 2 branches
| Branch | True | False | Total |
| SvGROW(sv_ref, sizeof(double) * arg_basic_type_fields_length + 1); |
0 |
0 |
0 |
| SvGROW(sv_ref, sizeof(double) * arg_basic_type_fields_length + 1); |
0 |
0 |
0 |
|
| 1749 |
0 |
| double* ref = (double*)SvPV_nolen(sv_ref); |
| 1750 |
0 |
| av_store(av_refs, arg_index,SvREFCNT_inc(sv_ref)); |
| 1751 |
0 |
| stack[stack_index].dref = ref; |
| 1752 |
|
| |
| 1753 |
0 |
| break; |
| 1754 |
|
| } |
| 1755 |
0 |
| default: { |
| 1756 |
|
| assert(0); |
| 1757 |
|
| } |
| 1758 |
|
| } |
| 1759 |
|
| |
| 1760 |
0 |
▶ | for (int32_t field_index = 0; field_index < arg_basic_type_fields_length; field_index++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int32_t field_index = 0; field_index < arg_basic_type_fields_length; field_index++) { |
0 |
0 |
0 |
|
| 1761 |
0 |
| void* mulnum_field = env->api->basic_type->get_field_by_index(runtime, arg_basic_type, field_index); |
| 1762 |
0 |
| const char* mulnum_field_name = env->api->field->get_name(env->runtime, mulnum_field); |
| 1763 |
0 |
| SV** sv_field_value_ptr = hv_fetch(hv_value, mulnum_field_name, strlen(mulnum_field_name), 0); |
| 1764 |
|
| SV* sv_field_value; |
| 1765 |
0 |
▶ | if (sv_field_value_ptr) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (sv_field_value_ptr) { |
0 |
0 |
0 |
|
| 1766 |
0 |
| sv_field_value = *sv_field_value_ptr; |
| 1767 |
|
| } |
| 1768 |
|
| else { |
| 1769 |
0 |
| const char* arg_basic_type_name = env->api->basic_type->get_name(env->runtime, arg_basic_type); |
| 1770 |
0 |
| croak("The hash reference for the %dth argument of %s#%s method must have \"%s\" key for %s#%s field\n %s at %s line %d\n", arg_index_nth, basic_type_name, method_name, mulnum_field_name, arg_basic_type_name, mulnum_field_name, method_abs_name, file, line); |
| 1771 |
|
| } |
| 1772 |
0 |
| switch(arg_basic_type_field_basic_type_id) { |
| 1773 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_BYTE: { |
| 1774 |
|
| // Argument conversion - multi-numeric byte reference |
| 1775 |
0 |
| int8_t value = (int8_t)SvIV(sv_field_value); |
| 1776 |
|
| |
| 1777 |
0 |
| SV** sv_ref_ptr = av_fetch(av_refs, arg_index, 0); |
| 1778 |
0 |
▶ | SV* sv_ref = sv_ref_ptr ? *sv_ref_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_ref = sv_ref_ptr ? *sv_ref_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 1779 |
0 |
| int8_t* ref = (int8_t*)SvPV_nolen(sv_ref); |
| 1780 |
0 |
| memcpy((void*)(ref + field_index), &value, sizeof(int8_t)); |
| 1781 |
|
| |
| 1782 |
0 |
| break; |
| 1783 |
|
| } |
| 1784 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_SHORT: { |
| 1785 |
|
| // Argument conversion - multi-numeric short reference |
| 1786 |
0 |
| int16_t value = (int16_t)SvIV(sv_field_value); |
| 1787 |
|
| |
| 1788 |
0 |
| SV** sv_ref_ptr = av_fetch(av_refs, arg_index, 0); |
| 1789 |
0 |
▶ | SV* sv_ref = sv_ref_ptr ? *sv_ref_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_ref = sv_ref_ptr ? *sv_ref_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 1790 |
0 |
| int16_t* ref = (int16_t*)SvPV_nolen(sv_ref); |
| 1791 |
0 |
| memcpy((void*)(ref + field_index), &value, sizeof(int16_t)); |
| 1792 |
|
| |
| 1793 |
0 |
| break; |
| 1794 |
|
| } |
| 1795 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_INT: { |
| 1796 |
|
| // Argument conversion - multi-numeric int reference |
| 1797 |
0 |
| int32_t value = (int32_t)SvIV(sv_field_value); |
| 1798 |
|
| |
| 1799 |
0 |
| SV** sv_ref_ptr = av_fetch(av_refs, arg_index, 0); |
| 1800 |
0 |
▶ | SV* sv_ref = sv_ref_ptr ? *sv_ref_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_ref = sv_ref_ptr ? *sv_ref_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 1801 |
0 |
| int32_t* ref = (int32_t*)SvPV_nolen(sv_ref); |
| 1802 |
0 |
| memcpy((void*)(ref + field_index), &value, sizeof(int32_t)); |
| 1803 |
|
| |
| 1804 |
0 |
| break; |
| 1805 |
|
| } |
| 1806 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_LONG: { |
| 1807 |
|
| // Argument conversion - multi-numeric long reference |
| 1808 |
0 |
| int64_t value = (int64_t)SvIV(sv_field_value); |
| 1809 |
|
| |
| 1810 |
0 |
| SV** sv_ref_ptr = av_fetch(av_refs, arg_index, 0); |
| 1811 |
0 |
▶ | SV* sv_ref = sv_ref_ptr ? *sv_ref_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_ref = sv_ref_ptr ? *sv_ref_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 1812 |
0 |
| int64_t* ref = (int64_t*)SvPV_nolen(sv_ref); |
| 1813 |
0 |
| memcpy((void*)(ref + field_index), &value, sizeof(int64_t)); |
| 1814 |
|
| |
| 1815 |
0 |
| break; |
| 1816 |
|
| } |
| 1817 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_FLOAT: { |
| 1818 |
|
| // Argument conversion - multi-numeric float reference |
| 1819 |
0 |
| float value = (float)SvNV(sv_field_value); |
| 1820 |
|
| |
| 1821 |
0 |
| SV** sv_ref_ptr = av_fetch(av_refs, arg_index, 0); |
| 1822 |
0 |
▶ | SV* sv_ref = sv_ref_ptr ? *sv_ref_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_ref = sv_ref_ptr ? *sv_ref_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 1823 |
0 |
| float* ref = (float*)SvPV_nolen(sv_ref); |
| 1824 |
0 |
| memcpy((void*)(ref + field_index), &value, sizeof(float)); |
| 1825 |
|
| |
| 1826 |
0 |
| break; |
| 1827 |
|
| } |
| 1828 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_DOUBLE: { |
| 1829 |
|
| // Argument conversion - multi-numeric double reference |
| 1830 |
0 |
| double value = (double)SvNV(sv_field_value); |
| 1831 |
|
| |
| 1832 |
0 |
| SV** sv_ref_ptr = av_fetch(av_refs, arg_index, 0); |
| 1833 |
0 |
▶ | SV* sv_ref = sv_ref_ptr ? *sv_ref_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_ref = sv_ref_ptr ? *sv_ref_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 1834 |
0 |
| double* ref = (double*)SvPV_nolen(sv_ref); |
| 1835 |
0 |
| memcpy((void*)(ref + field_index), &value, sizeof(double)); |
| 1836 |
|
| |
| 1837 |
0 |
| break; |
| 1838 |
|
| } |
| 1839 |
0 |
| default: { |
| 1840 |
|
| assert(0); |
| 1841 |
|
| } |
| 1842 |
|
| } |
| 1843 |
|
| } |
| 1844 |
|
| |
| 1845 |
0 |
| stack_index++; |
| 1846 |
0 |
| break; |
| 1847 |
|
| } |
| 1848 |
4401 |
| default: { |
| 1849 |
|
| assert(0); |
| 1850 |
|
| } |
| 1851 |
|
| } |
| 1852 |
|
| } |
| 1853 |
|
| } |
| 1854 |
201 |
▶ | else if (arg_type_dimension == 1) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if (arg_type_dimension == 1) { |
201 |
0 |
201 |
|
| 1855 |
201 |
| switch (arg_basic_type_category) { |
| 1856 |
|
| // Argument conversion - numeric array |
| 1857 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_NUMERIC: { |
| 1858 |
0 |
| SV* sv_error = &PL_sv_undef; |
| 1859 |
0 |
| switch (arg_basic_type_id) { |
| 1860 |
|
| // Argument conversion - byte array |
| 1861 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_BYTE: { |
| 1862 |
0 |
| sv_value = SPVM_XS_UTIL_new_byte_array(aTHX_ sv_self, sv_value, &sv_error); |
| 1863 |
0 |
| break; |
| 1864 |
|
| } |
| 1865 |
|
| // Argument conversion - short array |
| 1866 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_SHORT: { |
| 1867 |
0 |
| sv_value = SPVM_XS_UTIL_new_short_array(aTHX_ sv_self, sv_value, &sv_error); |
| 1868 |
0 |
| break; |
| 1869 |
|
| } |
| 1870 |
|
| // Argument conversion - int array |
| 1871 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_INT: { |
| 1872 |
0 |
| sv_value = SPVM_XS_UTIL_new_int_array(aTHX_ sv_self, sv_value, &sv_error); |
| 1873 |
0 |
| break; |
| 1874 |
|
| } |
| 1875 |
|
| // Argument conversion - long array |
| 1876 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_LONG: { |
| 1877 |
0 |
| sv_value = SPVM_XS_UTIL_new_long_array(aTHX_ sv_self, sv_value, &sv_error); |
| 1878 |
0 |
| break; |
| 1879 |
|
| } |
| 1880 |
|
| // Argument conversion - float array |
| 1881 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_FLOAT: { |
| 1882 |
0 |
| sv_value = SPVM_XS_UTIL_new_float_array(aTHX_ sv_self, sv_value, &sv_error); |
| 1883 |
0 |
| break; |
| 1884 |
|
| } |
| 1885 |
|
| // Argument conversion - double array |
| 1886 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_DOUBLE: { |
| 1887 |
0 |
| sv_value = SPVM_XS_UTIL_new_double_array(aTHX_ sv_self, sv_value, &sv_error); |
| 1888 |
0 |
| break; |
| 1889 |
|
| } |
| 1890 |
0 |
| default: { |
| 1891 |
|
| assert(0); |
| 1892 |
|
| } |
| 1893 |
|
| } |
| 1894 |
|
| |
| 1895 |
0 |
▶ | if (SvOK(sv_error)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_error)) { |
0 |
0 |
0 |
|
| 1896 |
0 |
| croak("The %dth argument of %s#%s method%s\n %s at %s line %d\n", arg_index_nth, basic_type_name, method_name, SvPV_nolen(sv_error), method_abs_name, file, line); |
| 1897 |
|
| } |
| 1898 |
|
| |
| 1899 |
0 |
| void* spvm_array = SPVM_XS_UTIL_get_spvm_object(aTHX_ sv_value); |
| 1900 |
|
| |
| 1901 |
0 |
| stack[stack_index].oval = spvm_array; |
| 1902 |
|
| |
| 1903 |
0 |
| stack_index++; |
| 1904 |
0 |
| break; |
| 1905 |
|
| } |
| 1906 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_MULNUM: |
| 1907 |
|
| { |
| 1908 |
0 |
| SV* sv_error = &PL_sv_undef; |
| 1909 |
0 |
| sv_value = SPVM_XS_UTIL_new_mulnum_array(aTHX_ sv_self, arg_basic_type, sv_value, &sv_error); |
| 1910 |
|
| |
| 1911 |
0 |
▶ | if (SvOK(sv_error)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_error)) { |
0 |
0 |
0 |
|
| 1912 |
0 |
| croak("The %dth argument of %s#%s method%s\n %s at %s line %d\n", arg_index_nth, basic_type_name, method_name, SvPV_nolen(sv_error), method_abs_name, file, line); |
| 1913 |
|
| } |
| 1914 |
|
| |
| 1915 |
0 |
| void* spvm_array = SPVM_XS_UTIL_get_spvm_object(aTHX_ sv_value); |
| 1916 |
|
| |
| 1917 |
0 |
| stack[stack_index].oval = spvm_array; |
| 1918 |
|
| |
| 1919 |
0 |
| stack_index++; |
| 1920 |
0 |
| break; |
| 1921 |
|
| } |
| 1922 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_STRING: { |
| 1923 |
0 |
| SV* sv_error = &PL_sv_undef; |
| 1924 |
|
| |
| 1925 |
0 |
| sv_value = SPVM_XS_UTIL_new_string_array(aTHX_ sv_self, sv_value, &sv_error); |
| 1926 |
|
| |
| 1927 |
0 |
▶ | if (SvOK(sv_error)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_error)) { |
0 |
0 |
0 |
|
| 1928 |
0 |
| croak("The %dth argument of %s#%s method%s\n %s at %s line %d\n", arg_index_nth, basic_type_name, method_name, SvPV_nolen(sv_error), method_abs_name, file, line); |
| 1929 |
|
| } |
| 1930 |
|
| |
| 1931 |
0 |
| void* spvm_array = SPVM_XS_UTIL_get_spvm_object(aTHX_ sv_value); |
| 1932 |
|
| |
| 1933 |
0 |
| stack[stack_index].oval = spvm_array; |
| 1934 |
|
| |
| 1935 |
0 |
| stack_index++; |
| 1936 |
0 |
| break; |
| 1937 |
|
| } |
| 1938 |
201 |
| case SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_CLASS: |
| 1939 |
|
| case SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_INTERFACE: |
| 1940 |
|
| case SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_ANY_OBJECT: |
| 1941 |
|
| { |
| 1942 |
201 |
| SV* sv_error = &PL_sv_undef; |
| 1943 |
|
| |
| 1944 |
201 |
| sv_value = SPVM_XS_UTIL_new_object_array(aTHX_ sv_self, arg_basic_type, sv_value, &sv_error); |
| 1945 |
|
| |
| 1946 |
201 |
▶ | if (SvOK(sv_error)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_error)) { |
0 |
201 |
201 |
|
| 1947 |
0 |
| croak("The %dth argument of %s#%s method%s\n %s at %s line %d\n", arg_index_nth, basic_type_name, method_name, SvPV_nolen(sv_error), method_abs_name, file, line); |
| 1948 |
|
| } |
| 1949 |
|
| |
| 1950 |
201 |
| void* spvm_array = SPVM_XS_UTIL_get_spvm_object(aTHX_ sv_value); |
| 1951 |
|
| |
| 1952 |
201 |
| stack[stack_index].oval = spvm_array; |
| 1953 |
|
| |
| 1954 |
201 |
| stack_index++; |
| 1955 |
201 |
| break; |
| 1956 |
|
| } |
| 1957 |
201 |
| default: { |
| 1958 |
|
| assert(0); |
| 1959 |
|
| } |
| 1960 |
|
| } |
| 1961 |
|
| } |
| 1962 |
0 |
▶ | else if (arg_type_dimension > 1) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if (arg_type_dimension > 1) { |
0 |
0 |
0 |
|
| 1963 |
|
| |
| 1964 |
|
| // Argument conversion - multi-type_dimensional array |
| 1965 |
0 |
| SV* sv_error = &PL_sv_undef; |
| 1966 |
|
| |
| 1967 |
0 |
| sv_value = SPVM_XS_UTIL_new_muldim_array(aTHX_ sv_self, arg_basic_type, arg_type_dimension, sv_value, &sv_error); |
| 1968 |
|
| |
| 1969 |
0 |
▶ | if (SvOK(sv_error)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_error)) { |
0 |
0 |
0 |
|
| 1970 |
0 |
| croak("The %dth argument of %s#%s method%s\n %s at %s line %d\n", arg_index_nth, basic_type_name, method_name, SvPV_nolen(sv_error), method_abs_name, file, line); |
| 1971 |
|
| } |
| 1972 |
|
| |
| 1973 |
0 |
| void* spvm_array = SPVM_XS_UTIL_get_spvm_object(aTHX_ sv_value); |
| 1974 |
|
| |
| 1975 |
0 |
| stack[stack_index].oval = spvm_array; |
| 1976 |
|
| |
| 1977 |
0 |
| stack_index++; |
| 1978 |
0 |
| break; |
| 1979 |
|
| } |
| 1980 |
|
| else { |
| 1981 |
|
| assert(0); |
| 1982 |
|
| } |
| 1983 |
|
| } |
| 1984 |
|
| |
| 1985 |
|
| // Return |
| 1986 |
5739 |
| void* method_return_basic_type = env->api->method->get_return_basic_type(env->runtime, method); |
| 1987 |
5739 |
| int32_t method_return_basic_type_id = env->api->basic_type->get_id(env->runtime, method_return_basic_type); |
| 1988 |
5739 |
| int32_t method_return_type_dimension = env->api->method->get_return_type_dimension(env->runtime, method); |
| 1989 |
|
| |
| 1990 |
5739 |
| int32_t method_return_basic_type_category = env->api->basic_type->get_category(env->runtime, method_return_basic_type); |
| 1991 |
|
| |
| 1992 |
|
| // Call method |
| 1993 |
5739 |
| int32_t call_method_args_width = stack_index; |
| 1994 |
5739 |
| int32_t error_id = env->call_method_no_mortal(env, stack, method, call_method_args_width, method_abs_name, file, line); |
| 1995 |
|
| |
| 1996 |
5739 |
▶ | if (error_id) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (error_id) { |
11 |
5728 |
5739 |
|
| 1997 |
11 |
▶ | if (SvOK(sv_error_ret)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_error_ret)) { |
0 |
11 |
11 |
|
| 1998 |
0 |
| HV* hv_error_ret = (HV*)SvRV(sv_error_ret); |
| 1999 |
0 |
| SV* sv_error_id = sv_2mortal(newSViv(error_id)); |
| 2000 |
0 |
| (void)hv_store(hv_error_ret, "id", strlen("id"), SvREFCNT_inc(sv_error_id), 0); |
| 2001 |
|
| } |
| 2002 |
|
| |
| 2003 |
11 |
| int32_t scope_id = env->enter_scope(env, stack); |
| 2004 |
|
| |
| 2005 |
|
| /* Reconstruct the exception message including the SPVM stack trace */ |
| 2006 |
|
| /* level = 0 starts from the caller of this XS function in the SPVM world */ |
| 2007 |
11 |
| void* obj_exception_with_stack_trace = env->build_exception_message(env, stack, 0); |
| 2008 |
|
| |
| 2009 |
11 |
| const char* exception_chars_with_stack_trace = env->get_chars(env, stack, obj_exception_with_stack_trace); |
| 2010 |
11 |
| int32_t exception_with_stack_trace_length = env->length(env, stack, obj_exception_with_stack_trace); |
| 2011 |
|
| |
| 2012 |
|
| /* Convert the SPVM string to a Perl SV */ |
| 2013 |
11 |
| SV* sv_exception = sv_2mortal(newSVpvn(exception_chars_with_stack_trace, exception_with_stack_trace_length)); |
| 2014 |
|
| |
| 2015 |
11 |
| env->leave_scope(env, stack, scope_id); |
| 2016 |
|
| |
| 2017 |
|
| /* Rethrow the exception to the Perl world using croak. |
| 2018 |
|
| The SPVM stack trace is followed by the Perl XS location information. |
| 2019 |
|
| */ |
| 2020 |
11 |
| croak("%s\n (C function %s at %s line %d)\n", |
| 2021 |
|
| SvPV_nolen(sv_exception), |
| 2022 |
|
| method_abs_name, |
| 2023 |
|
| file, |
| 2024 |
|
| line |
| 2025 |
|
| ); |
| 2026 |
|
| } |
| 2027 |
|
| |
| 2028 |
|
| // Return value conversion |
| 2029 |
5728 |
| SV* sv_return_value = NULL; |
| 2030 |
5728 |
▶ | if (method_return_type_dimension == 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (method_return_type_dimension == 0) { |
5727 |
1 |
5728 |
|
| 2031 |
5727 |
| switch (method_return_basic_type_category) { |
| 2032 |
|
| // Return value conversion - void |
| 2033 |
8 |
| case SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_VOID: { |
| 2034 |
8 |
| break; |
| 2035 |
|
| } |
| 2036 |
|
| // Return value conversion - numeric |
| 2037 |
5283 |
| case SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_NUMERIC: { |
| 2038 |
5283 |
| switch (method_return_basic_type_id) { |
| 2039 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_BYTE: { |
| 2040 |
|
| // Return value conversion - byte |
| 2041 |
0 |
| sv_return_value = sv_2mortal(newSViv(stack[0].bval)); |
| 2042 |
0 |
| break; |
| 2043 |
|
| } |
| 2044 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_SHORT: { |
| 2045 |
|
| // Return value conversion - short |
| 2046 |
0 |
| sv_return_value = sv_2mortal(newSViv(stack[0].sval)); |
| 2047 |
0 |
| break; |
| 2048 |
|
| } |
| 2049 |
1232 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_INT: { |
| 2050 |
|
| // Return value conversion - int |
| 2051 |
1232 |
| sv_return_value = sv_2mortal(newSViv(stack[0].ival)); |
| 2052 |
1232 |
| break; |
| 2053 |
|
| } |
| 2054 |
33 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_LONG: { |
| 2055 |
|
| // Return value conversion - long |
| 2056 |
33 |
| sv_return_value = sv_2mortal(newSViv(stack[0].lval)); |
| 2057 |
33 |
| break; |
| 2058 |
|
| } |
| 2059 |
8 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_FLOAT: { |
| 2060 |
|
| // Return value conversion - float |
| 2061 |
8 |
| sv_return_value = sv_2mortal(newSVnv(stack[0].fval)); |
| 2062 |
8 |
| break; |
| 2063 |
|
| } |
| 2064 |
4010 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_DOUBLE: { |
| 2065 |
|
| // Return value conversion - double |
| 2066 |
4010 |
| sv_return_value = sv_2mortal(newSVnv(stack[0].dval)); |
| 2067 |
4010 |
| break; |
| 2068 |
|
| } |
| 2069 |
5283 |
| default: { |
| 2070 |
|
| assert(0); |
| 2071 |
|
| } |
| 2072 |
|
| } |
| 2073 |
5283 |
| break; |
| 2074 |
|
| } |
| 2075 |
|
| // Return value conversion - multi-numeric |
| 2076 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_MULNUM: |
| 2077 |
|
| { |
| 2078 |
0 |
| int32_t method_return_basic_type_fields_length = env->api->basic_type->get_fields_length(env->runtime, method_return_basic_type); |
| 2079 |
0 |
| void* method_return_mulnum_field = env->api->basic_type->get_field_by_index(runtime, method_return_basic_type, 0); |
| 2080 |
0 |
| void* method_return_mulnum_field_basic_type = env->api->field->get_basic_type(env->runtime, method_return_mulnum_field); |
| 2081 |
0 |
| int32_t method_return_mulnum_field_basic_type_id = env->api->basic_type->get_id(env->runtime, method_return_mulnum_field_basic_type); |
| 2082 |
|
| |
| 2083 |
0 |
| HV* hv_value = (HV*)sv_2mortal((SV*)newHV()); |
| 2084 |
0 |
▶ | for (int32_t field_index = 0; field_index < method_return_basic_type_fields_length; field_index++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int32_t field_index = 0; field_index < method_return_basic_type_fields_length; field_index++) { |
0 |
0 |
0 |
|
| 2085 |
0 |
| SV* sv_field_value = NULL; |
| 2086 |
0 |
| switch (method_return_mulnum_field_basic_type_id) { |
| 2087 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_BYTE: { |
| 2088 |
|
| // Return value conversion - multi-numeric byte |
| 2089 |
0 |
| sv_field_value = sv_2mortal(newSViv(stack[field_index].bval)); |
| 2090 |
0 |
| break; |
| 2091 |
|
| } |
| 2092 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_SHORT: { |
| 2093 |
|
| // Return value conversion - multi-numeric short |
| 2094 |
0 |
| sv_field_value = sv_2mortal(newSViv(stack[field_index].sval)); |
| 2095 |
0 |
| break; |
| 2096 |
|
| } |
| 2097 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_INT: { |
| 2098 |
|
| // Return value conversion - multi-numeric int |
| 2099 |
0 |
| sv_field_value = sv_2mortal(newSViv(stack[field_index].ival)); |
| 2100 |
0 |
| break; |
| 2101 |
|
| } |
| 2102 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_LONG: { |
| 2103 |
|
| // Return value conversion - multi-numeric long |
| 2104 |
0 |
| sv_field_value = sv_2mortal(newSViv(stack[field_index].lval)); |
| 2105 |
0 |
| break; |
| 2106 |
|
| } |
| 2107 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_FLOAT: { |
| 2108 |
|
| // Return value conversion - multi-numeric float |
| 2109 |
0 |
| sv_field_value = sv_2mortal(newSVnv(stack[field_index].fval)); |
| 2110 |
0 |
| break; |
| 2111 |
|
| } |
| 2112 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_DOUBLE: { |
| 2113 |
|
| // Return value conversion - multi-numeric double |
| 2114 |
0 |
| sv_field_value = sv_2mortal(newSVnv(stack[field_index].dval)); |
| 2115 |
0 |
| break; |
| 2116 |
|
| } |
| 2117 |
0 |
| default: { |
| 2118 |
|
| assert(0); |
| 2119 |
|
| } |
| 2120 |
|
| } |
| 2121 |
|
| |
| 2122 |
0 |
| void* mulnum_field = env->api->basic_type->get_field_by_index(runtime, method_return_basic_type, field_index); |
| 2123 |
0 |
| const char* mulnum_field_name = env->api->field->get_name(env->runtime, mulnum_field); |
| 2124 |
0 |
| (void)hv_store(hv_value, mulnum_field_name, strlen(mulnum_field_name), SvREFCNT_inc(sv_field_value), 0); |
| 2125 |
0 |
| sv_return_value = sv_2mortal(newRV_inc((SV*)hv_value)); |
| 2126 |
|
| } |
| 2127 |
0 |
| break; |
| 2128 |
|
| } |
| 2129 |
238 |
| case SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_STRING: { |
| 2130 |
|
| // Return value conversion - string |
| 2131 |
238 |
| void* return_value = (void*)stack[0].oval; |
| 2132 |
238 |
| sv_return_value = NULL; |
| 2133 |
238 |
▶ | if (return_value != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (return_value != NULL) { |
238 |
0 |
238 |
|
| 2134 |
238 |
| sv_return_value = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_self, return_value, "SPVM::BlessedObject::String"); |
| 2135 |
|
| } |
| 2136 |
|
| // undef |
| 2137 |
|
| else { |
| 2138 |
0 |
| sv_return_value = &PL_sv_undef; |
| 2139 |
|
| } |
| 2140 |
238 |
| break; |
| 2141 |
|
| } |
| 2142 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_ANY_OBJECT: |
| 2143 |
|
| { |
| 2144 |
|
| // Return value conversion - any object |
| 2145 |
0 |
| void* return_value = (void*)stack[0].oval; |
| 2146 |
0 |
| sv_return_value = NULL; |
| 2147 |
0 |
▶ | if (return_value != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (return_value != NULL) { |
0 |
0 |
0 |
|
| 2148 |
0 |
| const char* return_value_basic_type_name = env->get_object_basic_type_name(env, stack, return_value); |
| 2149 |
0 |
| int32_t return_value_type_dimension = env->get_object_type_dimension(env, stack, return_value); |
| 2150 |
0 |
▶ | if (return_value_type_dimension > 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (return_value_type_dimension > 0) { |
0 |
0 |
0 |
|
| 2151 |
0 |
| sv_return_value = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_self, return_value, "SPVM::BlessedObject::Array"); |
| 2152 |
|
| } |
| 2153 |
|
| else { |
| 2154 |
0 |
▶ | if (strcmp(return_value_basic_type_name, "string") == 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(return_value_basic_type_name, "string") == 0) { |
0 |
0 |
0 |
|
| 2155 |
0 |
| sv_return_value = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_self, return_value, "SPVM::BlessedObject::String"); |
| 2156 |
|
| } |
| 2157 |
|
| else { |
| 2158 |
0 |
| sv_return_value = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_self, return_value, "SPVM::BlessedObject::Class"); |
| 2159 |
|
| } |
| 2160 |
|
| } |
| 2161 |
|
| } |
| 2162 |
|
| // undef |
| 2163 |
|
| else { |
| 2164 |
0 |
| sv_return_value = &PL_sv_undef; |
| 2165 |
|
| } |
| 2166 |
0 |
| break; |
| 2167 |
|
| } |
| 2168 |
198 |
| case SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_CLASS: |
| 2169 |
|
| case SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_INTERFACE: |
| 2170 |
|
| { |
| 2171 |
198 |
| void* return_value = (void*)stack[0].oval; |
| 2172 |
198 |
| sv_return_value = NULL; |
| 2173 |
198 |
▶ | if (return_value != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (return_value != NULL) { |
198 |
0 |
198 |
|
| 2174 |
198 |
| sv_return_value = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_self, return_value, "SPVM::BlessedObject::Class"); |
| 2175 |
|
| } |
| 2176 |
|
| // undef |
| 2177 |
|
| else { |
| 2178 |
0 |
| sv_return_value = &PL_sv_undef; |
| 2179 |
|
| } |
| 2180 |
198 |
| break; |
| 2181 |
|
| } |
| 2182 |
5727 |
| default: { |
| 2183 |
|
| assert(0); |
| 2184 |
|
| } |
| 2185 |
|
| } |
| 2186 |
|
| } |
| 2187 |
1 |
▶ | else if (method_return_type_dimension > 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if (method_return_type_dimension > 0) { |
1 |
0 |
1 |
|
| 2188 |
|
| // Return value conversion - array |
| 2189 |
1 |
| void* return_value = (void*)stack[0].oval; |
| 2190 |
1 |
| sv_return_value = NULL; |
| 2191 |
1 |
▶ | if (return_value != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (return_value != NULL) { |
1 |
0 |
1 |
|
| 2192 |
1 |
| sv_return_value = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_self, return_value, "SPVM::BlessedObject::Array"); |
| 2193 |
|
| } |
| 2194 |
|
| else { |
| 2195 |
0 |
| sv_return_value = &PL_sv_undef; |
| 2196 |
|
| } |
| 2197 |
|
| } |
| 2198 |
|
| |
| 2199 |
|
| // Restore reference |
| 2200 |
5728 |
▶ | if (has_ref_arg) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (has_ref_arg) { |
0 |
5728 |
5728 |
|
| 2201 |
0 |
▶ | for (int32_t arg_index = 0; arg_index < method_args_length; arg_index++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int32_t arg_index = 0; arg_index < method_args_length; arg_index++) { |
0 |
0 |
0 |
|
| 2202 |
0 |
| SV* sv_value = ST(spvm_args_base + arg_index); |
| 2203 |
|
| |
| 2204 |
|
| // Argument type |
| 2205 |
0 |
| void* arg = env->api->method->get_arg_by_index(env->runtime, method, arg_index); |
| 2206 |
0 |
| void* arg_basic_type = env->api->arg->get_basic_type(env->runtime, arg); |
| 2207 |
0 |
| int32_t arg_basic_type_id = env->api->basic_type->get_id(env->runtime, arg_basic_type); |
| 2208 |
0 |
| int32_t arg_type_dimension = env->api->arg->get_type_dimension(env->runtime, arg); |
| 2209 |
0 |
| int32_t arg_type_flag = env->api->arg->get_type_flag(env->runtime, arg); |
| 2210 |
0 |
| int32_t arg_basic_type_category = env->api->basic_type->get_category(env->runtime, arg_basic_type); |
| 2211 |
|
| |
| 2212 |
|
| // Restore reference - numeric |
| 2213 |
0 |
▶ | if (arg_type_flag & SPVM_NATIVE_C_TYPE_FLAG_REF) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (arg_type_flag & SPVM_NATIVE_C_TYPE_FLAG_REF) { |
0 |
0 |
0 |
|
| 2214 |
0 |
| switch (arg_basic_type_category) { |
| 2215 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_NUMERIC: { |
| 2216 |
0 |
| switch (arg_basic_type_id) { |
| 2217 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_BYTE : { |
| 2218 |
|
| // Restore reference - byte |
| 2219 |
0 |
| SV* sv_value_deref = SvRV(sv_value); |
| 2220 |
0 |
| SV** sv_ref_ptr = av_fetch(av_refs, arg_index, 0); |
| 2221 |
0 |
▶ | SV* sv_ref = sv_ref_ptr ? *sv_ref_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_ref = sv_ref_ptr ? *sv_ref_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2222 |
0 |
| int8_t* ref = (int8_t*)SvPV_nolen(sv_ref); |
| 2223 |
0 |
| sv_setiv(sv_value_deref, *ref); |
| 2224 |
|
| |
| 2225 |
0 |
| break; |
| 2226 |
|
| } |
| 2227 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_SHORT : { |
| 2228 |
|
| // Restore reference - short |
| 2229 |
0 |
| SV* sv_value_deref = SvRV(sv_value); |
| 2230 |
0 |
| SV** sv_ref_ptr = av_fetch(av_refs, arg_index, 0); |
| 2231 |
0 |
▶ | SV* sv_ref = sv_ref_ptr ? *sv_ref_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_ref = sv_ref_ptr ? *sv_ref_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2232 |
0 |
| int16_t* ref = (int16_t*)SvPV_nolen(sv_ref); |
| 2233 |
0 |
| sv_setiv(sv_value_deref, *ref); |
| 2234 |
|
| |
| 2235 |
0 |
| break; |
| 2236 |
|
| } |
| 2237 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_INT : { |
| 2238 |
|
| // Restore reference - int |
| 2239 |
0 |
| SV* sv_value_deref = SvRV(sv_value); |
| 2240 |
0 |
| SV** sv_ref_ptr = av_fetch(av_refs, arg_index, 0); |
| 2241 |
0 |
▶ | SV* sv_ref = sv_ref_ptr ? *sv_ref_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_ref = sv_ref_ptr ? *sv_ref_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2242 |
0 |
| int32_t* ref = (int32_t*)SvPV_nolen(sv_ref); |
| 2243 |
0 |
| sv_setiv(sv_value_deref, *ref); |
| 2244 |
|
| |
| 2245 |
0 |
| break; |
| 2246 |
|
| } |
| 2247 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_LONG : { |
| 2248 |
|
| // Restore reference - long |
| 2249 |
0 |
| SV* sv_value_deref = SvRV(sv_value); |
| 2250 |
0 |
| SV** sv_ref_ptr = av_fetch(av_refs, arg_index, 0); |
| 2251 |
0 |
▶ | SV* sv_ref = sv_ref_ptr ? *sv_ref_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_ref = sv_ref_ptr ? *sv_ref_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2252 |
0 |
| int64_t* ref = (int64_t*)SvPV_nolen(sv_ref); |
| 2253 |
0 |
| sv_setiv(sv_value_deref, *ref); |
| 2254 |
|
| |
| 2255 |
0 |
| break; |
| 2256 |
|
| } |
| 2257 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_FLOAT : { |
| 2258 |
|
| // Restore reference - float |
| 2259 |
0 |
| SV* sv_value_deref = SvRV(sv_value); |
| 2260 |
0 |
| SV** sv_ref_ptr = av_fetch(av_refs, arg_index, 0); |
| 2261 |
0 |
▶ | SV* sv_ref = sv_ref_ptr ? *sv_ref_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_ref = sv_ref_ptr ? *sv_ref_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2262 |
0 |
| float* ref = (float*)SvPV_nolen(sv_ref); |
| 2263 |
0 |
| sv_setnv(sv_value_deref, *ref); |
| 2264 |
|
| |
| 2265 |
0 |
| break; |
| 2266 |
|
| } |
| 2267 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_DOUBLE : { |
| 2268 |
|
| // Restore reference - double |
| 2269 |
0 |
| SV* sv_value_deref = SvRV(sv_value); |
| 2270 |
0 |
| SV** sv_ref_ptr = av_fetch(av_refs, arg_index, 0); |
| 2271 |
0 |
▶ | SV* sv_ref = sv_ref_ptr ? *sv_ref_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_ref = sv_ref_ptr ? *sv_ref_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2272 |
0 |
| double* ref = (double*)SvPV_nolen(sv_ref); |
| 2273 |
0 |
| sv_setnv(sv_value_deref, *ref); |
| 2274 |
|
| |
| 2275 |
0 |
| break; |
| 2276 |
|
| } |
| 2277 |
0 |
| default: { |
| 2278 |
|
| assert(0); |
| 2279 |
|
| } |
| 2280 |
|
| } |
| 2281 |
0 |
| break; |
| 2282 |
|
| } |
| 2283 |
|
| // Restore reference value - multi-numeric |
| 2284 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_MULNUM: |
| 2285 |
|
| { |
| 2286 |
0 |
| HV* hv_value = (HV*)SvRV(SvRV(sv_value)); |
| 2287 |
0 |
| int32_t arg_basic_type_fields_length = env->api->basic_type->get_fields_length(env->runtime, arg_basic_type); |
| 2288 |
0 |
| void* arg_basic_type_field_first = env->api->basic_type->get_field_by_index(runtime, arg_basic_type, 0); |
| 2289 |
0 |
| void* arg_basic_type_field_basic_type = env->api->field->get_basic_type(env->runtime, arg_basic_type_field_first); |
| 2290 |
0 |
| int32_t arg_basic_type_field_basic_type_id = env->api->basic_type->get_id(env->runtime, arg_basic_type_field_basic_type); |
| 2291 |
0 |
▶ | for (int32_t field_index = 0; field_index < arg_basic_type_fields_length; field_index++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int32_t field_index = 0; field_index < arg_basic_type_fields_length; field_index++) { |
0 |
0 |
0 |
|
| 2292 |
0 |
| void* mulnum_field = env->api->basic_type->get_field_by_index(runtime, arg_basic_type, field_index); |
| 2293 |
0 |
| const char* mulnum_field_name = env->api->field->get_name(env->runtime, mulnum_field); |
| 2294 |
|
| SV* sv_field_value; |
| 2295 |
0 |
| switch (arg_basic_type_field_basic_type_id) { |
| 2296 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_BYTE: { |
| 2297 |
|
| // Restore reference value - multi-numeric byte |
| 2298 |
0 |
| SV** sv_ref_ptr = av_fetch(av_refs, arg_index, 0); |
| 2299 |
0 |
▶ | SV* sv_ref = sv_ref_ptr ? *sv_ref_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_ref = sv_ref_ptr ? *sv_ref_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2300 |
0 |
| int8_t* ref = (int8_t*)SvPV_nolen(sv_ref); |
| 2301 |
0 |
| sv_field_value = sv_2mortal(newSViv(*(ref + field_index))); |
| 2302 |
|
| |
| 2303 |
0 |
| break; |
| 2304 |
|
| } |
| 2305 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_SHORT: { |
| 2306 |
|
| // Restore reference value - multi-numeric short |
| 2307 |
0 |
| SV** sv_ref_ptr = av_fetch(av_refs, arg_index, 0); |
| 2308 |
0 |
▶ | SV* sv_ref = sv_ref_ptr ? *sv_ref_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_ref = sv_ref_ptr ? *sv_ref_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2309 |
0 |
| int16_t* ref = (int16_t*)SvPV_nolen(sv_ref); |
| 2310 |
0 |
| sv_field_value = sv_2mortal(newSViv(*(ref + field_index))); |
| 2311 |
|
| |
| 2312 |
0 |
| break; |
| 2313 |
|
| } |
| 2314 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_INT: { |
| 2315 |
|
| // Restore reference value - multi-numeric int |
| 2316 |
0 |
| SV** sv_ref_ptr = av_fetch(av_refs, arg_index, 0); |
| 2317 |
0 |
▶ | SV* sv_ref = sv_ref_ptr ? *sv_ref_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_ref = sv_ref_ptr ? *sv_ref_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2318 |
0 |
| int32_t* ref = (int32_t*)SvPV_nolen(sv_ref); |
| 2319 |
0 |
| sv_field_value = sv_2mortal(newSViv(*(ref + field_index))); |
| 2320 |
|
| |
| 2321 |
0 |
| break; |
| 2322 |
|
| } |
| 2323 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_LONG: { |
| 2324 |
|
| // Restore reference value - multi-numeric long |
| 2325 |
0 |
| SV** sv_ref_ptr = av_fetch(av_refs, arg_index, 0); |
| 2326 |
0 |
▶ | SV* sv_ref = sv_ref_ptr ? *sv_ref_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_ref = sv_ref_ptr ? *sv_ref_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2327 |
0 |
| int64_t* ref = (int64_t*)SvPV_nolen(sv_ref); |
| 2328 |
0 |
| sv_field_value = sv_2mortal(newSViv(*(ref + field_index))); |
| 2329 |
|
| |
| 2330 |
0 |
| break; |
| 2331 |
|
| } |
| 2332 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_FLOAT: { |
| 2333 |
|
| // Restore reference value - multi-numeric float |
| 2334 |
0 |
| SV** sv_ref_ptr = av_fetch(av_refs, arg_index, 0); |
| 2335 |
0 |
▶ | SV* sv_ref = sv_ref_ptr ? *sv_ref_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_ref = sv_ref_ptr ? *sv_ref_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2336 |
0 |
| float* ref = (float*)SvPV_nolen(sv_ref); |
| 2337 |
0 |
| sv_field_value = sv_2mortal(newSVnv(*(ref + field_index))); |
| 2338 |
|
| |
| 2339 |
0 |
| break; |
| 2340 |
|
| } |
| 2341 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_DOUBLE: { |
| 2342 |
|
| // Restore reference value - multi-numeric double |
| 2343 |
0 |
| SV** sv_ref_ptr = av_fetch(av_refs, arg_index, 0); |
| 2344 |
0 |
▶ | SV* sv_ref = sv_ref_ptr ? *sv_ref_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_ref = sv_ref_ptr ? *sv_ref_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2345 |
0 |
| double* ref = (double*)SvPV_nolen(sv_ref); |
| 2346 |
0 |
| sv_field_value = sv_2mortal(newSVnv(*(ref + field_index))); |
| 2347 |
|
| |
| 2348 |
0 |
| break; |
| 2349 |
|
| } |
| 2350 |
0 |
| default: { |
| 2351 |
|
| assert(0); |
| 2352 |
|
| } |
| 2353 |
|
| } |
| 2354 |
0 |
| (void)hv_store(hv_value, mulnum_field_name, strlen(mulnum_field_name), SvREFCNT_inc(sv_field_value), 0); |
| 2355 |
|
| } |
| 2356 |
|
| } |
| 2357 |
|
| } |
| 2358 |
|
| } |
| 2359 |
|
| else { |
| 2360 |
|
| assert(0); |
| 2361 |
|
| } |
| 2362 |
|
| } |
| 2363 |
|
| } |
| 2364 |
|
| |
| 2365 |
|
| // Count of return value |
| 2366 |
|
| int32_t return_count; |
| 2367 |
5728 |
▶ | if (method_return_type_dimension == 0 && method_return_basic_type_category == SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_VOID) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (method_return_type_dimension == 0 && method_return_basic_type_category == SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_VOID) { |
5727 |
1 |
5728 |
| if (method_return_type_dimension == 0 && method_return_basic_type_category == SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_VOID) { |
8 |
5719 |
5727 |
|
| 2368 |
8 |
| return_count = 0; |
| 2369 |
|
| } |
| 2370 |
|
| else { |
| 2371 |
5720 |
▶ | XPUSHs(sv_return_value); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_return_value); |
0 |
5720 |
5720 |
|
| 2372 |
5720 |
| return_count = 1; |
| 2373 |
|
| } |
| 2374 |
|
| |
| 2375 |
5728 |
| XSRETURN(return_count); |
| 2376 |
|
| } |
| 2377 |
|
| |
| 2378 |
|
| SV* |
| 2379 |
|
| _xs_dump(...) |
| 2380 |
|
| PPCODE: |
| 2381 |
|
| { |
| 2382 |
|
| |
| 2383 |
0 |
| SV* sv_self = ST(0); |
| 2384 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 2385 |
|
| |
| 2386 |
|
| // Env |
| 2387 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 2388 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2389 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 2390 |
|
| |
| 2391 |
|
| // Stack |
| 2392 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 2393 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2394 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 2395 |
|
| |
| 2396 |
0 |
| SV* sv_object = ST(1); |
| 2397 |
|
| |
| 2398 |
|
| // Array must be an SPVM::BlessedObject or SPVM::BlessedObject |
| 2399 |
0 |
▶ | if (SvOK(sv_object)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_object)) { |
0 |
0 |
0 |
|
| 2400 |
0 |
▶ | if (!(SvROK(sv_object) && sv_derived_from(sv_object, "SPVM::BlessedObject"))) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(SvROK(sv_object) && sv_derived_from(sv_object, "SPVM::BlessedObject"))) { |
0 |
0 |
0 |
| if (!(SvROK(sv_object) && sv_derived_from(sv_object, "SPVM::BlessedObject"))) { |
0 |
0 |
0 |
|
| 2401 |
0 |
| croak("$object must be an SPVM::BlessedObject object\n %s at %s line %d\n", __func__, FILE_NAME, __LINE__); |
| 2402 |
|
| } |
| 2403 |
|
| } |
| 2404 |
|
| |
| 2405 |
|
| // Get object |
| 2406 |
0 |
| void* object = SPVM_XS_UTIL_get_spvm_object(aTHX_ sv_object); |
| 2407 |
|
| |
| 2408 |
0 |
| void* spvm_dump = env->dump_no_mortal(env, stack, object); |
| 2409 |
|
| |
| 2410 |
0 |
| const char* dump = env->get_chars(env, stack, spvm_dump); |
| 2411 |
0 |
| int32_t dump_length = env->length(env, stack, spvm_dump); |
| 2412 |
|
| |
| 2413 |
0 |
| SV* sv_dump = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_self, spvm_dump, "SPVM::BlessedObject::String"); |
| 2414 |
|
| |
| 2415 |
0 |
▶ | XPUSHs(sv_dump); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_dump); |
0 |
0 |
0 |
|
| 2416 |
0 |
| XSRETURN(1); |
| 2417 |
|
| } |
| 2418 |
|
| |
| 2419 |
|
| SV* |
| 2420 |
|
| _xs_new_string(...) |
| 2421 |
|
| PPCODE: |
| 2422 |
|
| { |
| 2423 |
|
| |
| 2424 |
11 |
| SV* sv_self = ST(0); |
| 2425 |
11 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 2426 |
|
| |
| 2427 |
|
| // Env |
| 2428 |
11 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 2429 |
11 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
11 |
0 |
11 |
|
| 2430 |
11 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 2431 |
|
| |
| 2432 |
|
| // Stack |
| 2433 |
11 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 2434 |
11 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
11 |
0 |
11 |
|
| 2435 |
11 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 2436 |
|
| |
| 2437 |
11 |
| SV* sv_string = ST(1); |
| 2438 |
|
| |
| 2439 |
11 |
| SV* sv_error = &PL_sv_undef; |
| 2440 |
11 |
| sv_string = SPVM_XS_UTIL_new_string(aTHX_ sv_self, sv_string, &sv_error); |
| 2441 |
|
| |
| 2442 |
11 |
▶ | if (SvOK(sv_error)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_error)) { |
0 |
11 |
11 |
|
| 2443 |
0 |
| croak("$string%s\n %s at %s line %d\n", SvPV_nolen(sv_error), __func__, FILE_NAME, __LINE__); |
| 2444 |
|
| } |
| 2445 |
|
| |
| 2446 |
11 |
▶ | XPUSHs(sv_string); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_string); |
0 |
11 |
11 |
|
| 2447 |
11 |
| XSRETURN(1); |
| 2448 |
|
| } |
| 2449 |
|
| |
| 2450 |
|
| SV* |
| 2451 |
|
| _xs_new_address_object(...) |
| 2452 |
|
| PPCODE: |
| 2453 |
|
| { |
| 2454 |
|
| |
| 2455 |
0 |
| int32_t error_id = 0; |
| 2456 |
|
| |
| 2457 |
0 |
| SV* sv_self = ST(0); |
| 2458 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 2459 |
|
| |
| 2460 |
|
| // Env |
| 2461 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 2462 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2463 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 2464 |
|
| |
| 2465 |
|
| // Stack |
| 2466 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 2467 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2468 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 2469 |
|
| |
| 2470 |
0 |
| SV* sv_address = ST(1); |
| 2471 |
|
| |
| 2472 |
0 |
| SV* sv_error = &PL_sv_undef; |
| 2473 |
0 |
| sv_address = SPVM_XS_UTIL_new_address_object(aTHX_ sv_self, sv_address, &sv_error); |
| 2474 |
|
| |
| 2475 |
0 |
▶ | if (SvOK(sv_error)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_error)) { |
0 |
0 |
0 |
|
| 2476 |
0 |
| croak("$address%s\n %s at %s line %d\n", SvPV_nolen(sv_error), __func__, FILE_NAME, __LINE__); |
| 2477 |
|
| } |
| 2478 |
|
| |
| 2479 |
0 |
▶ | XPUSHs(sv_address); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_address); |
0 |
0 |
0 |
|
| 2480 |
0 |
| XSRETURN(1); |
| 2481 |
|
| } |
| 2482 |
|
| |
| 2483 |
|
| SV* |
| 2484 |
|
| _xs_new_byte_array(...) |
| 2485 |
|
| PPCODE: |
| 2486 |
|
| { |
| 2487 |
|
| |
| 2488 |
0 |
| SV* sv_self = ST(0); |
| 2489 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 2490 |
|
| |
| 2491 |
|
| // Env |
| 2492 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 2493 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2494 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 2495 |
|
| |
| 2496 |
|
| // Stack |
| 2497 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 2498 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2499 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 2500 |
|
| |
| 2501 |
0 |
| SV* sv_array = ST(1); |
| 2502 |
|
| |
| 2503 |
0 |
| SV* sv_error = &PL_sv_undef; |
| 2504 |
0 |
| sv_array = SPVM_XS_UTIL_new_byte_array(aTHX_ sv_self, sv_array, &sv_error); |
| 2505 |
|
| |
| 2506 |
0 |
▶ | if (SvOK(sv_error)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_error)) { |
0 |
0 |
0 |
|
| 2507 |
0 |
| croak("$array%s\n %s at %s line %d\n", SvPV_nolen(sv_error), __func__, FILE_NAME, __LINE__); |
| 2508 |
|
| } |
| 2509 |
|
| |
| 2510 |
0 |
▶ | XPUSHs(sv_array); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_array); |
0 |
0 |
0 |
|
| 2511 |
0 |
| XSRETURN(1); |
| 2512 |
|
| } |
| 2513 |
|
| |
| 2514 |
|
| SV* |
| 2515 |
|
| _xs_new_byte_array_unsigned(...) |
| 2516 |
|
| PPCODE: |
| 2517 |
|
| { |
| 2518 |
|
| |
| 2519 |
0 |
| SV* sv_self = ST(0); |
| 2520 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 2521 |
|
| |
| 2522 |
|
| // Env |
| 2523 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 2524 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2525 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 2526 |
|
| |
| 2527 |
|
| // Stack |
| 2528 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 2529 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2530 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 2531 |
|
| |
| 2532 |
0 |
| SV* sv_array = ST(1); |
| 2533 |
|
| |
| 2534 |
0 |
| SV* sv_error = &PL_sv_undef; |
| 2535 |
0 |
| sv_array = SPVM_XS_UTIL_new_byte_array_unsigned(aTHX_ sv_self, sv_array, &sv_error); |
| 2536 |
|
| |
| 2537 |
0 |
▶ | if (SvOK(sv_error)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_error)) { |
0 |
0 |
0 |
|
| 2538 |
0 |
| croak("$array%s\n %s at %s line %d\n", SvPV_nolen(sv_error), __func__, FILE_NAME, __LINE__); |
| 2539 |
|
| } |
| 2540 |
|
| |
| 2541 |
0 |
▶ | XPUSHs(sv_array); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_array); |
0 |
0 |
0 |
|
| 2542 |
0 |
| XSRETURN(1); |
| 2543 |
|
| } |
| 2544 |
|
| |
| 2545 |
|
| SV* |
| 2546 |
|
| _xs_new_byte_array_len(...) |
| 2547 |
|
| PPCODE: |
| 2548 |
|
| { |
| 2549 |
|
| |
| 2550 |
0 |
| SV* sv_self = ST(0); |
| 2551 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 2552 |
|
| |
| 2553 |
|
| // Env |
| 2554 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 2555 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2556 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 2557 |
|
| |
| 2558 |
|
| // Stack |
| 2559 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 2560 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2561 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 2562 |
|
| |
| 2563 |
0 |
| SV* sv_length = ST(1); |
| 2564 |
|
| |
| 2565 |
0 |
| int32_t length = (int32_t)SvIV(sv_length); |
| 2566 |
|
| |
| 2567 |
0 |
▶ | if (length < 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (length < 0) { |
0 |
0 |
0 |
|
| 2568 |
0 |
| croak("$length must be greater than or equal to 0\n %s at %s line %d\n", __func__, FILE_NAME, __LINE__); |
| 2569 |
|
| } |
| 2570 |
|
| |
| 2571 |
0 |
| void* spvm_array = env->new_byte_array_no_mortal(env, stack, length); |
| 2572 |
|
| |
| 2573 |
0 |
| SV* sv_byte_array = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_self, spvm_array, "SPVM::BlessedObject::Array"); |
| 2574 |
|
| |
| 2575 |
0 |
▶ | XPUSHs(sv_byte_array); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_byte_array); |
0 |
0 |
0 |
|
| 2576 |
0 |
| XSRETURN(1); |
| 2577 |
|
| } |
| 2578 |
|
| |
| 2579 |
|
| SV* |
| 2580 |
|
| _xs_new_byte_array_from_bin(...) |
| 2581 |
|
| PPCODE: |
| 2582 |
|
| { |
| 2583 |
|
| |
| 2584 |
0 |
| SV* sv_self = ST(0); |
| 2585 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 2586 |
|
| |
| 2587 |
|
| // Env |
| 2588 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 2589 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2590 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 2591 |
|
| |
| 2592 |
|
| // Stack |
| 2593 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 2594 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2595 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 2596 |
|
| |
| 2597 |
0 |
| SV* sv_binary = ST(1); |
| 2598 |
|
| |
| 2599 |
0 |
▶ | if (!(SvOK(sv_binary) && !SvROK(sv_binary))) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(SvOK(sv_binary) && !SvROK(sv_binary))) { |
0 |
0 |
0 |
| if (!(SvOK(sv_binary) && !SvROK(sv_binary))) { |
0 |
0 |
0 |
|
| 2600 |
0 |
| croak("$binary must be a defined non-reference scalar\n %s at %s line %d\n", __func__, FILE_NAME, __LINE__); |
| 2601 |
|
| } |
| 2602 |
|
| |
| 2603 |
0 |
| STRLEN length = -1; |
| 2604 |
0 |
| int8_t* binary = (int8_t*)SvPV(sv_binary, length); |
| 2605 |
|
| |
| 2606 |
|
| // New array |
| 2607 |
0 |
| void* spvm_array = env->new_byte_array_no_mortal(env, stack, (int32_t)length); |
| 2608 |
|
| |
| 2609 |
0 |
| int8_t* elems = env->get_elems_byte(env, stack, spvm_array); |
| 2610 |
0 |
| memcpy(elems, binary, length); |
| 2611 |
|
| |
| 2612 |
0 |
| SV* sv_array = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_self, spvm_array, "SPVM::BlessedObject::Array"); |
| 2613 |
|
| |
| 2614 |
0 |
▶ | XPUSHs(sv_array); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_array); |
0 |
0 |
0 |
|
| 2615 |
0 |
| XSRETURN(1); |
| 2616 |
|
| } |
| 2617 |
|
| |
| 2618 |
|
| SV* |
| 2619 |
|
| _xs_new_short_array(...) |
| 2620 |
|
| PPCODE: |
| 2621 |
|
| { |
| 2622 |
|
| |
| 2623 |
0 |
| SV* sv_self = ST(0); |
| 2624 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 2625 |
|
| |
| 2626 |
|
| // Env |
| 2627 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 2628 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2629 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 2630 |
|
| |
| 2631 |
|
| // Stack |
| 2632 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 2633 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2634 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 2635 |
|
| |
| 2636 |
0 |
| SV* sv_array = ST(1); |
| 2637 |
|
| |
| 2638 |
0 |
| SV* sv_error = &PL_sv_undef; |
| 2639 |
0 |
| sv_array = SPVM_XS_UTIL_new_short_array(aTHX_ sv_self, sv_array, &sv_error); |
| 2640 |
|
| |
| 2641 |
0 |
▶ | if (SvOK(sv_error)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_error)) { |
0 |
0 |
0 |
|
| 2642 |
0 |
| croak("$array%s\n %s at %s line %d\n", SvPV_nolen(sv_error), __func__, FILE_NAME, __LINE__); |
| 2643 |
|
| } |
| 2644 |
|
| |
| 2645 |
0 |
▶ | XPUSHs(sv_array); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_array); |
0 |
0 |
0 |
|
| 2646 |
0 |
| XSRETURN(1); |
| 2647 |
|
| } |
| 2648 |
|
| |
| 2649 |
|
| SV* |
| 2650 |
|
| _xs_new_short_array_unsigned(...) |
| 2651 |
|
| PPCODE: |
| 2652 |
|
| { |
| 2653 |
|
| |
| 2654 |
0 |
| SV* sv_self = ST(0); |
| 2655 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 2656 |
|
| |
| 2657 |
|
| // Env |
| 2658 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 2659 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2660 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 2661 |
|
| |
| 2662 |
|
| // Stack |
| 2663 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 2664 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2665 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 2666 |
|
| |
| 2667 |
0 |
| SV* sv_array = ST(1); |
| 2668 |
|
| |
| 2669 |
0 |
| SV* sv_error = &PL_sv_undef; |
| 2670 |
0 |
| sv_array = SPVM_XS_UTIL_new_short_array_unsigned(aTHX_ sv_self, sv_array, &sv_error); |
| 2671 |
|
| |
| 2672 |
0 |
▶ | if (SvOK(sv_error)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_error)) { |
0 |
0 |
0 |
|
| 2673 |
0 |
| croak("$array%s\n %s at %s line %d\n", SvPV_nolen(sv_error), __func__, FILE_NAME, __LINE__); |
| 2674 |
|
| } |
| 2675 |
|
| |
| 2676 |
0 |
▶ | XPUSHs(sv_array); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_array); |
0 |
0 |
0 |
|
| 2677 |
0 |
| XSRETURN(1); |
| 2678 |
|
| } |
| 2679 |
|
| |
| 2680 |
|
| SV* |
| 2681 |
|
| _xs_new_short_array_len(...) |
| 2682 |
|
| PPCODE: |
| 2683 |
|
| { |
| 2684 |
|
| |
| 2685 |
0 |
| SV* sv_self = ST(0); |
| 2686 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 2687 |
|
| |
| 2688 |
|
| // Env |
| 2689 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 2690 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2691 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 2692 |
|
| |
| 2693 |
|
| // Stack |
| 2694 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 2695 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2696 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 2697 |
|
| |
| 2698 |
0 |
| SV* sv_length = ST(1); |
| 2699 |
|
| |
| 2700 |
0 |
| int32_t length = (int32_t)SvIV(sv_length); |
| 2701 |
|
| |
| 2702 |
0 |
▶ | if (length < 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (length < 0) { |
0 |
0 |
0 |
|
| 2703 |
0 |
| croak("$length must be greater than or equal to 0\n %s at %s line %d\n", __func__, FILE_NAME, __LINE__); |
| 2704 |
|
| } |
| 2705 |
|
| |
| 2706 |
0 |
| void* spvm_array = env->new_short_array_no_mortal(env, stack, length); |
| 2707 |
|
| |
| 2708 |
0 |
| SV* sv_short_array = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_self, spvm_array, "SPVM::BlessedObject::Array"); |
| 2709 |
|
| |
| 2710 |
0 |
▶ | XPUSHs(sv_short_array); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_short_array); |
0 |
0 |
0 |
|
| 2711 |
0 |
| XSRETURN(1); |
| 2712 |
|
| } |
| 2713 |
|
| |
| 2714 |
|
| SV* |
| 2715 |
|
| _xs_new_short_array_from_bin(...) |
| 2716 |
|
| PPCODE: |
| 2717 |
|
| { |
| 2718 |
|
| |
| 2719 |
0 |
| SV* sv_self = ST(0); |
| 2720 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 2721 |
|
| |
| 2722 |
|
| // Env |
| 2723 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 2724 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2725 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 2726 |
|
| |
| 2727 |
|
| // Stack |
| 2728 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 2729 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2730 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 2731 |
|
| |
| 2732 |
0 |
| SV* sv_binary = ST(1); |
| 2733 |
|
| |
| 2734 |
0 |
▶ | if (!(SvOK(sv_binary) && !SvROK(sv_binary))) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(SvOK(sv_binary) && !SvROK(sv_binary))) { |
0 |
0 |
0 |
| if (!(SvOK(sv_binary) && !SvROK(sv_binary))) { |
0 |
0 |
0 |
|
| 2735 |
0 |
| croak("$binary must be a defined non-reference scalar\n %s at %s line %d\n", __func__, FILE_NAME, __LINE__); |
| 2736 |
|
| } |
| 2737 |
|
| |
| 2738 |
0 |
| STRLEN binary_length = -1; |
| 2739 |
0 |
| int16_t* binary = (int16_t*)SvPV(sv_binary, binary_length); |
| 2740 |
|
| |
| 2741 |
0 |
▶ | if (!(binary_length % 2 == 0)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!(binary_length % 2 == 0)) { |
0 |
0 |
0 |
|
| 2742 |
0 |
| croak("The length of $binary must be divisible by 2\n %s at %s line %d\n", __func__, FILE_NAME, __LINE__); |
| 2743 |
|
| } |
| 2744 |
|
| |
| 2745 |
0 |
| int32_t array_length = binary_length / sizeof(int16_t); |
| 2746 |
|
| |
| 2747 |
|
| // New array |
| 2748 |
0 |
| void* spvm_array = env->new_short_array_no_mortal(env, stack, array_length); |
| 2749 |
|
| |
| 2750 |
0 |
| int16_t* elems = env->get_elems_short(env, stack, spvm_array); |
| 2751 |
0 |
| memcpy(elems, binary, array_length * sizeof(int16_t)); |
| 2752 |
|
| |
| 2753 |
0 |
| SV* sv_array = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_self, spvm_array, "SPVM::BlessedObject::Array"); |
| 2754 |
|
| |
| 2755 |
0 |
▶ | XPUSHs(sv_array); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_array); |
0 |
0 |
0 |
|
| 2756 |
0 |
| XSRETURN(1); |
| 2757 |
|
| } |
| 2758 |
|
| |
| 2759 |
|
| SV* |
| 2760 |
|
| _xs_new_int_array(...) |
| 2761 |
|
| PPCODE: |
| 2762 |
|
| { |
| 2763 |
|
| |
| 2764 |
0 |
| SV* sv_self = ST(0); |
| 2765 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 2766 |
|
| |
| 2767 |
|
| // Env |
| 2768 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 2769 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2770 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 2771 |
|
| |
| 2772 |
|
| // Stack |
| 2773 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 2774 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2775 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 2776 |
|
| |
| 2777 |
0 |
| SV* sv_array = ST(1); |
| 2778 |
|
| |
| 2779 |
0 |
| SV* sv_error = &PL_sv_undef; |
| 2780 |
0 |
| sv_array = SPVM_XS_UTIL_new_int_array(aTHX_ sv_self, sv_array, &sv_error); |
| 2781 |
|
| |
| 2782 |
0 |
▶ | if (SvOK(sv_error)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_error)) { |
0 |
0 |
0 |
|
| 2783 |
0 |
| croak("$array%s\n %s at %s line %d\n", SvPV_nolen(sv_error), __func__, FILE_NAME, __LINE__); |
| 2784 |
|
| } |
| 2785 |
|
| |
| 2786 |
0 |
▶ | XPUSHs(sv_array); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_array); |
0 |
0 |
0 |
|
| 2787 |
0 |
| XSRETURN(1); |
| 2788 |
|
| } |
| 2789 |
|
| |
| 2790 |
|
| SV* |
| 2791 |
|
| _xs_new_int_array_unsigned(...) |
| 2792 |
|
| PPCODE: |
| 2793 |
|
| { |
| 2794 |
|
| |
| 2795 |
0 |
| SV* sv_self = ST(0); |
| 2796 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 2797 |
|
| |
| 2798 |
|
| // Env |
| 2799 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 2800 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2801 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 2802 |
|
| |
| 2803 |
|
| // Stack |
| 2804 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 2805 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2806 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 2807 |
|
| |
| 2808 |
0 |
| SV* sv_array = ST(1); |
| 2809 |
|
| |
| 2810 |
0 |
| SV* sv_error = &PL_sv_undef; |
| 2811 |
0 |
| sv_array = SPVM_XS_UTIL_new_int_array_unsigned(aTHX_ sv_self, sv_array, &sv_error); |
| 2812 |
|
| |
| 2813 |
0 |
▶ | if (SvOK(sv_error)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_error)) { |
0 |
0 |
0 |
|
| 2814 |
0 |
| croak("$array%s\n %s at %s line %d\n", SvPV_nolen(sv_error), __func__, FILE_NAME, __LINE__); |
| 2815 |
|
| } |
| 2816 |
|
| |
| 2817 |
0 |
▶ | XPUSHs(sv_array); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_array); |
0 |
0 |
0 |
|
| 2818 |
0 |
| XSRETURN(1); |
| 2819 |
|
| } |
| 2820 |
|
| |
| 2821 |
|
| SV* |
| 2822 |
|
| _xs_new_int_array_len(...) |
| 2823 |
|
| PPCODE: |
| 2824 |
|
| { |
| 2825 |
|
| |
| 2826 |
0 |
| SV* sv_self = ST(0); |
| 2827 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 2828 |
|
| |
| 2829 |
|
| // Env |
| 2830 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 2831 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2832 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 2833 |
|
| |
| 2834 |
|
| // Stack |
| 2835 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 2836 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2837 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 2838 |
|
| |
| 2839 |
0 |
| SV* sv_length = ST(1); |
| 2840 |
|
| |
| 2841 |
0 |
| int32_t length = (int32_t)SvIV(sv_length); |
| 2842 |
|
| |
| 2843 |
0 |
▶ | if (length < 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (length < 0) { |
0 |
0 |
0 |
|
| 2844 |
0 |
| croak("$length must be greater than or equal to 0\n %s at %s line %d\n", __func__, FILE_NAME, __LINE__); |
| 2845 |
|
| } |
| 2846 |
|
| |
| 2847 |
0 |
| void* spvm_array = env->new_int_array_no_mortal(env, stack, length); |
| 2848 |
|
| |
| 2849 |
0 |
| SV* sv_int_array = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_self, spvm_array, "SPVM::BlessedObject::Array"); |
| 2850 |
|
| |
| 2851 |
0 |
▶ | XPUSHs(sv_int_array); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_int_array); |
0 |
0 |
0 |
|
| 2852 |
0 |
| XSRETURN(1); |
| 2853 |
|
| } |
| 2854 |
|
| |
| 2855 |
|
| SV* |
| 2856 |
|
| _xs_new_int_array_from_bin(...) |
| 2857 |
|
| PPCODE: |
| 2858 |
|
| { |
| 2859 |
|
| |
| 2860 |
0 |
| SV* sv_self = ST(0); |
| 2861 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 2862 |
|
| |
| 2863 |
|
| // Env |
| 2864 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 2865 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2866 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 2867 |
|
| |
| 2868 |
|
| // Stack |
| 2869 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 2870 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2871 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 2872 |
|
| |
| 2873 |
0 |
| SV* sv_binary = ST(1); |
| 2874 |
|
| |
| 2875 |
0 |
▶ | if (!(SvOK(sv_binary) && !SvROK(sv_binary))) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(SvOK(sv_binary) && !SvROK(sv_binary))) { |
0 |
0 |
0 |
| if (!(SvOK(sv_binary) && !SvROK(sv_binary))) { |
0 |
0 |
0 |
|
| 2876 |
0 |
| croak("$binary must be a defined non-reference scalar\n %s at %s line %d\n", __func__, FILE_NAME, __LINE__); |
| 2877 |
|
| } |
| 2878 |
|
| |
| 2879 |
0 |
| STRLEN binary_length = -1; |
| 2880 |
0 |
| int32_t* binary = (int32_t*)SvPV(sv_binary, binary_length); |
| 2881 |
|
| |
| 2882 |
0 |
▶ | if (!(binary_length % 4 == 0)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!(binary_length % 4 == 0)) { |
0 |
0 |
0 |
|
| 2883 |
0 |
| croak("The length of $binary must be divisible by 4\n %s at %s line %d\n", __func__, FILE_NAME, __LINE__); |
| 2884 |
|
| } |
| 2885 |
|
| |
| 2886 |
0 |
| int32_t array_length = binary_length / sizeof(int32_t); |
| 2887 |
|
| |
| 2888 |
0 |
| void* spvm_array = env->new_int_array_no_mortal(env, stack, array_length); |
| 2889 |
|
| |
| 2890 |
0 |
| int32_t* elems = env->get_elems_int(env, stack, spvm_array); |
| 2891 |
0 |
| memcpy(elems, binary, array_length * sizeof(int32_t)); |
| 2892 |
|
| |
| 2893 |
0 |
| SV* sv_array = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_self, spvm_array, "SPVM::BlessedObject::Array"); |
| 2894 |
|
| |
| 2895 |
0 |
▶ | XPUSHs(sv_array); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_array); |
0 |
0 |
0 |
|
| 2896 |
0 |
| XSRETURN(1); |
| 2897 |
|
| } |
| 2898 |
|
| |
| 2899 |
|
| SV* |
| 2900 |
|
| _xs_new_long_array(...) |
| 2901 |
|
| PPCODE: |
| 2902 |
|
| { |
| 2903 |
|
| |
| 2904 |
0 |
| SV* sv_self = ST(0); |
| 2905 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 2906 |
|
| |
| 2907 |
|
| // Env |
| 2908 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 2909 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2910 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 2911 |
|
| |
| 2912 |
|
| // Stack |
| 2913 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 2914 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2915 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 2916 |
|
| |
| 2917 |
0 |
| SV* sv_array = ST(1); |
| 2918 |
|
| |
| 2919 |
0 |
| SV* sv_error = &PL_sv_undef; |
| 2920 |
0 |
| sv_array = SPVM_XS_UTIL_new_long_array(aTHX_ sv_self, sv_array, &sv_error); |
| 2921 |
|
| |
| 2922 |
0 |
▶ | if (SvOK(sv_error)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_error)) { |
0 |
0 |
0 |
|
| 2923 |
0 |
| croak("$array%s\n %s at %s line %d\n", SvPV_nolen(sv_error), __func__, FILE_NAME, __LINE__); |
| 2924 |
|
| } |
| 2925 |
|
| |
| 2926 |
0 |
▶ | XPUSHs(sv_array); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_array); |
0 |
0 |
0 |
|
| 2927 |
0 |
| XSRETURN(1); |
| 2928 |
|
| } |
| 2929 |
|
| |
| 2930 |
|
| SV* |
| 2931 |
|
| _xs_new_long_array_unsigned(...) |
| 2932 |
|
| PPCODE: |
| 2933 |
|
| { |
| 2934 |
|
| |
| 2935 |
0 |
| SV* sv_self = ST(0); |
| 2936 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 2937 |
|
| |
| 2938 |
|
| // Env |
| 2939 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 2940 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2941 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 2942 |
|
| |
| 2943 |
|
| // Stack |
| 2944 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 2945 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2946 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 2947 |
|
| |
| 2948 |
0 |
| SV* sv_array = ST(1); |
| 2949 |
|
| |
| 2950 |
0 |
| SV* sv_error = &PL_sv_undef; |
| 2951 |
0 |
| sv_array = SPVM_XS_UTIL_new_long_array_unsigned(aTHX_ sv_self, sv_array, &sv_error); |
| 2952 |
|
| |
| 2953 |
0 |
▶ | if (SvOK(sv_error)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_error)) { |
0 |
0 |
0 |
|
| 2954 |
0 |
| croak("$array%s\n %s at %s line %d\n", SvPV_nolen(sv_error), __func__, FILE_NAME, __LINE__); |
| 2955 |
|
| } |
| 2956 |
|
| |
| 2957 |
0 |
▶ | XPUSHs(sv_array); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_array); |
0 |
0 |
0 |
|
| 2958 |
0 |
| XSRETURN(1); |
| 2959 |
|
| } |
| 2960 |
|
| |
| 2961 |
|
| SV* |
| 2962 |
|
| _xs_new_long_array_len(...) |
| 2963 |
|
| PPCODE: |
| 2964 |
|
| { |
| 2965 |
|
| |
| 2966 |
0 |
| SV* sv_self = ST(0); |
| 2967 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 2968 |
|
| |
| 2969 |
|
| // Env |
| 2970 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 2971 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2972 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 2973 |
|
| |
| 2974 |
|
| // Stack |
| 2975 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 2976 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 2977 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 2978 |
|
| |
| 2979 |
0 |
| SV* sv_length = ST(1); |
| 2980 |
|
| |
| 2981 |
0 |
| int32_t length = (int32_t)SvIV(sv_length); |
| 2982 |
|
| |
| 2983 |
0 |
▶ | if (length < 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (length < 0) { |
0 |
0 |
0 |
|
| 2984 |
0 |
| croak("$length must be greater than or equal to 0\n %s at %s line %d\n", __func__, FILE_NAME, __LINE__); |
| 2985 |
|
| } |
| 2986 |
|
| |
| 2987 |
0 |
| void* spvm_array = env->new_long_array_no_mortal(env, stack, length); |
| 2988 |
|
| |
| 2989 |
0 |
| SV* sv_long_array = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_self, spvm_array, "SPVM::BlessedObject::Array"); |
| 2990 |
|
| |
| 2991 |
0 |
▶ | XPUSHs(sv_long_array); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_long_array); |
0 |
0 |
0 |
|
| 2992 |
0 |
| XSRETURN(1); |
| 2993 |
|
| } |
| 2994 |
|
| |
| 2995 |
|
| SV* |
| 2996 |
|
| _xs_new_long_array_from_bin(...) |
| 2997 |
|
| PPCODE: |
| 2998 |
|
| { |
| 2999 |
|
| |
| 3000 |
0 |
| SV* sv_self = ST(0); |
| 3001 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 3002 |
|
| |
| 3003 |
|
| // Env |
| 3004 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 3005 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3006 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 3007 |
|
| |
| 3008 |
|
| // Stack |
| 3009 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 3010 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3011 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 3012 |
|
| |
| 3013 |
0 |
| SV* sv_binary = ST(1); |
| 3014 |
|
| |
| 3015 |
0 |
▶ | if (!(SvOK(sv_binary) && !SvROK(sv_binary))) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(SvOK(sv_binary) && !SvROK(sv_binary))) { |
0 |
0 |
0 |
| if (!(SvOK(sv_binary) && !SvROK(sv_binary))) { |
0 |
0 |
0 |
|
| 3016 |
0 |
| croak("$binary must be a defined non-reference scalar\n %s at %s line %d\n", __func__, FILE_NAME, __LINE__); |
| 3017 |
|
| } |
| 3018 |
|
| |
| 3019 |
0 |
| STRLEN binary_length = -1; |
| 3020 |
0 |
| int64_t* binary = (int64_t*)SvPV(sv_binary, binary_length); |
| 3021 |
|
| |
| 3022 |
0 |
▶ | if (!(binary_length % 8 == 0)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!(binary_length % 8 == 0)) { |
0 |
0 |
0 |
|
| 3023 |
0 |
| croak("The length of $binary must be divisible by 8\n %s at %s line %d\n", __func__, FILE_NAME, __LINE__); |
| 3024 |
|
| } |
| 3025 |
|
| |
| 3026 |
0 |
| int32_t array_length = binary_length / sizeof(int64_t); |
| 3027 |
|
| |
| 3028 |
|
| // New array |
| 3029 |
0 |
| void* spvm_array = env->new_long_array_no_mortal(env, stack, array_length); |
| 3030 |
|
| |
| 3031 |
0 |
| int64_t* elems = env->get_elems_long(env, stack, spvm_array); |
| 3032 |
0 |
| memcpy(elems, binary, array_length * sizeof(int64_t)); |
| 3033 |
|
| |
| 3034 |
0 |
| SV* sv_array = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_self, spvm_array, "SPVM::BlessedObject::Array"); |
| 3035 |
|
| |
| 3036 |
0 |
▶ | XPUSHs(sv_array); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_array); |
0 |
0 |
0 |
|
| 3037 |
0 |
| XSRETURN(1); |
| 3038 |
|
| } |
| 3039 |
|
| |
| 3040 |
|
| SV* |
| 3041 |
|
| _xs_new_float_array(...) |
| 3042 |
|
| PPCODE: |
| 3043 |
|
| { |
| 3044 |
|
| |
| 3045 |
0 |
| SV* sv_self = ST(0); |
| 3046 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 3047 |
|
| |
| 3048 |
|
| // Env |
| 3049 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 3050 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3051 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 3052 |
|
| |
| 3053 |
|
| // Stack |
| 3054 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 3055 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3056 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 3057 |
|
| |
| 3058 |
0 |
| SV* sv_array = ST(1); |
| 3059 |
|
| |
| 3060 |
0 |
| SV* sv_error = &PL_sv_undef; |
| 3061 |
0 |
| sv_array = SPVM_XS_UTIL_new_float_array(aTHX_ sv_self, sv_array, &sv_error); |
| 3062 |
|
| |
| 3063 |
0 |
▶ | if (SvOK(sv_error)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_error)) { |
0 |
0 |
0 |
|
| 3064 |
0 |
| croak("$array%s\n %s at %s line %d\n", SvPV_nolen(sv_error), __func__, FILE_NAME, __LINE__); |
| 3065 |
|
| } |
| 3066 |
|
| |
| 3067 |
0 |
▶ | XPUSHs(sv_array); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_array); |
0 |
0 |
0 |
|
| 3068 |
0 |
| XSRETURN(1); |
| 3069 |
|
| } |
| 3070 |
|
| |
| 3071 |
|
| SV* |
| 3072 |
|
| _xs_new_float_array_len(...) |
| 3073 |
|
| PPCODE: |
| 3074 |
|
| { |
| 3075 |
|
| |
| 3076 |
0 |
| SV* sv_self = ST(0); |
| 3077 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 3078 |
|
| |
| 3079 |
|
| // Env |
| 3080 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 3081 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3082 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 3083 |
|
| |
| 3084 |
|
| // Stack |
| 3085 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 3086 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3087 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 3088 |
|
| |
| 3089 |
0 |
| SV* sv_length = ST(1); |
| 3090 |
|
| |
| 3091 |
0 |
| int32_t length = (int32_t)SvIV(sv_length); |
| 3092 |
|
| |
| 3093 |
0 |
▶ | if (length < 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (length < 0) { |
0 |
0 |
0 |
|
| 3094 |
0 |
| croak("$length must be greater than or equal to 0\n %s at %s line %d\n", __func__, FILE_NAME, __LINE__); |
| 3095 |
|
| } |
| 3096 |
|
| |
| 3097 |
0 |
| void* spvm_array = env->new_float_array_no_mortal(env, stack, length); |
| 3098 |
|
| |
| 3099 |
0 |
| SV* sv_float_array = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_self, spvm_array, "SPVM::BlessedObject::Array"); |
| 3100 |
|
| |
| 3101 |
0 |
▶ | XPUSHs(sv_float_array); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_float_array); |
0 |
0 |
0 |
|
| 3102 |
0 |
| XSRETURN(1); |
| 3103 |
|
| } |
| 3104 |
|
| |
| 3105 |
|
| SV* |
| 3106 |
|
| _xs_new_float_array_from_bin(...) |
| 3107 |
|
| PPCODE: |
| 3108 |
|
| { |
| 3109 |
|
| |
| 3110 |
0 |
| SV* sv_self = ST(0); |
| 3111 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 3112 |
|
| |
| 3113 |
|
| // Env |
| 3114 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 3115 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3116 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 3117 |
|
| |
| 3118 |
|
| // Stack |
| 3119 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 3120 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3121 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 3122 |
|
| |
| 3123 |
0 |
| SV* sv_binary = ST(1); |
| 3124 |
|
| |
| 3125 |
0 |
▶ | if (!(SvOK(sv_binary) && !SvROK(sv_binary))) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(SvOK(sv_binary) && !SvROK(sv_binary))) { |
0 |
0 |
0 |
| if (!(SvOK(sv_binary) && !SvROK(sv_binary))) { |
0 |
0 |
0 |
|
| 3126 |
0 |
| croak("$binary must be a defined non-reference scalar\n %s at %s line %d\n", __func__, FILE_NAME, __LINE__); |
| 3127 |
|
| } |
| 3128 |
|
| |
| 3129 |
0 |
| STRLEN binary_length = -1; |
| 3130 |
0 |
| float* binary = (float*)SvPV(sv_binary, binary_length); |
| 3131 |
|
| |
| 3132 |
0 |
▶ | if (!(binary_length % 4 == 0)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!(binary_length % 4 == 0)) { |
0 |
0 |
0 |
|
| 3133 |
0 |
| croak("The length of $binary must be divisible by 4\n %s at %s line %d\n", __func__, FILE_NAME, __LINE__); |
| 3134 |
|
| } |
| 3135 |
|
| |
| 3136 |
0 |
| int32_t array_length = binary_length / sizeof(float); |
| 3137 |
|
| |
| 3138 |
|
| // New array |
| 3139 |
0 |
| void* spvm_array = env->new_float_array_no_mortal(env, stack, array_length); |
| 3140 |
|
| |
| 3141 |
0 |
| float* elems = env->get_elems_float(env, stack, spvm_array); |
| 3142 |
0 |
| memcpy(elems, binary, array_length * sizeof(float)); |
| 3143 |
|
| |
| 3144 |
0 |
| SV* sv_array = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_self, spvm_array, "SPVM::BlessedObject::Array"); |
| 3145 |
|
| |
| 3146 |
0 |
▶ | XPUSHs(sv_array); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_array); |
0 |
0 |
0 |
|
| 3147 |
0 |
| XSRETURN(1); |
| 3148 |
|
| } |
| 3149 |
|
| |
| 3150 |
|
| SV* |
| 3151 |
|
| _xs_new_double_array(...) |
| 3152 |
|
| PPCODE: |
| 3153 |
|
| { |
| 3154 |
|
| |
| 3155 |
0 |
| SV* sv_self = ST(0); |
| 3156 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 3157 |
|
| |
| 3158 |
|
| // Env |
| 3159 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 3160 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3161 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 3162 |
|
| |
| 3163 |
|
| // Stack |
| 3164 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 3165 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3166 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 3167 |
|
| |
| 3168 |
0 |
| SV* sv_array = ST(1); |
| 3169 |
|
| |
| 3170 |
0 |
| SV* sv_error = &PL_sv_undef; |
| 3171 |
0 |
| sv_array = SPVM_XS_UTIL_new_double_array(aTHX_ sv_self, sv_array, &sv_error); |
| 3172 |
|
| |
| 3173 |
0 |
▶ | if (SvOK(sv_error)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_error)) { |
0 |
0 |
0 |
|
| 3174 |
0 |
| croak("$array%s\n %s at %s line %d\n", SvPV_nolen(sv_error), __func__, FILE_NAME, __LINE__); |
| 3175 |
|
| } |
| 3176 |
|
| |
| 3177 |
0 |
▶ | XPUSHs(sv_array); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_array); |
0 |
0 |
0 |
|
| 3178 |
0 |
| XSRETURN(1); |
| 3179 |
|
| } |
| 3180 |
|
| |
| 3181 |
|
| SV* |
| 3182 |
|
| _xs_new_double_array_len(...) |
| 3183 |
|
| PPCODE: |
| 3184 |
|
| { |
| 3185 |
|
| |
| 3186 |
0 |
| SV* sv_self = ST(0); |
| 3187 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 3188 |
|
| |
| 3189 |
|
| // Env |
| 3190 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 3191 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3192 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 3193 |
|
| |
| 3194 |
|
| // Stack |
| 3195 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 3196 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3197 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 3198 |
|
| |
| 3199 |
0 |
| SV* sv_length = ST(1); |
| 3200 |
|
| |
| 3201 |
0 |
| int32_t length = (int32_t)SvIV(sv_length); |
| 3202 |
|
| |
| 3203 |
0 |
▶ | if (length < 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (length < 0) { |
0 |
0 |
0 |
|
| 3204 |
0 |
| croak("$length must be greater than or equal to 0\n %s at %s line %d\n", __func__, FILE_NAME, __LINE__); |
| 3205 |
|
| } |
| 3206 |
|
| |
| 3207 |
0 |
| void* spvm_array = env->new_double_array_no_mortal(env, stack, length); |
| 3208 |
|
| |
| 3209 |
0 |
| SV* sv_double_array = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_self, spvm_array, "SPVM::BlessedObject::Array"); |
| 3210 |
|
| |
| 3211 |
0 |
▶ | XPUSHs(sv_double_array); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_double_array); |
0 |
0 |
0 |
|
| 3212 |
0 |
| XSRETURN(1); |
| 3213 |
|
| } |
| 3214 |
|
| |
| 3215 |
|
| SV* |
| 3216 |
|
| _xs_new_double_array_from_bin(...) |
| 3217 |
|
| PPCODE: |
| 3218 |
|
| { |
| 3219 |
|
| |
| 3220 |
0 |
| SV* sv_self = ST(0); |
| 3221 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 3222 |
|
| |
| 3223 |
|
| // Env |
| 3224 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 3225 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3226 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 3227 |
|
| |
| 3228 |
|
| // Stack |
| 3229 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 3230 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3231 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 3232 |
|
| |
| 3233 |
0 |
| SV* sv_binary = ST(1); |
| 3234 |
|
| |
| 3235 |
0 |
▶ | if (!(SvOK(sv_binary) && !SvROK(sv_binary))) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(SvOK(sv_binary) && !SvROK(sv_binary))) { |
0 |
0 |
0 |
| if (!(SvOK(sv_binary) && !SvROK(sv_binary))) { |
0 |
0 |
0 |
|
| 3236 |
0 |
| croak("$binary must be a defined non-reference scalar\n %s at %s line %d\n", __func__, FILE_NAME, __LINE__); |
| 3237 |
|
| } |
| 3238 |
|
| |
| 3239 |
0 |
| STRLEN binary_length = -1; |
| 3240 |
0 |
| double* binary = (double*)SvPV(sv_binary, binary_length); |
| 3241 |
|
| |
| 3242 |
0 |
▶ | if (!(binary_length % 8 == 0)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!(binary_length % 8 == 0)) { |
0 |
0 |
0 |
|
| 3243 |
0 |
| croak("The length of $binary must be divisible by 8\n %s at %s line %d\n", __func__, FILE_NAME, __LINE__); |
| 3244 |
|
| } |
| 3245 |
|
| |
| 3246 |
0 |
| int32_t array_length = binary_length / sizeof(double); |
| 3247 |
|
| |
| 3248 |
0 |
| void* spvm_array = env->new_double_array_no_mortal(env, stack, array_length); |
| 3249 |
|
| |
| 3250 |
0 |
| double* elems = env->get_elems_double(env, stack, spvm_array); |
| 3251 |
0 |
| memcpy(elems, binary, array_length * sizeof(double)); |
| 3252 |
|
| |
| 3253 |
0 |
| SV* sv_array = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_self, spvm_array, "SPVM::BlessedObject::Array"); |
| 3254 |
|
| |
| 3255 |
0 |
▶ | XPUSHs(sv_array); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_array); |
0 |
0 |
0 |
|
| 3256 |
0 |
| XSRETURN(1); |
| 3257 |
|
| } |
| 3258 |
|
| |
| 3259 |
|
| SV* |
| 3260 |
|
| _xs_new_string_array(...) |
| 3261 |
|
| PPCODE: |
| 3262 |
|
| { |
| 3263 |
|
| |
| 3264 |
0 |
| SV* sv_self = ST(0); |
| 3265 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 3266 |
|
| |
| 3267 |
|
| // Env |
| 3268 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 3269 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3270 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 3271 |
|
| |
| 3272 |
|
| // Stack |
| 3273 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 3274 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3275 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 3276 |
|
| |
| 3277 |
0 |
| SV* sv_array = ST(1); |
| 3278 |
|
| |
| 3279 |
0 |
| SV* sv_error = &PL_sv_undef; |
| 3280 |
0 |
| sv_array = SPVM_XS_UTIL_new_string_array(aTHX_ sv_self, sv_array, &sv_error); |
| 3281 |
|
| |
| 3282 |
0 |
▶ | if (SvOK(sv_error)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_error)) { |
0 |
0 |
0 |
|
| 3283 |
0 |
| croak("$array%s\n %s at %s line %d\n", SvPV_nolen(sv_error), __func__, FILE_NAME, __LINE__); |
| 3284 |
|
| } |
| 3285 |
|
| |
| 3286 |
0 |
▶ | XPUSHs(sv_array); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_array); |
0 |
0 |
0 |
|
| 3287 |
0 |
| XSRETURN(1); |
| 3288 |
|
| } |
| 3289 |
|
| |
| 3290 |
|
| SV* |
| 3291 |
|
| _xs_new_string_array_len(...) |
| 3292 |
|
| PPCODE: |
| 3293 |
|
| { |
| 3294 |
|
| |
| 3295 |
0 |
| SV* sv_self = ST(0); |
| 3296 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 3297 |
|
| |
| 3298 |
|
| // Env |
| 3299 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 3300 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3301 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 3302 |
|
| |
| 3303 |
|
| // Stack |
| 3304 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 3305 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3306 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 3307 |
|
| |
| 3308 |
0 |
| SV* sv_length = ST(1); |
| 3309 |
|
| |
| 3310 |
0 |
| int32_t length = (int32_t)SvIV(sv_length); |
| 3311 |
|
| |
| 3312 |
0 |
▶ | if (length < 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (length < 0) { |
0 |
0 |
0 |
|
| 3313 |
0 |
| croak("$length must be greater than or equal to 0\n %s at %s line %d\n", __func__, FILE_NAME, __LINE__); |
| 3314 |
|
| } |
| 3315 |
|
| |
| 3316 |
0 |
| void* spvm_array = env->new_string_array_no_mortal(env, stack, length); |
| 3317 |
|
| |
| 3318 |
0 |
| SV* sv_array = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_self, spvm_array, "SPVM::BlessedObject::Array"); |
| 3319 |
|
| |
| 3320 |
0 |
▶ | XPUSHs(sv_array); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_array); |
0 |
0 |
0 |
|
| 3321 |
0 |
| XSRETURN(1); |
| 3322 |
|
| } |
| 3323 |
|
| |
| 3324 |
|
| SV* |
| 3325 |
|
| _xs_new_object_array(...) |
| 3326 |
|
| PPCODE: |
| 3327 |
|
| { |
| 3328 |
|
| |
| 3329 |
201 |
| SV* sv_self = ST(0); |
| 3330 |
201 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 3331 |
|
| |
| 3332 |
|
| // Env |
| 3333 |
201 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 3334 |
201 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
201 |
0 |
201 |
|
| 3335 |
201 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 3336 |
|
| |
| 3337 |
|
| // Stack |
| 3338 |
201 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 3339 |
201 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
201 |
0 |
201 |
|
| 3340 |
201 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 3341 |
|
| |
| 3342 |
201 |
| SV* sv_basic_type_name = ST(1); |
| 3343 |
201 |
| SV* sv_array = ST(2); |
| 3344 |
|
| |
| 3345 |
201 |
| const char* basic_type_name = SvPV_nolen(sv_basic_type_name); |
| 3346 |
201 |
| void* basic_type = env->api->runtime->get_basic_type_by_name(env->runtime, basic_type_name); |
| 3347 |
201 |
▶ | if (!basic_type) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!basic_type) { |
0 |
201 |
201 |
|
| 3348 |
0 |
| croak("%s class is not found\n %s at %s line %d\n", basic_type_name, __func__, FILE_NAME, __LINE__); |
| 3349 |
|
| } |
| 3350 |
|
| |
| 3351 |
201 |
| int32_t elem_type_dimension = 0; |
| 3352 |
201 |
| int32_t is_object_array = env->api->type->is_object_type(env->runtime, basic_type, elem_type_dimension, 0); |
| 3353 |
201 |
▶ | if (!is_object_array) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!is_object_array) { |
0 |
201 |
201 |
|
| 3354 |
0 |
| croak("$type_name must be an object array type\n %s at %s line %d\n", __func__, FILE_NAME, __LINE__); |
| 3355 |
|
| } |
| 3356 |
|
| |
| 3357 |
201 |
| SV* sv_error = &PL_sv_undef; |
| 3358 |
201 |
| sv_array = SPVM_XS_UTIL_new_object_array(aTHX_ sv_self, basic_type, sv_array, &sv_error); |
| 3359 |
|
| |
| 3360 |
201 |
▶ | if (SvOK(sv_error)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_error)) { |
0 |
201 |
201 |
|
| 3361 |
0 |
| croak("$array%s\n %s at %s line %d\n", SvPV_nolen(sv_error), __func__, FILE_NAME, __LINE__); |
| 3362 |
|
| } |
| 3363 |
|
| |
| 3364 |
201 |
▶ | XPUSHs(sv_array); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_array); |
0 |
201 |
201 |
|
| 3365 |
201 |
| XSRETURN(1); |
| 3366 |
|
| } |
| 3367 |
|
| |
| 3368 |
|
| SV* |
| 3369 |
|
| _xs_new_object_array_len(...) |
| 3370 |
|
| PPCODE: |
| 3371 |
|
| { |
| 3372 |
|
| |
| 3373 |
0 |
| SV* sv_self = ST(0); |
| 3374 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 3375 |
|
| |
| 3376 |
|
| // Env |
| 3377 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 3378 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3379 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 3380 |
|
| |
| 3381 |
|
| // Stack |
| 3382 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 3383 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3384 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 3385 |
|
| |
| 3386 |
0 |
| SV* sv_basic_type_name = ST(1); |
| 3387 |
0 |
| SV* sv_length = ST(2); |
| 3388 |
|
| |
| 3389 |
0 |
| int32_t length = (int32_t)SvIV(sv_length); |
| 3390 |
|
| |
| 3391 |
0 |
▶ | if (length < 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (length < 0) { |
0 |
0 |
0 |
|
| 3392 |
0 |
| croak("$length must be greater than or equal to 0\n %s at %s line %d\n", __func__, FILE_NAME, __LINE__); |
| 3393 |
|
| } |
| 3394 |
|
| |
| 3395 |
|
| // Element type id |
| 3396 |
0 |
| const char* basic_type_name = SvPV_nolen(sv_basic_type_name); |
| 3397 |
|
| |
| 3398 |
0 |
| void* basic_type = env->api->runtime->get_basic_type_by_name(env->runtime, basic_type_name); |
| 3399 |
0 |
▶ | if (!basic_type) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!basic_type) { |
0 |
0 |
0 |
|
| 3400 |
0 |
| croak("%s class is not found\n %s at %s line %d\n", basic_type_name, __func__, FILE_NAME, __LINE__); |
| 3401 |
|
| } |
| 3402 |
|
| |
| 3403 |
0 |
| int32_t elem_type_dimension = 0; |
| 3404 |
0 |
| int32_t is_object_array = env->api->type->is_object_type(env->runtime, basic_type, elem_type_dimension, 0); |
| 3405 |
0 |
▶ | if (!is_object_array) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!is_object_array) { |
0 |
0 |
0 |
|
| 3406 |
0 |
| croak("$type_name must be an object array type\n %s at %s line %d\n", __func__, FILE_NAME, __LINE__); |
| 3407 |
|
| } |
| 3408 |
|
| |
| 3409 |
0 |
| void* spvm_array = env->new_object_array_no_mortal(env, stack, basic_type, length); |
| 3410 |
|
| |
| 3411 |
0 |
| SV* sv_array = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_self, spvm_array, "SPVM::BlessedObject::Array"); |
| 3412 |
|
| |
| 3413 |
0 |
▶ | XPUSHs(sv_array); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_array); |
0 |
0 |
0 |
|
| 3414 |
0 |
| XSRETURN(1); |
| 3415 |
|
| } |
| 3416 |
|
| |
| 3417 |
|
| SV* |
| 3418 |
|
| _xs_new_mulnum_array(...) |
| 3419 |
|
| PPCODE: |
| 3420 |
|
| { |
| 3421 |
|
| |
| 3422 |
0 |
| SV* sv_self = ST(0); |
| 3423 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 3424 |
|
| |
| 3425 |
|
| // Env |
| 3426 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 3427 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3428 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 3429 |
|
| |
| 3430 |
|
| // Stack |
| 3431 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 3432 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3433 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 3434 |
|
| |
| 3435 |
0 |
| SV* sv_basic_type_name = ST(1); |
| 3436 |
0 |
| SV* sv_array = ST(2); |
| 3437 |
|
| |
| 3438 |
0 |
| const char* basic_type_name = SvPV_nolen(sv_basic_type_name); |
| 3439 |
|
| |
| 3440 |
0 |
| void* basic_type = env->api->runtime->get_basic_type_by_name(env->runtime, basic_type_name); |
| 3441 |
0 |
▶ | if (!basic_type) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!basic_type) { |
0 |
0 |
0 |
|
| 3442 |
0 |
| croak("%s class is not found\n %s at %s line %d\n", basic_type_name, __func__, FILE_NAME, __LINE__); |
| 3443 |
|
| } |
| 3444 |
0 |
| int32_t elem_type_dimension = 0; |
| 3445 |
0 |
| int32_t basic_type_category = env->api->basic_type->get_category(env->runtime, basic_type); |
| 3446 |
0 |
| int32_t is_mulnum_array = basic_type_category == SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_MULNUM; |
| 3447 |
0 |
▶ | if (!is_mulnum_array) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!is_mulnum_array) { |
0 |
0 |
0 |
|
| 3448 |
0 |
| croak("$type_name must be a multi-numeric array type\n %s at %s line %d\n", __func__, FILE_NAME, __LINE__); |
| 3449 |
|
| } |
| 3450 |
|
| |
| 3451 |
0 |
| SV* sv_error = &PL_sv_undef; |
| 3452 |
0 |
| sv_array = SPVM_XS_UTIL_new_mulnum_array(aTHX_ sv_self, basic_type, sv_array, &sv_error); |
| 3453 |
|
| |
| 3454 |
0 |
▶ | if (SvOK(sv_error)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_error)) { |
0 |
0 |
0 |
|
| 3455 |
0 |
| croak("$array%s\n %s at %s line %d\n", SvPV_nolen(sv_error), __func__, FILE_NAME, __LINE__); |
| 3456 |
|
| } |
| 3457 |
|
| |
| 3458 |
0 |
▶ | XPUSHs(sv_array); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_array); |
0 |
0 |
0 |
|
| 3459 |
0 |
| XSRETURN(1); |
| 3460 |
|
| } |
| 3461 |
|
| |
| 3462 |
|
| SV* |
| 3463 |
|
| _xs_new_mulnum_array_len(...) |
| 3464 |
|
| PPCODE: |
| 3465 |
|
| { |
| 3466 |
|
| |
| 3467 |
0 |
| SV* sv_self = ST(0); |
| 3468 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 3469 |
|
| |
| 3470 |
|
| // Env |
| 3471 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 3472 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3473 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 3474 |
|
| |
| 3475 |
|
| // Stack |
| 3476 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 3477 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3478 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 3479 |
|
| |
| 3480 |
0 |
| SV* sv_basic_type_name = ST(1); |
| 3481 |
0 |
| SV* sv_length = ST(2); |
| 3482 |
|
| |
| 3483 |
0 |
| int32_t length = (int32_t)SvIV(sv_length); |
| 3484 |
|
| |
| 3485 |
0 |
▶ | if (length < 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (length < 0) { |
0 |
0 |
0 |
|
| 3486 |
0 |
| croak("$length must be greater than or equal to 0\n %s at %s line %d\n", __func__, FILE_NAME, __LINE__); |
| 3487 |
|
| } |
| 3488 |
|
| |
| 3489 |
0 |
| const char* basic_type_name = SvPV_nolen(sv_basic_type_name); |
| 3490 |
|
| |
| 3491 |
0 |
| void* basic_type = env->api->runtime->get_basic_type_by_name(env->runtime, basic_type_name); |
| 3492 |
0 |
▶ | if (!basic_type) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!basic_type) { |
0 |
0 |
0 |
|
| 3493 |
0 |
| croak("%s class is not found\n %s at %s line %d\n", basic_type_name, __func__, FILE_NAME, __LINE__); |
| 3494 |
|
| } |
| 3495 |
|
| |
| 3496 |
0 |
| int32_t elem_type_dimension = 0; |
| 3497 |
0 |
| int32_t basic_type_category = env->api->basic_type->get_category(env->runtime, basic_type); |
| 3498 |
0 |
| int32_t is_mulnum_array = basic_type_category == SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_MULNUM; |
| 3499 |
0 |
▶ | if (!is_mulnum_array) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!is_mulnum_array) { |
0 |
0 |
0 |
|
| 3500 |
0 |
| croak("$type_name must be a multi-numeric array type\n %s at %s line %d\n", __func__, FILE_NAME, __LINE__); |
| 3501 |
|
| } |
| 3502 |
|
| |
| 3503 |
0 |
| void* spvm_array = env->new_mulnum_array_no_mortal(env, stack, basic_type, length); |
| 3504 |
|
| |
| 3505 |
0 |
| SV* sv_array = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_self, spvm_array, "SPVM::BlessedObject::Array"); |
| 3506 |
|
| |
| 3507 |
0 |
▶ | XPUSHs(sv_array); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_array); |
0 |
0 |
0 |
|
| 3508 |
0 |
| XSRETURN(1); |
| 3509 |
|
| } |
| 3510 |
|
| |
| 3511 |
|
| SV* |
| 3512 |
|
| _xs_new_mulnum_array_from_bin(...) |
| 3513 |
|
| PPCODE: |
| 3514 |
|
| { |
| 3515 |
|
| |
| 3516 |
0 |
| SV* sv_self = ST(0); |
| 3517 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 3518 |
|
| |
| 3519 |
|
| // Env |
| 3520 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 3521 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3522 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 3523 |
|
| |
| 3524 |
|
| // Stack |
| 3525 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 3526 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3527 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 3528 |
|
| |
| 3529 |
0 |
| SV* sv_basic_type_name = ST(1); |
| 3530 |
0 |
| SV* sv_binary = ST(2); |
| 3531 |
|
| |
| 3532 |
0 |
▶ | if (!(SvOK(sv_binary) && !SvROK(sv_binary))) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(SvOK(sv_binary) && !SvROK(sv_binary))) { |
0 |
0 |
0 |
| if (!(SvOK(sv_binary) && !SvROK(sv_binary))) { |
0 |
0 |
0 |
|
| 3533 |
0 |
| croak("$binary must be a defined non-reference scalar\n %s at %s line %d\n", __func__, FILE_NAME, __LINE__); |
| 3534 |
|
| } |
| 3535 |
|
| |
| 3536 |
0 |
| const char* basic_type_name = SvPV_nolen(sv_basic_type_name); |
| 3537 |
|
| |
| 3538 |
0 |
▶ | STRLEN binary_length = -1; |
Branch: 1 branch
| Branch | True | False | Total |
| STRLEN binary_length = -1; |
0 |
0 |
0 |
|
| 3539 |
0 |
| void* binary = (void*)SvPV(sv_binary, binary_length); |
| 3540 |
|
| |
| 3541 |
|
| // Runtime |
| 3542 |
0 |
| void* runtime = env->runtime; |
| 3543 |
|
| |
| 3544 |
0 |
| void* basic_type = env->api->runtime->get_basic_type_by_name(env->runtime, basic_type_name); |
| 3545 |
0 |
▶ | if (!basic_type) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!basic_type) { |
0 |
0 |
0 |
|
| 3546 |
0 |
| croak("%s class is not found\n %s at %s line %d\n", basic_type_name, __func__, FILE_NAME, __LINE__); |
| 3547 |
|
| } |
| 3548 |
0 |
| int32_t basic_type_id = env->api->basic_type->get_id(env->runtime, basic_type); |
| 3549 |
|
| |
| 3550 |
0 |
| int32_t elem_type_dimension = 0; |
| 3551 |
0 |
| int32_t basic_type_category = env->api->basic_type->get_category(env->runtime, basic_type); |
| 3552 |
0 |
| int32_t is_mulnum_array = basic_type_category == SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_MULNUM; |
| 3553 |
0 |
▶ | if (!is_mulnum_array) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!is_mulnum_array) { |
0 |
0 |
0 |
|
| 3554 |
0 |
| croak("$type_name must be a multi-numeric array type\n %s at %s line %d\n", __func__, FILE_NAME, __LINE__); |
| 3555 |
|
| } |
| 3556 |
|
| |
| 3557 |
0 |
| int32_t basic_type_fields_length = env->api->basic_type->get_fields_length(env->runtime, basic_type); |
| 3558 |
|
| |
| 3559 |
0 |
| int32_t fields_length = basic_type_fields_length; |
| 3560 |
|
| |
| 3561 |
|
| int32_t field_size; |
| 3562 |
0 |
| void* mulnum_field = env->api->basic_type->get_field_by_index(runtime, basic_type, 0); |
| 3563 |
0 |
| void* mulnum_field_basic_type = env->api->field->get_basic_type(env->runtime, mulnum_field); |
| 3564 |
0 |
| int32_t mulnum_field_basic_type_id = env->api->basic_type->get_id(env->runtime, mulnum_field_basic_type); |
| 3565 |
0 |
| switch (mulnum_field_basic_type_id) { |
| 3566 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_BYTE: { |
| 3567 |
0 |
| field_size = 1; |
| 3568 |
0 |
| break; |
| 3569 |
|
| } |
| 3570 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_SHORT: { |
| 3571 |
0 |
| field_size = 2; |
| 3572 |
0 |
| break; |
| 3573 |
|
| } |
| 3574 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_INT: { |
| 3575 |
0 |
| field_size = 4; |
| 3576 |
0 |
| break; |
| 3577 |
|
| } |
| 3578 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_LONG: { |
| 3579 |
0 |
| field_size = 8; |
| 3580 |
0 |
| break; |
| 3581 |
|
| } |
| 3582 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_FLOAT: { |
| 3583 |
0 |
| field_size = 4; |
| 3584 |
0 |
| break; |
| 3585 |
|
| } |
| 3586 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_DOUBLE: { |
| 3587 |
0 |
| field_size = 8; |
| 3588 |
0 |
| break; |
| 3589 |
|
| } |
| 3590 |
0 |
| default: { |
| 3591 |
|
| assert(0); |
| 3592 |
|
| } |
| 3593 |
|
| } |
| 3594 |
|
| |
| 3595 |
0 |
▶ | if (binary_length % (field_size * fields_length) != 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (binary_length % (field_size * fields_length) != 0) { |
0 |
0 |
0 |
|
| 3596 |
0 |
| croak("The length of $binary must be divisible by %d * %d\n %s at %s line %d", field_size, fields_length, __func__, FILE_NAME, __LINE__); |
| 3597 |
|
| } |
| 3598 |
|
| |
| 3599 |
0 |
| int32_t array_length = binary_length / fields_length / field_size; |
| 3600 |
|
| |
| 3601 |
0 |
| void* spvm_array = env->new_mulnum_array_no_mortal(env, stack, basic_type, array_length); |
| 3602 |
|
| |
| 3603 |
0 |
| int32_t type_dimension = env->get_object_type_dimension(env, stack, spvm_array); |
| 3604 |
|
| |
| 3605 |
0 |
| int32_t copy_length = fields_length * array_length * field_size; |
| 3606 |
0 |
| switch (mulnum_field_basic_type_id) { |
| 3607 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_BYTE: { |
| 3608 |
0 |
| int8_t* elems = env->get_elems_byte(env, stack, spvm_array); |
| 3609 |
0 |
▶ | if (array_length > 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (array_length > 0) { |
0 |
0 |
0 |
|
| 3610 |
0 |
| memcpy(elems, binary, copy_length); |
| 3611 |
|
| } |
| 3612 |
0 |
| break; |
| 3613 |
|
| } |
| 3614 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_SHORT: { |
| 3615 |
0 |
| int16_t* elems = env->get_elems_short(env, stack, spvm_array); |
| 3616 |
0 |
▶ | if (array_length > 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (array_length > 0) { |
0 |
0 |
0 |
|
| 3617 |
0 |
| memcpy(elems, binary, copy_length); |
| 3618 |
|
| } |
| 3619 |
0 |
| break; |
| 3620 |
|
| } |
| 3621 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_INT: { |
| 3622 |
0 |
| int32_t* elems = env->get_elems_int(env, stack, spvm_array); |
| 3623 |
0 |
▶ | if (array_length > 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (array_length > 0) { |
0 |
0 |
0 |
|
| 3624 |
0 |
| memcpy(elems, binary, copy_length); |
| 3625 |
|
| } |
| 3626 |
0 |
| break; |
| 3627 |
|
| } |
| 3628 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_LONG: { |
| 3629 |
0 |
| int64_t* elems = env->get_elems_long(env, stack, spvm_array); |
| 3630 |
0 |
▶ | if (array_length > 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (array_length > 0) { |
0 |
0 |
0 |
|
| 3631 |
0 |
| memcpy(elems, binary, copy_length); |
| 3632 |
|
| } |
| 3633 |
0 |
| break; |
| 3634 |
|
| } |
| 3635 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_FLOAT: { |
| 3636 |
0 |
| float* elems = env->get_elems_float(env, stack, spvm_array); |
| 3637 |
0 |
▶ | if (array_length > 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (array_length > 0) { |
0 |
0 |
0 |
|
| 3638 |
0 |
| memcpy(elems, binary, copy_length); |
| 3639 |
|
| } |
| 3640 |
0 |
| break; |
| 3641 |
|
| } |
| 3642 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_DOUBLE: { |
| 3643 |
0 |
| double* elems = env->get_elems_double(env, stack, spvm_array); |
| 3644 |
0 |
▶ | if (array_length > 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (array_length > 0) { |
0 |
0 |
0 |
|
| 3645 |
0 |
| memcpy(elems, binary, copy_length); |
| 3646 |
|
| } |
| 3647 |
0 |
| break; |
| 3648 |
|
| } |
| 3649 |
0 |
| default: |
| 3650 |
|
| assert(0); |
| 3651 |
|
| } |
| 3652 |
|
| |
| 3653 |
0 |
| SV* sv_array = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_self, spvm_array, "SPVM::BlessedObject::Array"); |
| 3654 |
|
| |
| 3655 |
0 |
▶ | XPUSHs(sv_array); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_array); |
0 |
0 |
0 |
|
| 3656 |
0 |
| XSRETURN(1); |
| 3657 |
|
| } |
| 3658 |
|
| |
| 3659 |
|
| SV* |
| 3660 |
|
| _xs_new_muldim_array(...) |
| 3661 |
|
| PPCODE: |
| 3662 |
|
| { |
| 3663 |
|
| |
| 3664 |
0 |
| SV* sv_self = ST(0); |
| 3665 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 3666 |
|
| |
| 3667 |
|
| // Env |
| 3668 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 3669 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3670 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 3671 |
|
| |
| 3672 |
|
| // Stack |
| 3673 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 3674 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3675 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 3676 |
|
| |
| 3677 |
0 |
| SV* sv_basic_type_name = ST(1); |
| 3678 |
0 |
| SV* sv_type_dimension = ST(2); |
| 3679 |
0 |
| SV* sv_array = ST(3); |
| 3680 |
|
| |
| 3681 |
0 |
| const char* basic_type_name = SvPV_nolen(sv_basic_type_name); |
| 3682 |
0 |
| void* basic_type = env->api->runtime->get_basic_type_by_name(env->runtime, basic_type_name); |
| 3683 |
0 |
▶ | if (!basic_type) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!basic_type) { |
0 |
0 |
0 |
|
| 3684 |
0 |
| croak("%s class is not found\n %s at %s line %d\n", basic_type_name, __func__, FILE_NAME, __LINE__); |
| 3685 |
|
| } |
| 3686 |
|
| |
| 3687 |
0 |
| int32_t type_dimension = (int32_t)SvIV(sv_type_dimension); |
| 3688 |
|
| |
| 3689 |
0 |
| SV* sv_error = &PL_sv_undef; |
| 3690 |
0 |
| sv_array = SPVM_XS_UTIL_new_muldim_array(aTHX_ sv_self, basic_type, type_dimension, sv_array, &sv_error); |
| 3691 |
|
| |
| 3692 |
0 |
▶ | if (SvOK(sv_error)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_error)) { |
0 |
0 |
0 |
|
| 3693 |
0 |
| croak("$array%s\n %s at %s line %d\n", SvPV_nolen(sv_error), __func__, FILE_NAME, __LINE__); |
| 3694 |
|
| } |
| 3695 |
|
| |
| 3696 |
0 |
▶ | XPUSHs(sv_array); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_array); |
0 |
0 |
0 |
|
| 3697 |
0 |
| XSRETURN(1); |
| 3698 |
|
| } |
| 3699 |
|
| |
| 3700 |
|
| SV* |
| 3701 |
|
| _xs_new_muldim_array_len(...) |
| 3702 |
|
| PPCODE: |
| 3703 |
|
| { |
| 3704 |
|
| |
| 3705 |
0 |
| SV* sv_self = ST(0); |
| 3706 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 3707 |
|
| |
| 3708 |
|
| // Env |
| 3709 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 3710 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3711 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 3712 |
|
| |
| 3713 |
|
| // Stack |
| 3714 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 3715 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3716 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 3717 |
|
| |
| 3718 |
0 |
| SV* sv_basic_type_name = ST(1); |
| 3719 |
0 |
| SV* sv_type_dimension = ST(2); |
| 3720 |
0 |
| SV* sv_length = ST(3); |
| 3721 |
|
| |
| 3722 |
0 |
| const char* basic_type_name = SvPV_nolen(sv_basic_type_name); |
| 3723 |
0 |
| void* basic_type = env->api->runtime->get_basic_type_by_name(env->runtime, basic_type_name); |
| 3724 |
0 |
▶ | if (!basic_type) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!basic_type) { |
0 |
0 |
0 |
|
| 3725 |
0 |
| croak("%s class is not found\n %s at %s line %d\n", basic_type_name, __func__, FILE_NAME, __LINE__); |
| 3726 |
|
| } |
| 3727 |
|
| |
| 3728 |
0 |
| int32_t type_dimension = (int32_t)SvIV(sv_type_dimension); |
| 3729 |
|
| |
| 3730 |
0 |
| int32_t length = (int32_t)SvIV(sv_length); |
| 3731 |
|
| |
| 3732 |
0 |
▶ | if (length < 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (length < 0) { |
0 |
0 |
0 |
|
| 3733 |
0 |
| croak("$length must be greater than or equal to 0\n %s at %s line %d\n", __func__, FILE_NAME, __LINE__); |
| 3734 |
|
| } |
| 3735 |
|
| |
| 3736 |
0 |
| void* spvm_array = env->new_muldim_array_no_mortal(env, stack, basic_type, type_dimension, length); |
| 3737 |
|
| |
| 3738 |
0 |
| SV* sv_array = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_self, spvm_array, "SPVM::BlessedObject::Array"); |
| 3739 |
|
| |
| 3740 |
0 |
▶ | XPUSHs(sv_array); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_array); |
0 |
0 |
0 |
|
| 3741 |
0 |
| XSRETURN(1); |
| 3742 |
|
| } |
| 3743 |
|
| |
| 3744 |
|
| SV* |
| 3745 |
|
| _xs_get_exception(...) |
| 3746 |
|
| PPCODE: |
| 3747 |
|
| { |
| 3748 |
|
| |
| 3749 |
0 |
| SV* sv_self = ST(0); |
| 3750 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 3751 |
|
| |
| 3752 |
|
| // Env |
| 3753 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 3754 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3755 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 3756 |
|
| |
| 3757 |
|
| // Stack |
| 3758 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 3759 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3760 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 3761 |
|
| |
| 3762 |
0 |
| void* str_exception = env->get_exception(env, stack); |
| 3763 |
|
| |
| 3764 |
|
| SV* sv_exception; |
| 3765 |
0 |
▶ | if (str_exception) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (str_exception) { |
0 |
0 |
0 |
|
| 3766 |
0 |
| sv_exception = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_self, str_exception, "SPVM::BlessedObject::String"); |
| 3767 |
|
| } |
| 3768 |
|
| else { |
| 3769 |
0 |
| sv_exception = &PL_sv_undef; |
| 3770 |
|
| } |
| 3771 |
|
| |
| 3772 |
0 |
▶ | XPUSHs(sv_exception); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_exception); |
0 |
0 |
0 |
|
| 3773 |
0 |
| XSRETURN(1); |
| 3774 |
|
| } |
| 3775 |
|
| |
| 3776 |
|
| SV* |
| 3777 |
|
| _xs_set_exception(...) |
| 3778 |
|
| PPCODE: |
| 3779 |
|
| { |
| 3780 |
|
| |
| 3781 |
0 |
| SV* sv_self = ST(0); |
| 3782 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 3783 |
|
| |
| 3784 |
|
| // Env |
| 3785 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 3786 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3787 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 3788 |
|
| |
| 3789 |
|
| // Stack |
| 3790 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 3791 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3792 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 3793 |
|
| |
| 3794 |
0 |
| SV* sv_message = ST(1); |
| 3795 |
|
| |
| 3796 |
0 |
| SV* sv_error = &PL_sv_undef; |
| 3797 |
0 |
| sv_message = SPVM_XS_UTIL_new_string(aTHX_ sv_self, sv_message, &sv_error); |
| 3798 |
|
| |
| 3799 |
0 |
▶ | if (SvOK(sv_error)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_error)) { |
0 |
0 |
0 |
|
| 3800 |
0 |
| croak("$message%s\n %s at %s line %d\n", SvPV_nolen(sv_error), __func__, FILE_NAME, __LINE__); |
| 3801 |
|
| } |
| 3802 |
|
| |
| 3803 |
0 |
| void* spvm_message = SPVM_XS_UTIL_get_spvm_object(aTHX_ sv_message); |
| 3804 |
|
| |
| 3805 |
0 |
| env->set_exception(env, stack, spvm_message); |
| 3806 |
|
| |
| 3807 |
0 |
| XSRETURN(0); |
| 3808 |
|
| } |
| 3809 |
|
| |
| 3810 |
|
| SV* |
| 3811 |
|
| _xs_get_memory_blocks_count(...) |
| 3812 |
|
| PPCODE: |
| 3813 |
|
| { |
| 3814 |
|
| |
| 3815 |
443 |
| SV* sv_self = ST(0); |
| 3816 |
443 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 3817 |
|
| |
| 3818 |
|
| // Env |
| 3819 |
443 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 3820 |
443 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
443 |
0 |
443 |
|
| 3821 |
443 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 3822 |
|
| |
| 3823 |
|
| // Stack |
| 3824 |
443 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 3825 |
443 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
443 |
0 |
443 |
|
| 3826 |
443 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 3827 |
|
| |
| 3828 |
443 |
| int32_t memory_blocks_count = env->get_memory_blocks_count(env, stack); |
| 3829 |
443 |
| SV* sv_memory_blocks_count = sv_2mortal(newSViv(memory_blocks_count)); |
| 3830 |
|
| |
| 3831 |
443 |
▶ | XPUSHs(sv_memory_blocks_count); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_memory_blocks_count); |
0 |
443 |
443 |
|
| 3832 |
443 |
| XSRETURN(1); |
| 3833 |
|
| } |
| 3834 |
|
| |
| 3835 |
|
| SV* |
| 3836 |
|
| _xs_destroy_runtime_permanent_vars(...) |
| 3837 |
|
| PPCODE: |
| 3838 |
|
| { |
| 3839 |
|
| |
| 3840 |
205 |
| SV* sv_self = ST(0); |
| 3841 |
205 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 3842 |
|
| |
| 3843 |
|
| // Env |
| 3844 |
205 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 3845 |
205 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
205 |
0 |
205 |
|
| 3846 |
205 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 3847 |
|
| |
| 3848 |
|
| // Stack |
| 3849 |
205 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 3850 |
205 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
205 |
0 |
205 |
|
| 3851 |
205 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 3852 |
|
| |
| 3853 |
205 |
| env->destroy_cache_class_vars(env, stack); |
| 3854 |
|
| |
| 3855 |
205 |
| env->set_exception(env, stack, NULL); |
| 3856 |
|
| |
| 3857 |
205 |
| XSRETURN(0); |
| 3858 |
|
| } |
| 3859 |
|
| |
| 3860 |
|
| SV* |
| 3861 |
|
| _xs_enable_record_object(...) |
| 3862 |
|
| PPCODE: |
| 3863 |
|
| { |
| 3864 |
|
| |
| 3865 |
0 |
| SV* sv_self = ST(0); |
| 3866 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 3867 |
|
| |
| 3868 |
|
| // Get env |
| 3869 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 3870 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3871 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 3872 |
|
| |
| 3873 |
|
| // Get stack |
| 3874 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 3875 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3876 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 3877 |
|
| |
| 3878 |
0 |
| env->api->runtime->enable_record_object(env->runtime); |
| 3879 |
|
| |
| 3880 |
0 |
| XSRETURN(0); |
| 3881 |
|
| } |
| 3882 |
|
| |
| 3883 |
|
| SV* |
| 3884 |
|
| _xs_disable_record_object(...) |
| 3885 |
|
| PPCODE: |
| 3886 |
|
| { |
| 3887 |
|
| |
| 3888 |
0 |
| SV* sv_self = ST(0); |
| 3889 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 3890 |
|
| |
| 3891 |
|
| // Get env |
| 3892 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 3893 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3894 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 3895 |
|
| |
| 3896 |
|
| // Get stack |
| 3897 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 3898 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3899 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 3900 |
|
| |
| 3901 |
0 |
| env->api->runtime->disable_record_object(env->runtime); |
| 3902 |
|
| |
| 3903 |
0 |
| XSRETURN(0); |
| 3904 |
|
| } |
| 3905 |
|
| |
| 3906 |
|
| SV* |
| 3907 |
|
| _xs_dump_recorded_objects(...) |
| 3908 |
|
| PPCODE: |
| 3909 |
|
| { |
| 3910 |
|
| |
| 3911 |
0 |
| SV* sv_self = ST(0); |
| 3912 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 3913 |
|
| |
| 3914 |
|
| // Get env |
| 3915 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 3916 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3917 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 3918 |
|
| |
| 3919 |
|
| // Get stack |
| 3920 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 3921 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 3922 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 3923 |
|
| |
| 3924 |
0 |
| SPVM_OBJ* obj_dump = env->dump_recorded_objects(env, stack); |
| 3925 |
|
| |
| 3926 |
0 |
| SV* sv_dump = NULL; |
| 3927 |
0 |
▶ | if (obj_dump) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (obj_dump) { |
0 |
0 |
0 |
|
| 3928 |
0 |
| const char* dump_chars = env->get_chars(env, stack, obj_dump); |
| 3929 |
0 |
| int32_t dump_length = env->length(env, stack, obj_dump); |
| 3930 |
0 |
| sv_dump = sv_2mortal(newSVpvn(dump_chars, dump_length)); |
| 3931 |
|
| } |
| 3932 |
|
| else { |
| 3933 |
0 |
| sv_dump = &PL_sv_undef; |
| 3934 |
|
| } |
| 3935 |
|
| |
| 3936 |
0 |
▶ | XPUSHs(sv_dump); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_dump); |
0 |
0 |
0 |
|
| 3937 |
0 |
| XSRETURN(1); |
| 3938 |
|
| } |
| 3939 |
|
| |
| 3940 |
|
| SV* |
| 3941 |
|
| _xs_get_version_string(...) |
| 3942 |
|
| PPCODE: |
| 3943 |
|
| { |
| 3944 |
|
| |
| 3945 |
10 |
| SV* sv_self = ST(0); |
| 3946 |
10 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 3947 |
|
| |
| 3948 |
|
| // Env |
| 3949 |
10 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 3950 |
10 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
10 |
0 |
10 |
|
| 3951 |
10 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 3952 |
|
| |
| 3953 |
|
| // Stack |
| 3954 |
10 |
| SV** sv_stack_ptr = hv_fetch(hv_self, "stack", strlen("stack"), 0); |
| 3955 |
10 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
10 |
0 |
10 |
|
| 3956 |
10 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 3957 |
|
| |
| 3958 |
10 |
| SV* sv_basic_type_name = ST(1); |
| 3959 |
|
| |
| 3960 |
10 |
▶ | if (!SvOK(sv_basic_type_name)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!SvOK(sv_basic_type_name)) { |
0 |
10 |
10 |
|
| 3961 |
0 |
| croak("The basic type name $basic_type_name must be defined."); |
| 3962 |
|
| } |
| 3963 |
|
| |
| 3964 |
10 |
| const char* basic_type_name = SvPV_nolen(sv_basic_type_name); |
| 3965 |
|
| |
| 3966 |
10 |
| void* basic_type = env->api->runtime->get_basic_type_by_name(env->runtime, basic_type_name); |
| 3967 |
10 |
▶ | if (!basic_type) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!basic_type) { |
0 |
10 |
10 |
|
| 3968 |
0 |
| croak("The class specified by the basic type name $basic_type_name must be loaded."); |
| 3969 |
|
| } |
| 3970 |
|
| |
| 3971 |
10 |
| const char* version_string = env->get_version_string(env, stack, basic_type); |
| 3972 |
|
| |
| 3973 |
10 |
| SV* sv_version_string = sv_2mortal(newSVpv(version_string, 0)); |
| 3974 |
|
| |
| 3975 |
10 |
▶ | XPUSHs(sv_version_string); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_version_string); |
0 |
10 |
10 |
|
| 3976 |
10 |
| XSRETURN(1); |
| 3977 |
|
| } |
| 3978 |
|
| |
| 3979 |
|
| MODULE = SPVM::BlessedObject PACKAGE = SPVM::BlessedObject |
| 3980 |
|
| |
| 3981 |
|
| SV* |
| 3982 |
|
| DESTROY(...) |
| 3983 |
|
| PPCODE: |
| 3984 |
|
| { |
| 3985 |
4856 |
| SV* sv_self = ST(0); |
| 3986 |
4856 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 3987 |
|
| |
| 3988 |
4856 |
| SV** sv_spvm_object_ptr = hv_fetch(hv_self, "spvm_object", strlen("spvm_object"), 0); |
| 3989 |
4856 |
▶ | SV* sv_spvm_object = sv_spvm_object_ptr ? *sv_spvm_object_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_spvm_object = sv_spvm_object_ptr ? *sv_spvm_object_ptr : &PL_sv_undef; |
4856 |
0 |
4856 |
|
| 3990 |
4856 |
| SPVM_OBJ** spvm_object_ref = (SPVM_OBJ**)SvPV_nolen(sv_spvm_object); |
| 3991 |
|
| |
| 3992 |
4856 |
| SV** sv_api_ptr = hv_fetch(hv_self, "__api", strlen("__api"), 0); |
| 3993 |
4856 |
▶ | SV* sv_api = sv_api_ptr ? *sv_api_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_api = sv_api_ptr ? *sv_api_ptr : &PL_sv_undef; |
4856 |
0 |
4856 |
|
| 3994 |
4856 |
| HV* hv_api = (HV*)SvRV(sv_api); |
| 3995 |
|
| |
| 3996 |
4856 |
| SV** sv_env_ptr = hv_fetch(hv_api, "env", strlen("env"), 0); |
| 3997 |
4856 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
4856 |
0 |
4856 |
|
| 3998 |
4856 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 3999 |
|
| |
| 4000 |
|
| // Stack |
| 4001 |
4856 |
| SV** sv_stack_ptr = hv_fetch(hv_api, "stack", strlen("stack"), 0); |
| 4002 |
4856 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
4856 |
0 |
4856 |
|
| 4003 |
4856 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 4004 |
|
| |
| 4005 |
4856 |
| env->assign_object(env, stack, spvm_object_ref, NULL); |
| 4006 |
|
| |
| 4007 |
4856 |
| XSRETURN(0); |
| 4008 |
|
| } |
| 4009 |
|
| |
| 4010 |
|
| SV* |
| 4011 |
|
| _xs___get_type_name(...) |
| 4012 |
|
| PPCODE: |
| 4013 |
|
| { |
| 4014 |
|
| |
| 4015 |
0 |
| SV* sv_self = ST(0); |
| 4016 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 4017 |
|
| |
| 4018 |
|
| // API |
| 4019 |
0 |
| SV** sv_api_ptr = hv_fetch(hv_self, "__api", strlen("__api"), 0); |
| 4020 |
0 |
▶ | SV* sv_api = sv_api_ptr ? *sv_api_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_api = sv_api_ptr ? *sv_api_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 4021 |
0 |
| HV* hv_api = (HV*)SvRV(sv_api); |
| 4022 |
|
| |
| 4023 |
|
| // Env |
| 4024 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_api, "env", strlen("env"), 0); |
| 4025 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 4026 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 4027 |
|
| |
| 4028 |
|
| // Stack |
| 4029 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_api, "stack", strlen("stack"), 0); |
| 4030 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 4031 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 4032 |
|
| |
| 4033 |
|
| assert(SvROK(sv_self) && sv_derived_from(sv_self, "SPVM::BlessedObject")); |
| 4034 |
|
| |
| 4035 |
|
| // Get object |
| 4036 |
0 |
| void* spvm_object = SPVM_XS_UTIL_get_spvm_object(aTHX_ sv_self); |
| 4037 |
|
| |
| 4038 |
0 |
| void* spvm_type_name = env->get_type_name_no_mortal(env, stack, spvm_object); |
| 4039 |
0 |
| const char* type_name = env->get_chars(env, stack, spvm_type_name); |
| 4040 |
0 |
| int32_t type_name_length = env->length(env, stack, spvm_type_name); |
| 4041 |
|
| |
| 4042 |
0 |
| SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_api, spvm_type_name, "SPVM::BlessedObject::String"); |
| 4043 |
|
| |
| 4044 |
0 |
| SV* sv_type_name = sv_2mortal(newSVpv(type_name, type_name_length)); |
| 4045 |
|
| |
| 4046 |
0 |
▶ | XPUSHs(sv_type_name); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_type_name); |
0 |
0 |
0 |
|
| 4047 |
0 |
| XSRETURN(1); |
| 4048 |
|
| } |
| 4049 |
|
| |
| 4050 |
|
| MODULE = SPVM::BlessedObject::String PACKAGE = SPVM::BlessedObject::String |
| 4051 |
|
| |
| 4052 |
|
| SV* |
| 4053 |
|
| _xs_to_bin(...) |
| 4054 |
|
| PPCODE: |
| 4055 |
|
| { |
| 4056 |
|
| |
| 4057 |
240 |
| SV* sv_self = ST(0); |
| 4058 |
240 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 4059 |
|
| |
| 4060 |
|
| // API |
| 4061 |
240 |
| SV** sv_api_ptr = hv_fetch(hv_self, "__api", strlen("__api"), 0); |
| 4062 |
240 |
▶ | SV* sv_api = sv_api_ptr ? *sv_api_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_api = sv_api_ptr ? *sv_api_ptr : &PL_sv_undef; |
240 |
0 |
240 |
|
| 4063 |
240 |
| HV* hv_api = (HV*)SvRV(sv_api); |
| 4064 |
|
| |
| 4065 |
|
| // Env |
| 4066 |
240 |
| SV** sv_env_ptr = hv_fetch(hv_api, "env", strlen("env"), 0); |
| 4067 |
240 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
240 |
0 |
240 |
|
| 4068 |
240 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 4069 |
|
| |
| 4070 |
|
| // Stack |
| 4071 |
240 |
| SV** sv_stack_ptr = hv_fetch(hv_api, "stack", strlen("stack"), 0); |
| 4072 |
240 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
240 |
0 |
240 |
|
| 4073 |
240 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 4074 |
|
| |
| 4075 |
|
| assert(SvROK(sv_self) && sv_derived_from(sv_self, "SPVM::BlessedObject::String")); |
| 4076 |
|
| |
| 4077 |
|
| // Get object |
| 4078 |
240 |
| void* spvm_string = SPVM_XS_UTIL_get_spvm_object(aTHX_ sv_self); |
| 4079 |
|
| |
| 4080 |
240 |
| int32_t length = env->length(env, stack, spvm_string); |
| 4081 |
240 |
| const char* chars = env->get_chars(env, stack, spvm_string); |
| 4082 |
|
| |
| 4083 |
240 |
| SV* sv_return_value = sv_2mortal(newSVpv(chars, length)); |
| 4084 |
|
| |
| 4085 |
240 |
▶ | XPUSHs(sv_return_value); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_return_value); |
0 |
240 |
240 |
|
| 4086 |
240 |
| XSRETURN(1); |
| 4087 |
|
| } |
| 4088 |
|
| |
| 4089 |
|
| MODULE = SPVM::BlessedObject::Array PACKAGE = SPVM::BlessedObject::Array |
| 4090 |
|
| |
| 4091 |
|
| SV* |
| 4092 |
|
| _xs_length(...) |
| 4093 |
|
| PPCODE: |
| 4094 |
|
| { |
| 4095 |
|
| |
| 4096 |
0 |
| SV* sv_self = ST(0); |
| 4097 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 4098 |
|
| |
| 4099 |
|
| // API |
| 4100 |
0 |
| SV** sv_api_ptr = hv_fetch(hv_self, "__api", strlen("__api"), 0); |
| 4101 |
0 |
▶ | SV* sv_api = sv_api_ptr ? *sv_api_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_api = sv_api_ptr ? *sv_api_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 4102 |
0 |
| HV* hv_api = (HV*)SvRV(sv_api); |
| 4103 |
|
| |
| 4104 |
|
| // Env |
| 4105 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_api, "env", strlen("env"), 0); |
| 4106 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 4107 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 4108 |
|
| |
| 4109 |
|
| // Stack |
| 4110 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_api, "stack", strlen("stack"), 0); |
| 4111 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 4112 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 4113 |
|
| |
| 4114 |
|
| // Runtime |
| 4115 |
0 |
| void* runtime = env->runtime; |
| 4116 |
|
| |
| 4117 |
|
| assert(SvROK(sv_self) && sv_derived_from(sv_self, "SPVM::BlessedObject::Array")); |
| 4118 |
|
| |
| 4119 |
|
| // Get object |
| 4120 |
0 |
| void* spvm_array = SPVM_XS_UTIL_get_spvm_object(aTHX_ sv_self); |
| 4121 |
|
| |
| 4122 |
0 |
| int32_t length = env->length(env, stack, spvm_array); |
| 4123 |
|
| |
| 4124 |
0 |
| SV* sv_length = sv_2mortal(newSViv(length)); |
| 4125 |
|
| |
| 4126 |
0 |
▶ | XPUSHs(sv_length); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_length); |
0 |
0 |
0 |
|
| 4127 |
0 |
| XSRETURN(1); |
| 4128 |
|
| } |
| 4129 |
|
| |
| 4130 |
|
| SV* |
| 4131 |
|
| _xs_to_elems(...) |
| 4132 |
|
| PPCODE: |
| 4133 |
|
| { |
| 4134 |
|
| |
| 4135 |
1 |
| SV* sv_self = ST(0); |
| 4136 |
1 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 4137 |
|
| |
| 4138 |
|
| // API |
| 4139 |
1 |
| SV** sv_api_ptr = hv_fetch(hv_self, "__api", strlen("__api"), 0); |
| 4140 |
1 |
▶ | SV* sv_api = sv_api_ptr ? *sv_api_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_api = sv_api_ptr ? *sv_api_ptr : &PL_sv_undef; |
1 |
0 |
1 |
|
| 4141 |
1 |
| HV* hv_api = (HV*)SvRV(sv_api); |
| 4142 |
|
| |
| 4143 |
|
| // Env |
| 4144 |
1 |
| SV** sv_env_ptr = hv_fetch(hv_api, "env", strlen("env"), 0); |
| 4145 |
1 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
1 |
0 |
1 |
|
| 4146 |
1 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 4147 |
|
| |
| 4148 |
|
| // Stack |
| 4149 |
1 |
| SV** sv_stack_ptr = hv_fetch(hv_api, "stack", strlen("stack"), 0); |
| 4150 |
1 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
1 |
0 |
1 |
|
| 4151 |
1 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 4152 |
|
| |
| 4153 |
|
| // Runtime |
| 4154 |
1 |
| void* runtime = env->runtime; |
| 4155 |
|
| |
| 4156 |
|
| assert(SvROK(sv_self) && sv_derived_from(sv_self, "SPVM::BlessedObject::Array")); |
| 4157 |
|
| |
| 4158 |
|
| // Get object |
| 4159 |
1 |
| void* spvm_array = SPVM_XS_UTIL_get_spvm_object(aTHX_ sv_self); |
| 4160 |
|
| |
| 4161 |
1 |
| int32_t length = env->length(env, stack, spvm_array); |
| 4162 |
|
| |
| 4163 |
1 |
| const char* basic_type_name = env->get_object_basic_type_name(env, stack, spvm_array); |
| 4164 |
1 |
| void* basic_type = env->api->runtime->get_basic_type_by_name(env->runtime, basic_type_name); |
| 4165 |
1 |
▶ | if (!basic_type) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!basic_type) { |
0 |
1 |
1 |
|
| 4166 |
0 |
| croak("%s class is not found\n %s at %s line %d\n", basic_type_name, __func__, FILE_NAME, __LINE__); |
| 4167 |
|
| } |
| 4168 |
1 |
| int32_t basic_type_id = env->api->basic_type->get_id(env->runtime, basic_type); |
| 4169 |
1 |
| int32_t type_dimension = env->get_object_type_dimension(env, stack, spvm_array); |
| 4170 |
1 |
| int32_t is_array_type = type_dimension > 0; |
| 4171 |
|
| |
| 4172 |
|
| assert(is_array_type); |
| 4173 |
|
| |
| 4174 |
1 |
| AV* av_values = (AV*)sv_2mortal((SV*)newAV()); |
| 4175 |
1 |
▶ | if (is_array_type) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (is_array_type) { |
0 |
1 |
1 |
|
| 4176 |
1 |
| int32_t elem_type_dimension = type_dimension - 1; |
| 4177 |
|
| |
| 4178 |
1 |
| int32_t array_is_mulnum_array = env->is_mulnum_array(env, stack, spvm_array); |
| 4179 |
1 |
| int32_t array_is_object_array = env->is_object_array(env, stack, spvm_array); |
| 4180 |
|
| |
| 4181 |
1 |
▶ | if (array_is_mulnum_array) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (array_is_mulnum_array) { |
0 |
1 |
1 |
|
| 4182 |
|
| |
| 4183 |
0 |
▶ | for (int32_t index = 0; index < length; index++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int32_t index = 0; index < length; index++) { |
0 |
0 |
0 |
|
| 4184 |
|
| |
| 4185 |
0 |
| int32_t basic_type_fields_length = env->api->basic_type->get_fields_length(env->runtime, basic_type); |
| 4186 |
0 |
| void* elems = (void*)env->get_elems_int(env, stack, spvm_array); |
| 4187 |
|
| |
| 4188 |
0 |
| HV* hv_value = (HV*)sv_2mortal((SV*)newHV()); |
| 4189 |
0 |
| int32_t fields_length = basic_type_fields_length; |
| 4190 |
0 |
▶ | for (int32_t field_index = 0; field_index < basic_type_fields_length; field_index++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int32_t field_index = 0; field_index < basic_type_fields_length; field_index++) { |
0 |
0 |
0 |
|
| 4191 |
0 |
| void* mulnum_field = env->api->basic_type->get_field_by_index(runtime, basic_type, field_index); |
| 4192 |
0 |
| const char* mulnum_field_name = env->api->field->get_name(env->runtime, mulnum_field); |
| 4193 |
|
| |
| 4194 |
|
| SV* sv_field_value; |
| 4195 |
0 |
| void* mulnum_field_basic_type = env->api->field->get_basic_type(env->runtime, mulnum_field); |
| 4196 |
0 |
| int32_t mulnum_field_basic_type_id = env->api->basic_type->get_id(env->runtime, mulnum_field_basic_type); |
| 4197 |
0 |
| switch (mulnum_field_basic_type_id) { |
| 4198 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_BYTE: { |
| 4199 |
0 |
| int8_t field_value = ((int8_t*)elems)[(fields_length * index) + field_index]; |
| 4200 |
0 |
| sv_field_value = sv_2mortal(newSViv(field_value)); |
| 4201 |
0 |
| break; |
| 4202 |
|
| } |
| 4203 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_SHORT: { |
| 4204 |
0 |
| int16_t field_value = ((int16_t*)elems)[(fields_length * index) + field_index]; |
| 4205 |
0 |
| sv_field_value = sv_2mortal(newSViv(field_value)); |
| 4206 |
0 |
| break; |
| 4207 |
|
| } |
| 4208 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_INT: { |
| 4209 |
0 |
| int32_t field_value = ((int32_t*)elems)[(fields_length * index) + field_index]; |
| 4210 |
0 |
| sv_field_value = sv_2mortal(newSViv(field_value)); |
| 4211 |
0 |
| break; |
| 4212 |
|
| } |
| 4213 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_LONG: { |
| 4214 |
0 |
| int64_t field_value = ((int64_t*)elems)[(fields_length * index) + field_index]; |
| 4215 |
0 |
| sv_field_value = sv_2mortal(newSViv(field_value)); |
| 4216 |
0 |
| break; |
| 4217 |
|
| } |
| 4218 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_FLOAT: { |
| 4219 |
0 |
| float field_value = ((float*)elems)[(fields_length * index) + field_index]; |
| 4220 |
0 |
| sv_field_value = sv_2mortal(newSVnv(field_value)); |
| 4221 |
0 |
| break; |
| 4222 |
|
| } |
| 4223 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_DOUBLE: { |
| 4224 |
0 |
| double field_value = ((double*)elems)[(fields_length * index) + field_index]; |
| 4225 |
0 |
| sv_field_value = sv_2mortal(newSVnv(field_value)); |
| 4226 |
0 |
| break; |
| 4227 |
|
| } |
| 4228 |
0 |
| default: { |
| 4229 |
|
| assert(0); |
| 4230 |
|
| } |
| 4231 |
|
| } |
| 4232 |
0 |
| SvREFCNT_inc(sv_field_value); |
| 4233 |
0 |
| (void)hv_store(hv_value, mulnum_field_name, strlen(mulnum_field_name), sv_field_value, 0); |
| 4234 |
|
| } |
| 4235 |
0 |
| SV* sv_value = sv_2mortal(newRV_inc((SV*)hv_value)); |
| 4236 |
0 |
| av_push(av_values, SvREFCNT_inc(sv_value)); |
| 4237 |
|
| } |
| 4238 |
|
| } |
| 4239 |
1 |
▶ | else if (array_is_object_array) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if (array_is_object_array) { |
1 |
0 |
1 |
|
| 4240 |
1 |
▶ | if (basic_type_id == SPVM_NATIVE_C_BASIC_TYPE_ID_STRING) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (basic_type_id == SPVM_NATIVE_C_BASIC_TYPE_ID_STRING) { |
1 |
0 |
1 |
|
| 4241 |
4 |
▶ | for (int32_t i = 0; i < length; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int32_t i = 0; i < length; i++) { |
3 |
1 |
4 |
|
| 4242 |
3 |
| void* object = env->get_elem_string(env, stack, spvm_array, i); |
| 4243 |
|
| |
| 4244 |
|
| SV* sv_value; |
| 4245 |
3 |
▶ | if (object != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (object != NULL) { |
3 |
0 |
3 |
|
| 4246 |
3 |
| sv_value = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_api, object, "SPVM::BlessedObject::String"); |
| 4247 |
|
| } |
| 4248 |
|
| else { |
| 4249 |
0 |
| sv_value = &PL_sv_undef; |
| 4250 |
|
| } |
| 4251 |
|
| |
| 4252 |
3 |
| av_push(av_values, SvREFCNT_inc(sv_value)); |
| 4253 |
|
| } |
| 4254 |
|
| } |
| 4255 |
|
| else { |
| 4256 |
0 |
▶ | for (int32_t index = 0; index < length; index++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int32_t index = 0; index < length; index++) { |
0 |
0 |
0 |
|
| 4257 |
|
| // Index |
| 4258 |
0 |
| void* value = env->get_elem_object(env, stack, spvm_array, index); |
| 4259 |
0 |
▶ | if (value == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (value == NULL) { |
0 |
0 |
0 |
|
| 4260 |
0 |
| av_push(av_values, &PL_sv_undef); |
| 4261 |
|
| } |
| 4262 |
|
| else { |
| 4263 |
0 |
| int32_t elem_type_is_array_type = elem_type_dimension > 0; |
| 4264 |
|
| SV* sv_value; |
| 4265 |
0 |
▶ | if (elem_type_is_array_type) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (elem_type_is_array_type) { |
0 |
0 |
0 |
|
| 4266 |
0 |
| sv_value = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_api, value, "SPVM::BlessedObject::Array"); |
| 4267 |
|
| } |
| 4268 |
|
| else { |
| 4269 |
0 |
| sv_value = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_api, value, "SPVM::BlessedObject::Class"); |
| 4270 |
|
| } |
| 4271 |
0 |
| av_push(av_values, SvREFCNT_inc(sv_value)); |
| 4272 |
|
| } |
| 4273 |
|
| } |
| 4274 |
|
| } |
| 4275 |
|
| } |
| 4276 |
|
| else { |
| 4277 |
0 |
| switch (basic_type_id) { |
| 4278 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_BYTE: { |
| 4279 |
0 |
| int8_t* elems = env->get_elems_byte(env, stack, spvm_array); |
| 4280 |
0 |
▶ | for (int32_t i = 0; i < length; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int32_t i = 0; i < length; i++) { |
0 |
0 |
0 |
|
| 4281 |
0 |
| SV* sv_value = sv_2mortal(newSViv(elems[i])); |
| 4282 |
0 |
| av_push(av_values, SvREFCNT_inc(sv_value)); |
| 4283 |
|
| } |
| 4284 |
0 |
| break; |
| 4285 |
|
| } |
| 4286 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_SHORT: { |
| 4287 |
0 |
| int16_t* elems = env->get_elems_short(env, stack, spvm_array); |
| 4288 |
0 |
▶ | for (int32_t i = 0; i < length; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int32_t i = 0; i < length; i++) { |
0 |
0 |
0 |
|
| 4289 |
0 |
| SV* sv_value = sv_2mortal(newSViv(elems[i])); |
| 4290 |
0 |
| av_push(av_values, SvREFCNT_inc(sv_value)); |
| 4291 |
|
| } |
| 4292 |
0 |
| break; |
| 4293 |
|
| } |
| 4294 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_INT: { |
| 4295 |
0 |
| int32_t* elems = env->get_elems_int(env, stack, spvm_array); |
| 4296 |
0 |
▶ | for (int32_t i = 0; i < length; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int32_t i = 0; i < length; i++) { |
0 |
0 |
0 |
|
| 4297 |
0 |
| SV* sv_value = sv_2mortal(newSViv(elems[i])); |
| 4298 |
0 |
| av_push(av_values, SvREFCNT_inc(sv_value)); |
| 4299 |
|
| } |
| 4300 |
0 |
| break; |
| 4301 |
|
| } |
| 4302 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_LONG: { |
| 4303 |
0 |
| int64_t* elems = env->get_elems_long(env, stack, spvm_array); |
| 4304 |
0 |
▶ | for (int32_t i = 0; i < length; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int32_t i = 0; i < length; i++) { |
0 |
0 |
0 |
|
| 4305 |
0 |
| SV* sv_value = sv_2mortal(newSViv(elems[i])); |
| 4306 |
0 |
| av_push(av_values, SvREFCNT_inc(sv_value)); |
| 4307 |
|
| } |
| 4308 |
0 |
| break; |
| 4309 |
|
| } |
| 4310 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_FLOAT: { |
| 4311 |
0 |
| float* elems = env->get_elems_float(env, stack, spvm_array); |
| 4312 |
0 |
▶ | for (int32_t i = 0; i < length; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int32_t i = 0; i < length; i++) { |
0 |
0 |
0 |
|
| 4313 |
0 |
| SV* sv_value = sv_2mortal(newSVnv(elems[i])); |
| 4314 |
0 |
| av_push(av_values, SvREFCNT_inc(sv_value)); |
| 4315 |
|
| } |
| 4316 |
0 |
| break; |
| 4317 |
|
| } |
| 4318 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_DOUBLE: { |
| 4319 |
0 |
| double* elems = env->get_elems_double(env, stack, spvm_array); |
| 4320 |
0 |
▶ | for (int32_t i = 0; i < length; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int32_t i = 0; i < length; i++) { |
0 |
0 |
0 |
|
| 4321 |
0 |
| SV* sv_value = sv_2mortal(newSVnv(elems[i])); |
| 4322 |
0 |
| av_push(av_values, SvREFCNT_inc(sv_value)); |
| 4323 |
|
| } |
| 4324 |
0 |
| break; |
| 4325 |
|
| } |
| 4326 |
0 |
| default: |
| 4327 |
|
| assert(0); |
| 4328 |
|
| } |
| 4329 |
|
| } |
| 4330 |
|
| } |
| 4331 |
|
| |
| 4332 |
1 |
| SV* sv_values = sv_2mortal(newRV_inc((SV*)av_values)); |
| 4333 |
|
| |
| 4334 |
1 |
▶ | XPUSHs(sv_values); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_values); |
0 |
1 |
1 |
|
| 4335 |
1 |
| XSRETURN(1); |
| 4336 |
|
| } |
| 4337 |
|
| |
| 4338 |
|
| SV* |
| 4339 |
|
| _xs_to_bin(...) |
| 4340 |
|
| PPCODE: |
| 4341 |
|
| { |
| 4342 |
|
| |
| 4343 |
0 |
| SV* sv_self = ST(0); |
| 4344 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 4345 |
|
| |
| 4346 |
|
| // API |
| 4347 |
0 |
| SV** sv_api_ptr = hv_fetch(hv_self, "__api", strlen("__api"), 0); |
| 4348 |
0 |
▶ | SV* sv_api = sv_api_ptr ? *sv_api_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_api = sv_api_ptr ? *sv_api_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 4349 |
0 |
| HV* hv_api = (HV*)SvRV(sv_api); |
| 4350 |
|
| |
| 4351 |
|
| // Env |
| 4352 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_api, "env", strlen("env"), 0); |
| 4353 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 4354 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 4355 |
|
| |
| 4356 |
|
| // Stack |
| 4357 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_api, "stack", strlen("stack"), 0); |
| 4358 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 4359 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 4360 |
|
| |
| 4361 |
|
| // Runtime |
| 4362 |
0 |
| void* runtime = env->runtime; |
| 4363 |
|
| |
| 4364 |
|
| assert(SvROK(sv_self) && sv_derived_from(sv_self, "SPVM::BlessedObject::Array")); |
| 4365 |
|
| |
| 4366 |
|
| // Get object |
| 4367 |
0 |
| void* spvm_array = SPVM_XS_UTIL_get_spvm_object(aTHX_ sv_self); |
| 4368 |
|
| |
| 4369 |
0 |
| int32_t length = env->length(env, stack, spvm_array); |
| 4370 |
|
| |
| 4371 |
0 |
| const char* basic_type_name = env->get_object_basic_type_name(env, stack, spvm_array); |
| 4372 |
0 |
| void* basic_type = env->api->runtime->get_basic_type_by_name(env->runtime, basic_type_name); |
| 4373 |
0 |
▶ | if (!basic_type) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!basic_type) { |
0 |
0 |
0 |
|
| 4374 |
0 |
| croak("%s class is not found\n %s at %s line %d\n", basic_type_name, __func__, FILE_NAME, __LINE__); |
| 4375 |
|
| } |
| 4376 |
0 |
| int32_t basic_type_id = env->api->basic_type->get_id(env->runtime, basic_type); |
| 4377 |
0 |
| int32_t type_dimension = env->get_object_type_dimension(env, stack, spvm_array); |
| 4378 |
0 |
| int32_t is_array_type = type_dimension > 0; |
| 4379 |
|
| assert(is_array_type); |
| 4380 |
|
| |
| 4381 |
|
| SV* sv_binary; |
| 4382 |
0 |
▶ | if (is_array_type) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (is_array_type) { |
0 |
0 |
0 |
|
| 4383 |
0 |
| int32_t elem_type_dimension = type_dimension - 1; |
| 4384 |
|
| |
| 4385 |
0 |
| int32_t array_is_mulnum_array = env->is_mulnum_array(env, stack, spvm_array); |
| 4386 |
0 |
| int32_t array_is_object_array = env->is_object_array(env, stack, spvm_array); |
| 4387 |
|
| |
| 4388 |
0 |
▶ | if (array_is_mulnum_array) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (array_is_mulnum_array) { |
0 |
0 |
0 |
|
| 4389 |
0 |
| int32_t basic_type_fields_length = env->api->basic_type->get_fields_length(env->runtime, basic_type); |
| 4390 |
|
| |
| 4391 |
0 |
| int32_t fields_length = basic_type_fields_length; |
| 4392 |
|
| |
| 4393 |
0 |
| void* mulnum_field = env->api->basic_type->get_field_by_index(runtime, basic_type, 0); |
| 4394 |
0 |
| void* mulnum_field_basic_type = env->api->field->get_basic_type(env->runtime, mulnum_field); |
| 4395 |
0 |
| int32_t mulnum_field_basic_type_id = env->api->basic_type->get_id(env->runtime, mulnum_field_basic_type); |
| 4396 |
0 |
| switch (mulnum_field_basic_type_id) { |
| 4397 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_BYTE: { |
| 4398 |
0 |
| int8_t* elems = env->get_elems_byte(env, stack, spvm_array); |
| 4399 |
|
| |
| 4400 |
0 |
| sv_binary = sv_2mortal(newSVpvn((char*)elems, fields_length * length)); |
| 4401 |
0 |
| break; |
| 4402 |
|
| } |
| 4403 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_SHORT: { |
| 4404 |
0 |
| int16_t* elems = env->get_elems_short(env, stack, spvm_array); |
| 4405 |
|
| |
| 4406 |
0 |
| sv_binary = sv_2mortal(newSVpvn((char*)elems, fields_length * length * 2)); |
| 4407 |
0 |
| break; |
| 4408 |
|
| } |
| 4409 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_INT: { |
| 4410 |
0 |
| int32_t* elems = env->get_elems_int(env, stack, spvm_array); |
| 4411 |
|
| |
| 4412 |
0 |
| sv_binary = sv_2mortal(newSVpvn((char*)elems, fields_length * length * 4)); |
| 4413 |
0 |
| break; |
| 4414 |
|
| } |
| 4415 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_LONG: { |
| 4416 |
0 |
| int64_t* elems = env->get_elems_long(env, stack, spvm_array); |
| 4417 |
|
| |
| 4418 |
0 |
| sv_binary = sv_2mortal(newSVpvn((char*)elems, fields_length * length * 8)); |
| 4419 |
0 |
| break; |
| 4420 |
|
| } |
| 4421 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_FLOAT: { |
| 4422 |
0 |
| float* elems = env->get_elems_float(env, stack, spvm_array); |
| 4423 |
|
| |
| 4424 |
0 |
| sv_binary = sv_2mortal(newSVpvn((char*)elems, fields_length * length * 4)); |
| 4425 |
0 |
| break; |
| 4426 |
|
| } |
| 4427 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_DOUBLE: { |
| 4428 |
0 |
| double* elems = env->get_elems_double(env, stack, spvm_array); |
| 4429 |
|
| |
| 4430 |
0 |
| sv_binary = sv_2mortal(newSVpvn((char*)elems, fields_length * length * 8)); |
| 4431 |
0 |
| break; |
| 4432 |
|
| } |
| 4433 |
0 |
| default: { |
| 4434 |
|
| assert(0); |
| 4435 |
|
| } |
| 4436 |
|
| } |
| 4437 |
|
| } |
| 4438 |
0 |
▶ | else if (array_is_object_array) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if (array_is_object_array) { |
0 |
0 |
0 |
|
| 4439 |
0 |
| croak("The object array cannnot be converted to a binary\n %s at %s line %d\n", __func__, FILE_NAME, __LINE__); |
| 4440 |
|
| } |
| 4441 |
|
| else { |
| 4442 |
0 |
| switch (basic_type_id) { |
| 4443 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_BYTE: { |
| 4444 |
0 |
| int8_t* elems = env->get_elems_byte(env, stack, spvm_array); |
| 4445 |
|
| |
| 4446 |
0 |
| sv_binary = sv_2mortal(newSVpvn((char*)elems, length)); |
| 4447 |
0 |
| break; |
| 4448 |
|
| } |
| 4449 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_SHORT: { |
| 4450 |
0 |
| int16_t* elems = env->get_elems_short(env, stack, spvm_array); |
| 4451 |
|
| |
| 4452 |
0 |
| sv_binary = sv_2mortal(newSVpvn((char*)elems, length * 2)); |
| 4453 |
0 |
| break; |
| 4454 |
|
| } |
| 4455 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_INT: { |
| 4456 |
0 |
| int32_t* elems = env->get_elems_int(env, stack, spvm_array); |
| 4457 |
|
| |
| 4458 |
0 |
| sv_binary = sv_2mortal(newSVpvn((char*)elems, length * 4)); |
| 4459 |
0 |
| break; |
| 4460 |
|
| } |
| 4461 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_LONG: { |
| 4462 |
0 |
| int64_t* elems = env->get_elems_long(env, stack, spvm_array); |
| 4463 |
|
| |
| 4464 |
0 |
| sv_binary = sv_2mortal(newSVpvn((char*)elems, length * 8)); |
| 4465 |
0 |
| break; |
| 4466 |
|
| } |
| 4467 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_FLOAT: { |
| 4468 |
0 |
| float* elems = env->get_elems_float(env, stack, spvm_array); |
| 4469 |
|
| |
| 4470 |
0 |
| sv_binary = sv_2mortal(newSVpvn((char*)elems, length * 4)); |
| 4471 |
0 |
| break; |
| 4472 |
|
| } |
| 4473 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_DOUBLE: { |
| 4474 |
0 |
| double* elems = env->get_elems_double(env, stack, spvm_array); |
| 4475 |
|
| |
| 4476 |
0 |
| sv_binary = sv_2mortal(newSVpvn((char*)elems, length * 8)); |
| 4477 |
0 |
| break; |
| 4478 |
|
| } |
| 4479 |
0 |
| default: { |
| 4480 |
|
| assert(0); |
| 4481 |
|
| } |
| 4482 |
|
| } |
| 4483 |
|
| } |
| 4484 |
|
| } |
| 4485 |
|
| |
| 4486 |
0 |
▶ | XPUSHs(sv_binary); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_binary); |
0 |
0 |
0 |
|
| 4487 |
0 |
| XSRETURN(1); |
| 4488 |
|
| } |
| 4489 |
|
| |
| 4490 |
|
| SV* |
| 4491 |
|
| _xs_set(...) |
| 4492 |
|
| PPCODE: |
| 4493 |
|
| { |
| 4494 |
|
| |
| 4495 |
0 |
| SV* sv_self = ST(0); |
| 4496 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 4497 |
|
| |
| 4498 |
|
| // API |
| 4499 |
0 |
| SV** sv_api_ptr = hv_fetch(hv_self, "__api", strlen("__api"), 0); |
| 4500 |
0 |
▶ | SV* sv_api = sv_api_ptr ? *sv_api_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_api = sv_api_ptr ? *sv_api_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 4501 |
0 |
| HV* hv_api = (HV*)SvRV(sv_api); |
| 4502 |
|
| |
| 4503 |
|
| // Env |
| 4504 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_api, "env", strlen("env"), 0); |
| 4505 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 4506 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 4507 |
|
| |
| 4508 |
|
| // Stack |
| 4509 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_api, "stack", strlen("stack"), 0); |
| 4510 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 4511 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 4512 |
|
| |
| 4513 |
0 |
| SV* sv_index = ST(1); |
| 4514 |
0 |
| SV* sv_elem = ST(2); |
| 4515 |
|
| |
| 4516 |
|
| // Index |
| 4517 |
0 |
| int32_t index = (int32_t)SvIV(sv_index); |
| 4518 |
|
| |
| 4519 |
|
| // Array |
| 4520 |
0 |
| void* spvm_array = SPVM_XS_UTIL_get_spvm_object(aTHX_ sv_self); |
| 4521 |
|
| |
| 4522 |
|
| // Length |
| 4523 |
0 |
| int32_t length = env->length(env, stack, spvm_array); |
| 4524 |
|
| |
| 4525 |
|
| // Check range |
| 4526 |
0 |
▶ | if (!(index >= 0 && index < length)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(index >= 0 && index < length)) { |
0 |
0 |
0 |
| if (!(index >= 0 && index < length)) { |
0 |
0 |
0 |
|
| 4527 |
0 |
| croak("$index must be greatr than or equal to 0 and less than the length of the array\n %s at %s line %d\n", __func__, FILE_NAME, __LINE__); |
| 4528 |
|
| } |
| 4529 |
|
| |
| 4530 |
0 |
| const char* basic_type_name = env->get_object_basic_type_name(env, stack, spvm_array); |
| 4531 |
0 |
| void* basic_type = env->api->runtime->get_basic_type_by_name(env->runtime, basic_type_name); |
| 4532 |
0 |
▶ | if (!basic_type) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!basic_type) { |
0 |
0 |
0 |
|
| 4533 |
0 |
| croak("%s class is not found\n %s at %s line %d\n", basic_type_name, __func__, FILE_NAME, __LINE__); |
| 4534 |
|
| } |
| 4535 |
0 |
| int32_t basic_type_id = env->api->basic_type->get_id(env->runtime, basic_type); |
| 4536 |
0 |
| int32_t type_dimension = env->get_object_type_dimension(env, stack, spvm_array); |
| 4537 |
|
| |
| 4538 |
0 |
▶ | if (type_dimension == 1) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (type_dimension == 1) { |
0 |
0 |
0 |
|
| 4539 |
0 |
| switch (basic_type_id) { |
| 4540 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_BYTE: { |
| 4541 |
|
| // Value |
| 4542 |
0 |
| int8_t elem = (int8_t)SvIV(sv_elem); |
| 4543 |
|
| |
| 4544 |
|
| // Set element |
| 4545 |
0 |
| int8_t* elems = env->get_elems_byte(env, stack, spvm_array); |
| 4546 |
|
| |
| 4547 |
0 |
| elems[index] = elem; |
| 4548 |
|
| |
| 4549 |
0 |
| break; |
| 4550 |
|
| } |
| 4551 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_SHORT: { |
| 4552 |
|
| // Value |
| 4553 |
0 |
| int16_t elem = (int16_t)SvIV(sv_elem); |
| 4554 |
|
| |
| 4555 |
|
| // Set element |
| 4556 |
0 |
| int16_t* elems = env->get_elems_short(env, stack, spvm_array); |
| 4557 |
|
| |
| 4558 |
0 |
| elems[index] = elem; |
| 4559 |
0 |
| break; |
| 4560 |
|
| } |
| 4561 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_INT: { |
| 4562 |
|
| // Value |
| 4563 |
0 |
| int32_t elem = (int32_t)SvIV(sv_elem); |
| 4564 |
|
| |
| 4565 |
|
| // Set element |
| 4566 |
0 |
| int32_t* elems = env->get_elems_int(env, stack, spvm_array); |
| 4567 |
|
| |
| 4568 |
0 |
| elems[index] = elem; |
| 4569 |
0 |
| break; |
| 4570 |
|
| } |
| 4571 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_LONG: { |
| 4572 |
|
| // Value |
| 4573 |
0 |
| int64_t elem = (int64_t)SvIV(sv_elem); |
| 4574 |
|
| |
| 4575 |
|
| // Set element |
| 4576 |
0 |
| int64_t* elems = env->get_elems_long(env, stack, spvm_array); |
| 4577 |
|
| |
| 4578 |
0 |
| elems[index] = elem; |
| 4579 |
0 |
| break; |
| 4580 |
|
| } |
| 4581 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_FLOAT: { |
| 4582 |
|
| // Value |
| 4583 |
0 |
| float elem = (float)SvNV(sv_elem); |
| 4584 |
|
| |
| 4585 |
|
| // Set element |
| 4586 |
0 |
| float* elems = env->get_elems_float(env, stack, spvm_array); |
| 4587 |
|
| |
| 4588 |
0 |
| elems[index] = elem; |
| 4589 |
0 |
| break; |
| 4590 |
|
| } |
| 4591 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_DOUBLE: { |
| 4592 |
|
| // Value |
| 4593 |
0 |
| double elem = (double)SvNV(sv_elem); |
| 4594 |
|
| |
| 4595 |
|
| // Set element |
| 4596 |
0 |
| double* elems = env->get_elems_double(env, stack, spvm_array); |
| 4597 |
|
| |
| 4598 |
0 |
| elems[index] = elem; |
| 4599 |
0 |
| break; |
| 4600 |
|
| } |
| 4601 |
0 |
| default: { |
| 4602 |
|
| // Get object |
| 4603 |
0 |
| void* elem = SPVM_XS_UTIL_get_spvm_object(aTHX_ sv_elem); |
| 4604 |
|
| |
| 4605 |
0 |
| env->set_elem_object(env, stack, spvm_array, index, elem); |
| 4606 |
|
| } |
| 4607 |
|
| } |
| 4608 |
|
| } |
| 4609 |
0 |
▶ | else if (type_dimension > 1) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if (type_dimension > 1) { |
0 |
0 |
0 |
|
| 4610 |
|
| |
| 4611 |
|
| // Get object |
| 4612 |
0 |
| void* elem = SPVM_XS_UTIL_get_spvm_object(aTHX_ sv_elem); |
| 4613 |
|
| |
| 4614 |
0 |
| int32_t elem_isa = env->elem_isa(env, stack, spvm_array, elem); |
| 4615 |
0 |
▶ | if (!elem_isa) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!elem_isa) { |
0 |
0 |
0 |
|
| 4616 |
0 |
| croak("$elem must be assigned to the element of the array\n %s at %s line %d\n", __func__, FILE_NAME, __LINE__); |
| 4617 |
|
| } |
| 4618 |
|
| |
| 4619 |
0 |
| env->set_elem_object(env, stack, spvm_array, index, elem); |
| 4620 |
|
| } |
| 4621 |
|
| else { |
| 4622 |
|
| assert(0); |
| 4623 |
|
| } |
| 4624 |
|
| |
| 4625 |
0 |
| XSRETURN(0); |
| 4626 |
|
| } |
| 4627 |
|
| |
| 4628 |
|
| SV* |
| 4629 |
|
| _xs_get(...) |
| 4630 |
|
| PPCODE: |
| 4631 |
|
| { |
| 4632 |
|
| |
| 4633 |
0 |
| SV* sv_self = ST(0); |
| 4634 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 4635 |
|
| |
| 4636 |
|
| // API |
| 4637 |
0 |
| SV** sv_api_ptr = hv_fetch(hv_self, "__api", strlen("__api"), 0); |
| 4638 |
0 |
▶ | SV* sv_api = sv_api_ptr ? *sv_api_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_api = sv_api_ptr ? *sv_api_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 4639 |
0 |
| HV* hv_api = (HV*)SvRV(sv_api); |
| 4640 |
|
| |
| 4641 |
|
| // Env |
| 4642 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_api, "env", strlen("env"), 0); |
| 4643 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 4644 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 4645 |
|
| |
| 4646 |
|
| // Stack |
| 4647 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_api, "stack", strlen("stack"), 0); |
| 4648 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 4649 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 4650 |
|
| |
| 4651 |
0 |
| SV* sv_index = ST(1); |
| 4652 |
|
| |
| 4653 |
|
| // Index |
| 4654 |
0 |
| int32_t index = (int32_t)SvIV(sv_index); |
| 4655 |
|
| |
| 4656 |
|
| // Array |
| 4657 |
0 |
| void* spvm_array = SPVM_XS_UTIL_get_spvm_object(aTHX_ sv_self); |
| 4658 |
|
| |
| 4659 |
|
| // Length |
| 4660 |
0 |
| int32_t length = env->length(env, stack, spvm_array); |
| 4661 |
|
| |
| 4662 |
|
| // Check range |
| 4663 |
0 |
▶ | if (!(index >= 0 && index < length)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(index >= 0 && index < length)) { |
0 |
0 |
0 |
| if (!(index >= 0 && index < length)) { |
0 |
0 |
0 |
|
| 4664 |
0 |
| croak("$index must be greater than or equal to 0 and less than the length of the array\n %s at %s line %d\n", __func__, FILE_NAME, __LINE__); |
| 4665 |
|
| } |
| 4666 |
|
| |
| 4667 |
0 |
| const char* basic_type_name = env->get_object_basic_type_name(env, stack, spvm_array); |
| 4668 |
0 |
| void* basic_type = env->api->runtime->get_basic_type_by_name(env->runtime, basic_type_name); |
| 4669 |
0 |
▶ | if (!basic_type) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!basic_type) { |
0 |
0 |
0 |
|
| 4670 |
0 |
| croak("%s class is not found\n %s at %s line %d\n", basic_type_name, __func__, FILE_NAME, __LINE__); |
| 4671 |
|
| } |
| 4672 |
0 |
| int32_t basic_type_id = env->api->basic_type->get_id(env->runtime, basic_type); |
| 4673 |
0 |
| int32_t type_dimension = env->get_object_type_dimension(env, stack, spvm_array); |
| 4674 |
|
| |
| 4675 |
|
| assert(type_dimension >= 1); |
| 4676 |
0 |
| SV* sv_elem = NULL; |
| 4677 |
0 |
| int32_t elem_is_object = 0; |
| 4678 |
0 |
▶ | if (type_dimension == 1) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (type_dimension == 1) { |
0 |
0 |
0 |
|
| 4679 |
0 |
| switch (basic_type_id) { |
| 4680 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_BYTE: { |
| 4681 |
|
| // Get element |
| 4682 |
0 |
| int8_t* elems = env->get_elems_byte(env, stack, spvm_array); |
| 4683 |
0 |
| int8_t elem = elems[index]; |
| 4684 |
0 |
| sv_elem = sv_2mortal(newSViv(elem)); |
| 4685 |
0 |
| break; |
| 4686 |
|
| } |
| 4687 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_SHORT: { |
| 4688 |
|
| // Get element |
| 4689 |
0 |
| int16_t* elems = env->get_elems_short(env, stack, spvm_array); |
| 4690 |
0 |
| int16_t elem = elems[index]; |
| 4691 |
0 |
| sv_elem = sv_2mortal(newSViv(elem)); |
| 4692 |
0 |
| break; |
| 4693 |
|
| } |
| 4694 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_INT: { |
| 4695 |
|
| // Get element |
| 4696 |
0 |
| int32_t* elems = env->get_elems_int(env, stack, spvm_array); |
| 4697 |
0 |
| int32_t elem = elems[index]; |
| 4698 |
0 |
| sv_elem = sv_2mortal(newSViv(elem)); |
| 4699 |
0 |
| break; |
| 4700 |
|
| } |
| 4701 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_LONG: { |
| 4702 |
|
| // Get element |
| 4703 |
0 |
| int64_t* elems = env->get_elems_long(env, stack, spvm_array); |
| 4704 |
0 |
| int64_t elem = elems[index]; |
| 4705 |
0 |
| sv_elem = sv_2mortal(newSViv(elem)); |
| 4706 |
0 |
| break; |
| 4707 |
|
| } |
| 4708 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_FLOAT: { |
| 4709 |
|
| // Get element |
| 4710 |
0 |
| float* elems = env->get_elems_float(env, stack, spvm_array); |
| 4711 |
0 |
| float elem = elems[index]; |
| 4712 |
0 |
| sv_elem = sv_2mortal(newSVnv(elem)); |
| 4713 |
0 |
| break; |
| 4714 |
|
| } |
| 4715 |
0 |
| case SPVM_NATIVE_C_BASIC_TYPE_ID_DOUBLE: { |
| 4716 |
|
| // Get element |
| 4717 |
0 |
| double* elems = env->get_elems_double(env, stack, spvm_array); |
| 4718 |
0 |
| double elem = elems[index]; |
| 4719 |
0 |
| sv_elem = sv_2mortal(newSVnv(elem)); |
| 4720 |
0 |
| break; |
| 4721 |
|
| } |
| 4722 |
0 |
| default: { |
| 4723 |
0 |
| elem_is_object = 1; |
| 4724 |
|
| } |
| 4725 |
|
| } |
| 4726 |
|
| } |
| 4727 |
0 |
▶ | else if (type_dimension > 1) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if (type_dimension > 1) { |
0 |
0 |
0 |
|
| 4728 |
0 |
| elem_is_object = 1; |
| 4729 |
|
| } |
| 4730 |
|
| |
| 4731 |
0 |
▶ | if (elem_is_object) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (elem_is_object) { |
0 |
0 |
0 |
|
| 4732 |
0 |
| void* runtime = env->runtime; |
| 4733 |
|
| |
| 4734 |
|
| // Element type dimension |
| 4735 |
0 |
| int32_t elem_type_dimension = env->get_object_type_dimension(env, stack, spvm_array) - 1; |
| 4736 |
|
| |
| 4737 |
|
| // Index |
| 4738 |
0 |
| void* elem = env->get_elem_object(env, stack, spvm_array, index); |
| 4739 |
|
| |
| 4740 |
0 |
▶ | if (elem_type_dimension == 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (elem_type_dimension == 0) { |
0 |
0 |
0 |
|
| 4741 |
0 |
| sv_elem = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_api, elem, "SPVM::BlessedObject::Class"); |
| 4742 |
|
| } |
| 4743 |
0 |
▶ | else if (elem_type_dimension > 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if (elem_type_dimension > 0) { |
0 |
0 |
0 |
|
| 4744 |
0 |
| sv_elem = SPVM_XS_UTIL_new_sv_blessed_object(aTHX_ sv_api, elem, "SPVM::BlessedObject::Array"); |
| 4745 |
|
| } |
| 4746 |
|
| } |
| 4747 |
|
| |
| 4748 |
0 |
▶ | XPUSHs(sv_elem); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_elem); |
0 |
0 |
0 |
|
| 4749 |
0 |
| XSRETURN(1); |
| 4750 |
|
| } |
| 4751 |
|
| |
| 4752 |
|
| MODULE = SPVM::BlessedObject::Class PACKAGE = SPVM::BlessedObject::Class |
| 4753 |
|
| |
| 4754 |
|
| SV* |
| 4755 |
|
| get_basic_type_name(...) |
| 4756 |
|
| PPCODE: |
| 4757 |
|
| { |
| 4758 |
|
| |
| 4759 |
0 |
| SV* sv_object = ST(0); |
| 4760 |
0 |
| HV* hv_object = (HV*)SvRV(sv_object); |
| 4761 |
|
| |
| 4762 |
|
| assert(SvOK(sv_object)); |
| 4763 |
|
| |
| 4764 |
|
| // Get object |
| 4765 |
0 |
| void* object = SPVM_XS_UTIL_get_spvm_object(aTHX_ sv_object); |
| 4766 |
|
| |
| 4767 |
|
| // API |
| 4768 |
0 |
| SV** sv_api_ptr = hv_fetch(hv_object, "__api", strlen("__api"), 0); |
| 4769 |
0 |
▶ | SV* sv_api = sv_api_ptr ? *sv_api_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_api = sv_api_ptr ? *sv_api_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 4770 |
0 |
| HV* hv_api = (HV*)SvRV(sv_api); |
| 4771 |
|
| |
| 4772 |
|
| // Env |
| 4773 |
0 |
| SV** sv_env_ptr = hv_fetch(hv_api, "env", strlen("env"), 0); |
| 4774 |
0 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 4775 |
0 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_env(aTHX_ sv_env); |
| 4776 |
|
| |
| 4777 |
|
| // Stack |
| 4778 |
0 |
| SV** sv_stack_ptr = hv_fetch(hv_api, "stack", strlen("stack"), 0); |
| 4779 |
0 |
▶ | SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_stack = sv_stack_ptr ? *sv_stack_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 4780 |
0 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_stack(aTHX_ sv_stack); |
| 4781 |
|
| |
| 4782 |
0 |
| const char* basic_type_name = env->get_object_basic_type_name(env, stack, object); |
| 4783 |
|
| |
| 4784 |
0 |
| SV* sv_basic_type_name = sv_2mortal(newSVpv(basic_type_name, 0)); |
| 4785 |
|
| |
| 4786 |
0 |
▶ | XPUSHs(sv_basic_type_name); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_basic_type_name); |
0 |
0 |
0 |
|
| 4787 |
0 |
| XSRETURN(1); |
| 4788 |
|
| } |
| 4789 |
|
| |
| 4790 |
|
| |
| 4791 |
|
| MODULE = SPVM::Builder::Native::Compiler PACKAGE = SPVM::Builder::Native::Compiler |
| 4792 |
|
| |
| 4793 |
|
| SV* |
| 4794 |
|
| DESTROY(...) |
| 4795 |
|
| PPCODE: |
| 4796 |
|
| { |
| 4797 |
|
| |
| 4798 |
1077 |
| SV* sv_self = ST(0); |
| 4799 |
1077 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 4800 |
|
| |
| 4801 |
1077 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 4802 |
|
| |
| 4803 |
1077 |
| SV** sv_runtime_ptr = hv_fetch(hv_self, "runtime", strlen("runtime"), 0); |
| 4804 |
1077 |
▶ | SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
1077 |
0 |
1077 |
|
| 4805 |
1077 |
| HV* hv_runtime = (HV*)SvRV(sv_runtime); |
| 4806 |
|
| |
| 4807 |
1077 |
| SV** sv_env_ptr = hv_fetch(hv_runtime, "env", strlen("env"), 0); |
| 4808 |
1077 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
1077 |
0 |
1077 |
|
| 4809 |
1077 |
| HV* hv_env = (HV*)SvRV(sv_env); |
| 4810 |
|
| |
| 4811 |
1077 |
| (void)hv_store(hv_env, "runtime", strlen("runtime"), &PL_sv_undef, 0); |
| 4812 |
|
| |
| 4813 |
1077 |
| void* compiler = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 4814 |
|
| |
| 4815 |
1077 |
| boot_env->api->compiler->free_instance(compiler); |
| 4816 |
|
| |
| 4817 |
1077 |
| XSRETURN(0); |
| 4818 |
|
| } |
| 4819 |
|
| |
| 4820 |
|
| SV* |
| 4821 |
|
| create_native_compiler(...) |
| 4822 |
|
| PPCODE: |
| 4823 |
|
| { |
| 4824 |
|
| |
| 4825 |
1077 |
| SV* sv_self = ST(0); |
| 4826 |
1077 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 4827 |
|
| |
| 4828 |
1077 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 4829 |
|
| |
| 4830 |
1077 |
| void* compiler = boot_env->api->compiler->new_instance(); |
| 4831 |
|
| |
| 4832 |
1077 |
| size_t iv_compiler = PTR2IV(compiler); |
| 4833 |
1077 |
| SV* sviv_compiler = sv_2mortal(newSViv(iv_compiler)); |
| 4834 |
1077 |
| SV* sv_compiler = sv_2mortal(newRV_inc(sviv_compiler)); |
| 4835 |
1077 |
| (void)hv_store(hv_self, "pointer", strlen("pointer"), SvREFCNT_inc(sv_compiler), 0); |
| 4836 |
|
| |
| 4837 |
1077 |
| void* runtime = boot_env->api->compiler->get_runtime(compiler); |
| 4838 |
|
| |
| 4839 |
1077 |
| SV* sv_runtime = SPVM_XS_UTIL_new_sv_pointer_object(aTHX_ runtime, "SPVM::Builder::Native::Runtime"); |
| 4840 |
1077 |
| HV* hv_runtime = (HV*)SvRV(sv_runtime); |
| 4841 |
1077 |
| (void)hv_store(hv_self, "runtime", strlen("runtime"), SvREFCNT_inc(sv_runtime), 0); |
| 4842 |
|
| |
| 4843 |
1077 |
| SPVM_ENV* env = boot_env->api->runtime->get_env(runtime); |
| 4844 |
|
| |
| 4845 |
1077 |
| SV* sv_env = SPVM_XS_UTIL_new_sv_pointer_object(aTHX_ env, "SPVM::Builder::Native::Env"); |
| 4846 |
1077 |
| HV* hv_env = (HV*)SvRV(sv_env); |
| 4847 |
1077 |
| (void)hv_store(hv_env, "runtime", strlen("runtime"), SvREFCNT_inc(sv_runtime), 0); |
| 4848 |
|
| |
| 4849 |
1077 |
| SV* sv_no_destroy = sv_2mortal(newSViv(1)); |
| 4850 |
1077 |
| (void)hv_store(hv_env, "no_destroy", strlen("no_destroy"), SvREFCNT_inc(sv_no_destroy), 0); |
| 4851 |
|
| |
| 4852 |
1077 |
| (void)hv_store(hv_runtime, "env", strlen("env"), SvREFCNT_inc(sv_env), 0); |
| 4853 |
|
| |
| 4854 |
1077 |
| XSRETURN(0); |
| 4855 |
|
| } |
| 4856 |
|
| |
| 4857 |
|
| SV* |
| 4858 |
|
| compile(...) |
| 4859 |
|
| PPCODE: |
| 4860 |
|
| { |
| 4861 |
|
| |
| 4862 |
1409 |
| SV* sv_self = ST(0); |
| 4863 |
1409 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 4864 |
|
| |
| 4865 |
1409 |
| SV* sv_basic_type_name = ST(1); |
| 4866 |
|
| |
| 4867 |
1409 |
| const char* basic_type_name = NULL; |
| 4868 |
1409 |
▶ | if (SvOK(sv_basic_type_name)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_basic_type_name)) { |
1098 |
311 |
1409 |
|
| 4869 |
1098 |
| basic_type_name = SvPV_nolen(sv_basic_type_name); |
| 4870 |
|
| } |
| 4871 |
|
| |
| 4872 |
1409 |
| void* compiler = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 4873 |
|
| |
| 4874 |
1409 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 4875 |
|
| |
| 4876 |
1409 |
| int32_t status = boot_env->api->compiler->compile(compiler, basic_type_name); |
| 4877 |
|
| |
| 4878 |
1409 |
▶ | if (!(status == 0)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!(status == 0)) { |
400 |
1009 |
1409 |
|
| 4879 |
400 |
| croak("Failed to compile %s class.", basic_type_name); |
| 4880 |
|
| } |
| 4881 |
|
| |
| 4882 |
1009 |
| XSRETURN(0); |
| 4883 |
|
| } |
| 4884 |
|
| |
| 4885 |
|
| SV* |
| 4886 |
|
| compile_anon_class(...) |
| 4887 |
|
| PPCODE: |
| 4888 |
|
| { |
| 4889 |
|
| |
| 4890 |
27 |
| SV* sv_self = ST(0); |
| 4891 |
27 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 4892 |
|
| |
| 4893 |
27 |
| SV* sv_source = ST(1); |
| 4894 |
|
| |
| 4895 |
27 |
| const char* source = NULL; |
| 4896 |
27 |
▶ | if (SvOK(sv_source)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_source)) { |
27 |
0 |
27 |
|
| 4897 |
27 |
| source = SvPV_nolen(sv_source); |
| 4898 |
|
| } |
| 4899 |
|
| |
| 4900 |
27 |
| void* compiler = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 4901 |
|
| |
| 4902 |
27 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 4903 |
|
| |
| 4904 |
27 |
| const char* anon_basic_type_name = NULL; |
| 4905 |
27 |
| int32_t status = boot_env->api->compiler->compile_anon_class(compiler, source, &anon_basic_type_name); |
| 4906 |
|
| |
| 4907 |
27 |
▶ | if (!(status == 0)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!(status == 0)) { |
2 |
25 |
27 |
|
| 4908 |
2 |
| croak("Failed to compile a source code for an anon class."); |
| 4909 |
|
| } |
| 4910 |
|
| |
| 4911 |
25 |
| SV* sv_anon_basic_type_name = sv_2mortal(newSVpv(anon_basic_type_name, 0)); |
| 4912 |
|
| |
| 4913 |
25 |
▶ | XPUSHs(sv_anon_basic_type_name); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_anon_basic_type_name); |
0 |
25 |
25 |
|
| 4914 |
|
| |
| 4915 |
25 |
| XSRETURN(1); |
| 4916 |
|
| } |
| 4917 |
|
| |
| 4918 |
|
| SV* |
| 4919 |
|
| compile_script(...) |
| 4920 |
|
| PPCODE: |
| 4921 |
|
| { |
| 4922 |
|
| |
| 4923 |
0 |
| SV* sv_self = ST(0); |
| 4924 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 4925 |
|
| |
| 4926 |
0 |
| SV* sv_source = ST(1); |
| 4927 |
|
| |
| 4928 |
0 |
| const char* source = NULL; |
| 4929 |
0 |
▶ | if (SvOK(sv_source)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_source)) { |
0 |
0 |
0 |
|
| 4930 |
0 |
| source = SvPV_nolen(sv_source); |
| 4931 |
|
| } |
| 4932 |
|
| |
| 4933 |
0 |
| void* compiler = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 4934 |
|
| |
| 4935 |
0 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 4936 |
|
| |
| 4937 |
0 |
| const char* anon_basic_type_name = NULL; |
| 4938 |
0 |
| int32_t status = boot_env->api->compiler->compile_script(compiler, source, &anon_basic_type_name); |
| 4939 |
|
| |
| 4940 |
0 |
▶ | if (!(status == 0)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!(status == 0)) { |
0 |
0 |
0 |
|
| 4941 |
0 |
| croak("Failed to compile a source code for an anon class."); |
| 4942 |
|
| } |
| 4943 |
|
| |
| 4944 |
0 |
| SV* sv_anon_basic_type_name = sv_2mortal(newSVpv(anon_basic_type_name, 0)); |
| 4945 |
|
| |
| 4946 |
0 |
▶ | XPUSHs(sv_anon_basic_type_name); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_anon_basic_type_name); |
0 |
0 |
0 |
|
| 4947 |
|
| |
| 4948 |
0 |
| XSRETURN(1); |
| 4949 |
|
| } |
| 4950 |
|
| |
| 4951 |
|
| SV* |
| 4952 |
|
| get_error_messages(...) |
| 4953 |
|
| PPCODE: |
| 4954 |
|
| { |
| 4955 |
|
| |
| 4956 |
402 |
| SV* sv_self = ST(0); |
| 4957 |
|
| |
| 4958 |
402 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 4959 |
|
| |
| 4960 |
402 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 4961 |
|
| |
| 4962 |
402 |
| void* compiler = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 4963 |
|
| |
| 4964 |
402 |
| AV* av_error_messages = (AV*)sv_2mortal((SV*)newAV()); |
| 4965 |
402 |
| SV* sv_error_messages = sv_2mortal(newRV_inc((SV*)av_error_messages)); |
| 4966 |
|
| |
| 4967 |
402 |
| int32_t error_messages_length = boot_env->api->compiler->get_error_messages_length(compiler); |
| 4968 |
|
| |
| 4969 |
875 |
▶ | for (int32_t i = 0; i < error_messages_length; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int32_t i = 0; i < error_messages_length; i++) { |
473 |
402 |
875 |
|
| 4970 |
473 |
| const char* error_message = boot_env->api->compiler->get_error_message(compiler, i); |
| 4971 |
473 |
| SV* sv_error_message = sv_2mortal(newSVpv(error_message, 0)); |
| 4972 |
473 |
| av_push(av_error_messages, SvREFCNT_inc(sv_error_message)); |
| 4973 |
|
| } |
| 4974 |
|
| |
| 4975 |
402 |
▶ | XPUSHs(sv_error_messages); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_error_messages); |
0 |
402 |
402 |
|
| 4976 |
402 |
| XSRETURN(1); |
| 4977 |
|
| } |
| 4978 |
|
| |
| 4979 |
|
| SV* |
| 4980 |
|
| get_class_file(...) |
| 4981 |
|
| PPCODE: |
| 4982 |
|
| { |
| 4983 |
|
| |
| 4984 |
63 |
| SV* sv_self = ST(0); |
| 4985 |
63 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 4986 |
63 |
| void* compiler = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 4987 |
|
| |
| 4988 |
63 |
| SV* sv_class_name = ST(1); |
| 4989 |
63 |
| const char* class_name = SvPV_nolen(sv_class_name); |
| 4990 |
|
| |
| 4991 |
63 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 4992 |
|
| |
| 4993 |
63 |
| void* class_file = boot_env->api->compiler->get_class_file(compiler, class_name); |
| 4994 |
|
| |
| 4995 |
63 |
| SV* sv_class_file = &PL_sv_undef; |
| 4996 |
|
| |
| 4997 |
63 |
▶ | if (class_file) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (class_file) { |
63 |
0 |
63 |
|
| 4998 |
63 |
| sv_class_file = SPVM_XS_UTIL_new_sv_pointer_object(aTHX_ class_file, "SPVM::Builder::Native::ClassFile"); |
| 4999 |
63 |
| HV* hv_class_file = (HV*)SvRV(sv_class_file); |
| 5000 |
|
| |
| 5001 |
63 |
| (void)hv_store(hv_class_file, "compiler", strlen("compiler"), SvREFCNT_inc(sv_self), 0); |
| 5002 |
|
| } |
| 5003 |
|
| |
| 5004 |
63 |
▶ | XPUSHs(sv_class_file); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_class_file); |
0 |
63 |
63 |
|
| 5005 |
63 |
| XSRETURN(1); |
| 5006 |
|
| } |
| 5007 |
|
| |
| 5008 |
|
| SV* |
| 5009 |
|
| set_start_file(...) |
| 5010 |
|
| PPCODE: |
| 5011 |
|
| { |
| 5012 |
|
| |
| 5013 |
1416 |
| SV* sv_self = ST(0); |
| 5014 |
|
| |
| 5015 |
1416 |
| SV* sv_start_file = ST(1); |
| 5016 |
|
| |
| 5017 |
1416 |
| const char* start_file = SvPV_nolen(sv_start_file); |
| 5018 |
|
| |
| 5019 |
1416 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 5020 |
|
| |
| 5021 |
1416 |
| void* compiler = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 5022 |
|
| |
| 5023 |
1416 |
| boot_env->api->compiler->set_start_file(compiler, start_file); |
| 5024 |
|
| |
| 5025 |
1416 |
| XSRETURN(0); |
| 5026 |
|
| } |
| 5027 |
|
| |
| 5028 |
|
| SV* |
| 5029 |
|
| set_start_line(...) |
| 5030 |
|
| PPCODE: |
| 5031 |
|
| { |
| 5032 |
|
| |
| 5033 |
1416 |
| SV* sv_self = ST(0); |
| 5034 |
|
| |
| 5035 |
1416 |
| SV* sv_start_line = ST(1); |
| 5036 |
|
| |
| 5037 |
1416 |
| int32_t start_line = SvIV(sv_start_line); |
| 5038 |
|
| |
| 5039 |
1416 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 5040 |
|
| |
| 5041 |
1416 |
| void* compiler = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 5042 |
|
| |
| 5043 |
1416 |
| boot_env->api->compiler->set_start_line(compiler, start_line); |
| 5044 |
|
| |
| 5045 |
1416 |
| XSRETURN(0); |
| 5046 |
|
| } |
| 5047 |
|
| |
| 5048 |
|
| SV* |
| 5049 |
|
| add_class_search_dir(...) |
| 5050 |
|
| PPCODE: |
| 5051 |
|
| { |
| 5052 |
|
| |
| 5053 |
55831 |
| SV* sv_self = ST(0); |
| 5054 |
|
| |
| 5055 |
55831 |
| SV* sv_class_search_dir = ST(1); |
| 5056 |
|
| |
| 5057 |
55831 |
| const char* class_search_dir = SvPV_nolen(sv_class_search_dir); |
| 5058 |
|
| |
| 5059 |
55831 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 5060 |
|
| |
| 5061 |
55831 |
| void* compiler = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 5062 |
|
| |
| 5063 |
55831 |
| boot_env->api->compiler->add_class_search_dir(compiler, class_search_dir); |
| 5064 |
|
| |
| 5065 |
55831 |
| XSRETURN(0); |
| 5066 |
|
| } |
| 5067 |
|
| |
| 5068 |
|
| SV* |
| 5069 |
|
| get_class_search_dir(...) |
| 5070 |
|
| PPCODE: |
| 5071 |
|
| { |
| 5072 |
|
| |
| 5073 |
0 |
| SV* sv_self = ST(0); |
| 5074 |
|
| |
| 5075 |
0 |
| SV* sv_index = ST(1); |
| 5076 |
|
| |
| 5077 |
0 |
| int32_t index = SvIV(sv_index); |
| 5078 |
|
| |
| 5079 |
0 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 5080 |
|
| |
| 5081 |
0 |
| void* compiler = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 5082 |
|
| |
| 5083 |
0 |
| const char* class_search_dir = boot_env->api->compiler->get_class_search_dir(compiler, index); |
| 5084 |
|
| |
| 5085 |
0 |
| SV* sv_class_search_dir = sv_2mortal(newSVpv(class_search_dir, 0)); |
| 5086 |
|
| |
| 5087 |
0 |
▶ | XPUSHs(sv_class_search_dir); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_class_search_dir); |
0 |
0 |
0 |
|
| 5088 |
|
| |
| 5089 |
0 |
| XSRETURN(1); |
| 5090 |
|
| } |
| 5091 |
|
| |
| 5092 |
|
| SV* |
| 5093 |
|
| get_class_search_dirs_length(...) |
| 5094 |
|
| PPCODE: |
| 5095 |
|
| { |
| 5096 |
|
| |
| 5097 |
0 |
| SV* sv_self = ST(0); |
| 5098 |
|
| |
| 5099 |
0 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 5100 |
|
| |
| 5101 |
0 |
| void* compiler = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 5102 |
|
| |
| 5103 |
0 |
| int32_t class_search_dirs_length = boot_env->api->compiler->get_class_search_dirs_length(compiler); |
| 5104 |
|
| |
| 5105 |
0 |
| SV* sv_class_search_dirs_length = sv_2mortal(newSViv(class_search_dirs_length)); |
| 5106 |
|
| |
| 5107 |
0 |
▶ | XPUSHs(sv_class_search_dirs_length); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_class_search_dirs_length); |
0 |
0 |
0 |
|
| 5108 |
|
| |
| 5109 |
0 |
| XSRETURN(1); |
| 5110 |
|
| } |
| 5111 |
|
| |
| 5112 |
|
| SV* |
| 5113 |
|
| create_c_string_literal(...) |
| 5114 |
|
| PPCODE: |
| 5115 |
|
| { |
| 5116 |
|
| // write brief comment in English |
| 5117 |
|
| // The first argument is the instance (self), the second is the content |
| 5118 |
63 |
| SV* sv_self = ST(0); |
| 5119 |
63 |
| SV* sv_content = ST(1); |
| 5120 |
|
| |
| 5121 |
63 |
▶ | if (!SvOK(sv_content)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!SvOK(sv_content)) { |
0 |
63 |
63 |
|
| 5122 |
0 |
| XSRETURN_UNDEF; |
| 5123 |
|
| } |
| 5124 |
|
| |
| 5125 |
|
| STRLEN len; |
| 5126 |
63 |
| unsigned char* content = (unsigned char*)SvPV(sv_content, len); |
| 5127 |
|
| |
| 5128 |
|
| // write brief comment in English |
| 5129 |
|
| // Hex table for fast conversion without sprintf |
| 5130 |
|
| static const char* hex_table[256] = { |
| 5131 |
|
| "0x00,", "0x01,", "0x02,", "0x03,", "0x04,", "0x05,", "0x06,", "0x07,", "0x08,", "0x09,", "0x0a,", "0x0b,", "0x0c,", "0x0d,", "0x0e,", "0x0f,", |
| 5132 |
|
| "0x10,", "0x11,", "0x12,", "0x13,", "0x14,", "0x15,", "0x16,", "0x17,", "0x18,", "0x19,", "0x1a,", "0x1b,", "0x1c,", "0x1d,", "0x1e,", "0x1f,", |
| 5133 |
|
| "0x20,", "0x21,", "0x22,", "0x23,", "0x24,", "0x25,", "0x26,", "0x27,", "0x28,", "0x29,", "0x2a,", "0x2b,", "0x2c,", "0x2d,", "0x2e,", "0x2f,", |
| 5134 |
|
| "0x30,", "0x31,", "0x32,", "0x33,", "0x34,", "0x35,", "0x36,", "0x37,", "0x38,", "0x39,", "0x3a,", "0x3b,", "0x3c,", "0x3d,", "0x3e,", "0x3f,", |
| 5135 |
|
| "0x40,", "0x41,", "0x42,", "0x43,", "0x44,", "0x45,", "0x46,", "0x47,", "0x48,", "0x49,", "0x4a,", "0x4b,", "0x4c,", "0x4d,", "0x4e,", "0x4f,", |
| 5136 |
|
| "0x50,", "0x51,", "0x52,", "0x53,", "0x54,", "0x55,", "0x56,", "0x57,", "0x58,", "0x59,", "0x5a,", "0x5b,", "0x5c,", "0x5d,", "0x5e,", "0x5f,", |
| 5137 |
|
| "0x60,", "0x61,", "0x62,", "0x63,", "0x64,", "0x65,", "0x66,", "0x67,", "0x68,", "0x69,", "0x6a,", "0x6b,", "0x6c,", "0x6d,", "0x6e,", "0x6f,", |
| 5138 |
|
| "0x70,", "0x71,", "0x72,", "0x73,", "0x74,", "0x75,", "0x76,", "0x77,", "0x78,", "0x79,", "0x7a,", "0x7b,", "0x7c,", "0x7d,", "0x7e,", "0x7f,", |
| 5139 |
|
| "0x80,", "0x81,", "0x82,", "0x83,", "0x84,", "0x85,", "0x86,", "0x87,", "0x88,", "0x89,", "0x8a,", "0x8b,", "0x8c,", "0x8d,", "0x8e,", "0x8f,", |
| 5140 |
|
| "0x90,", "0x91,", "0x92,", "0x93,", "0x94,", "0x95,", "0x96,", "0x97,", "0x98,", "0x99,", "0x9a,", "0x9b,", "0x9c,", "0x9d,", "0x9e,", "0x9f,", |
| 5141 |
|
| "0xa0,", "0xa1,", "0xa2,", "0xa3,", "0xa4,", "0xa5,", "0xa6,", "0xa7,", "0xa8,", "0xa9,", "0xaa,", "0xab,", "0xac,", "0xad,", "0xae,", "0xaf,", |
| 5142 |
|
| "0xb0,", "0xb1,", "0xb2,", "0xb3,", "0xb4,", "0xb5,", "0xb6,", "0xb7,", "0xb8,", "0xb9,", "0xba,", "0xbb,", "0xbc,", "0xbd,", "0xbe,", "0xbf,", |
| 5143 |
|
| "0xc0,", "0xc1,", "0xc2,", "0xc3,", "0xc4,", "0xc5,", "0xc6,", "0xc7,", "0xc8,", "0xc9,", "0xca,", "0xcb,", "0xcc,", "0xcd,", "0xce,", "0xcf,", |
| 5144 |
|
| "0xd0,", "0xd1,", "0xd2,", "0xd3,", "0xd4,", "0xd5,", "0xd6,", "0xd7,", "0xd8,", "0xd9,", "0xda,", "0xdb,", "0xdc,", "0xdd,", "0xde,", "0xdf,", |
| 5145 |
|
| "0xe0,", "0xe1,", "0xe2,", "0xe3,", "0xe4,", "0xe5,", "0xe6,", "0xe7,", "0xe8,", "0xe9,", "0xea,", "0xeb,", "0xec,", "0xed,", "0xee,", "0xef,", |
| 5146 |
|
| "0xf0,", "0xf1,", "0xf2,", "0xf3,", "0xf4,", "0xf5,", "0xf6,", "0xf7,", "0xf8,", "0xf9,", "0xfa,", "0xfb,", "0xfc,", "0xfd,", "0xfe,", "0xff," |
| 5147 |
|
| }; |
| 5148 |
|
| |
| 5149 |
63 |
| const char* prefix = "(const char[]){"; |
| 5150 |
63 |
| const char* suffix = "0}"; |
| 5151 |
63 |
| STRLEN prefix_len = strlen(prefix); |
| 5152 |
63 |
| STRLEN suffix_len = strlen(suffix); |
| 5153 |
|
| |
| 5154 |
|
| // write brief comment in English |
| 5155 |
|
| // Total size = prefix + (len * 5 bytes for "0xXX,") + suffix |
| 5156 |
63 |
| STRLEN res_len = prefix_len + (len * 5) + suffix_len; |
| 5157 |
63 |
| SV* sv_res = newSV(res_len); |
| 5158 |
63 |
| SvPOK_on(sv_res); |
| 5159 |
63 |
| char* p = SvPVX(sv_res); |
| 5160 |
|
| |
| 5161 |
|
| // write brief comment in English |
| 5162 |
|
| // Copy prefix |
| 5163 |
63 |
| memcpy(p, prefix, prefix_len); |
| 5164 |
63 |
| p += prefix_len; |
| 5165 |
|
| |
| 5166 |
|
| // write brief comment in English |
| 5167 |
|
| // Copy pre-formatted hex strings |
| 5168 |
19647 |
▶ | for (STRLEN i = 0; i < len; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (STRLEN i = 0; i < len; i++) { |
19584 |
63 |
19647 |
|
| 5169 |
19584 |
| memcpy(p, hex_table[content[i]], 5); |
| 5170 |
19584 |
| p += 5; |
| 5171 |
|
| } |
| 5172 |
|
| |
| 5173 |
|
| // write brief comment in English |
| 5174 |
|
| // Copy suffix and null-terminate for safety |
| 5175 |
63 |
| memcpy(p, suffix, suffix_len); |
| 5176 |
63 |
| p += suffix_len; |
| 5177 |
63 |
| *p = '\0'; |
| 5178 |
|
| |
| 5179 |
63 |
| SvCUR_set(sv_res, p - SvPVX(sv_res)); |
| 5180 |
|
| |
| 5181 |
63 |
| ST(0) = sv_2mortal(sv_res); |
| 5182 |
63 |
| XSRETURN(1); |
| 5183 |
|
| } |
| 5184 |
|
| |
| 5185 |
|
| MODULE = SPVM::Builder::Native::Runtime PACKAGE = SPVM::Builder::Native::Runtime |
| 5186 |
|
| |
| 5187 |
|
| SV* |
| 5188 |
|
| get_compiler(...) |
| 5189 |
|
| PPCODE: |
| 5190 |
|
| { |
| 5191 |
|
| |
| 5192 |
0 |
| SV* sv_self = ST(0); |
| 5193 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 5194 |
0 |
| void* runtime = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 5195 |
|
| |
| 5196 |
0 |
| SV** sv_api_env_ptr = hv_fetch(hv_self, "api_env", strlen("api_env"), 0); |
| 5197 |
0 |
▶ | SV* sv_api_env = sv_api_env_ptr ? *sv_api_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_api_env = sv_api_env_ptr ? *sv_api_env_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 5198 |
0 |
| SPVM_ENV* api_env = INT2PTR(SPVM_ENV*, SvIV(SvRV(sv_api_env))); |
| 5199 |
|
| |
| 5200 |
0 |
| void* compiler = api_env->api->runtime->get_compiler(runtime); |
| 5201 |
|
| |
| 5202 |
0 |
| SV* sv_compiler = SPVM_XS_UTIL_new_sv_pointer_object(aTHX_ compiler, "SPVM::Builder::Native::Compiler"); |
| 5203 |
|
| |
| 5204 |
0 |
▶ | XPUSHs(sv_compiler); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_compiler); |
0 |
0 |
0 |
|
| 5205 |
|
| |
| 5206 |
0 |
| XSRETURN(1); |
| 5207 |
|
| } |
| 5208 |
|
| |
| 5209 |
|
| SV* |
| 5210 |
|
| get_basic_types_length(...) |
| 5211 |
|
| PPCODE: |
| 5212 |
|
| { |
| 5213 |
|
| |
| 5214 |
1327 |
| SV* sv_self = ST(0); |
| 5215 |
1327 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 5216 |
1327 |
| void* runtime = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 5217 |
|
| |
| 5218 |
1327 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 5219 |
|
| |
| 5220 |
1327 |
| int32_t basic_types_length = boot_env->api->runtime->get_basic_types_length(runtime); |
| 5221 |
|
| |
| 5222 |
1327 |
| SV* sv_basic_types_length = sv_2mortal(newSViv(basic_types_length)); |
| 5223 |
|
| |
| 5224 |
1327 |
▶ | XPUSHs(sv_basic_types_length); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_basic_types_length); |
0 |
1327 |
1327 |
|
| 5225 |
1327 |
| XSRETURN(1); |
| 5226 |
|
| } |
| 5227 |
|
| |
| 5228 |
|
| SV* |
| 5229 |
|
| get_basic_type_by_id(...) |
| 5230 |
|
| PPCODE: |
| 5231 |
|
| { |
| 5232 |
|
| |
| 5233 |
33513 |
| SV* sv_self = ST(0); |
| 5234 |
33513 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 5235 |
33513 |
| void* runtime = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 5236 |
|
| |
| 5237 |
33513 |
| SV* sv_basic_type_id = ST(1); |
| 5238 |
33513 |
| int32_t basic_type_id = SvIV(sv_basic_type_id); |
| 5239 |
|
| |
| 5240 |
33513 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 5241 |
|
| |
| 5242 |
33513 |
| void* basic_type = boot_env->api->runtime->get_basic_type_by_id(runtime, basic_type_id); |
| 5243 |
|
| |
| 5244 |
33513 |
| SV* sv_basic_type = &PL_sv_undef; |
| 5245 |
|
| |
| 5246 |
33513 |
▶ | if (basic_type) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (basic_type) { |
33513 |
0 |
33513 |
|
| 5247 |
33513 |
| sv_basic_type = SPVM_XS_UTIL_new_sv_pointer_object(aTHX_ basic_type, "SPVM::Builder::Native::BasicType"); |
| 5248 |
33513 |
| HV* hv_basic_type = (HV*)SvRV(sv_basic_type); |
| 5249 |
|
| |
| 5250 |
33513 |
| (void)hv_store(hv_basic_type, "runtime", strlen("runtime"), SvREFCNT_inc(sv_self), 0); |
| 5251 |
|
| } |
| 5252 |
|
| |
| 5253 |
33513 |
▶ | XPUSHs(sv_basic_type); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_basic_type); |
0 |
33513 |
33513 |
|
| 5254 |
33513 |
| XSRETURN(1); |
| 5255 |
|
| } |
| 5256 |
|
| |
| 5257 |
|
| SV* |
| 5258 |
|
| get_basic_type_by_name(...) |
| 5259 |
|
| PPCODE: |
| 5260 |
|
| { |
| 5261 |
|
| |
| 5262 |
61784 |
| SV* sv_self = ST(0); |
| 5263 |
61784 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 5264 |
61784 |
| void* runtime = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 5265 |
|
| |
| 5266 |
61784 |
| SV* sv_basic_type_name = ST(1); |
| 5267 |
61784 |
| const char* basic_type_name = SvPV_nolen(sv_basic_type_name); |
| 5268 |
|
| |
| 5269 |
61784 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 5270 |
|
| |
| 5271 |
61784 |
| void* basic_type = boot_env->api->runtime->get_basic_type_by_name(runtime, basic_type_name); |
| 5272 |
|
| |
| 5273 |
61784 |
| SV* sv_basic_type = &PL_sv_undef; |
| 5274 |
|
| |
| 5275 |
61784 |
▶ | if (basic_type) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (basic_type) { |
61784 |
0 |
61784 |
|
| 5276 |
61784 |
| sv_basic_type = SPVM_XS_UTIL_new_sv_pointer_object(aTHX_ basic_type, "SPVM::Builder::Native::BasicType"); |
| 5277 |
61784 |
| HV* hv_basic_type = (HV*)SvRV(sv_basic_type); |
| 5278 |
|
| |
| 5279 |
61784 |
| (void)hv_store(hv_basic_type, "runtime", strlen("runtime"), SvREFCNT_inc(sv_self), 0); |
| 5280 |
|
| } |
| 5281 |
|
| |
| 5282 |
61784 |
▶ | XPUSHs(sv_basic_type); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_basic_type); |
0 |
61784 |
61784 |
|
| 5283 |
61784 |
| XSRETURN(1); |
| 5284 |
|
| } |
| 5285 |
|
| |
| 5286 |
|
| SV* |
| 5287 |
|
| get_env(...) |
| 5288 |
|
| PPCODE: |
| 5289 |
|
| { |
| 5290 |
311 |
| SV* sv_self = ST(0); |
| 5291 |
311 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 5292 |
|
| |
| 5293 |
311 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 5294 |
311 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
311 |
0 |
311 |
|
| 5295 |
|
| |
| 5296 |
311 |
▶ | XPUSHs(sv_env); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_env); |
0 |
311 |
311 |
|
| 5297 |
311 |
| XSRETURN(1); |
| 5298 |
|
| } |
| 5299 |
|
| |
| 5300 |
|
| SV* |
| 5301 |
|
| get_basic_type_names(...) |
| 5302 |
|
| PPCODE: |
| 5303 |
|
| { |
| 5304 |
|
| |
| 5305 |
0 |
| SV* sv_self = ST(0); |
| 5306 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 5307 |
|
| |
| 5308 |
0 |
| void* runtime = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 5309 |
|
| |
| 5310 |
0 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 5311 |
|
| |
| 5312 |
0 |
| AV* av_basic_type_names = (AV*)sv_2mortal((SV*)newAV()); |
| 5313 |
0 |
| SV* sv_basic_type_names = sv_2mortal(newRV_inc((SV*)av_basic_type_names)); |
| 5314 |
|
| |
| 5315 |
0 |
| int32_t basic_types_length = boot_env->api->runtime->get_basic_types_length(runtime); |
| 5316 |
0 |
▶ | for (int32_t basic_type_id = 0; basic_type_id < basic_types_length; basic_type_id++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int32_t basic_type_id = 0; basic_type_id < basic_types_length; basic_type_id++) { |
0 |
0 |
0 |
|
| 5317 |
0 |
| void* basic_type = boot_env->api->runtime->get_basic_type_by_id(runtime, basic_type_id); |
| 5318 |
0 |
| int32_t basic_type_category = boot_env->api->basic_type->get_category(runtime, basic_type); |
| 5319 |
0 |
| const char* basic_type_name = boot_env->api->basic_type->get_name(runtime, basic_type); |
| 5320 |
0 |
| SV* sv_basic_type_name = sv_2mortal(newSVpv(basic_type_name, 0)); |
| 5321 |
0 |
| av_push(av_basic_type_names, SvREFCNT_inc(sv_basic_type_name)); |
| 5322 |
|
| } |
| 5323 |
|
| |
| 5324 |
0 |
▶ | XPUSHs(sv_basic_type_names); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_basic_type_names); |
0 |
0 |
0 |
|
| 5325 |
0 |
| XSRETURN(1); |
| 5326 |
|
| } |
| 5327 |
|
| |
| 5328 |
|
| SV* |
| 5329 |
|
| get_spvm_version_string(...) |
| 5330 |
|
| PPCODE: |
| 5331 |
|
| { |
| 5332 |
0 |
| SV* sv_self = ST(0); |
| 5333 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 5334 |
|
| |
| 5335 |
0 |
| SV** sv_runtime_ptr = hv_fetch(hv_self, "runtime", strlen("runtime"), 0); |
| 5336 |
0 |
▶ | SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 5337 |
0 |
| HV* hv_runtime = (HV*)SvRV(sv_runtime); |
| 5338 |
0 |
| void* runtime = SPVM_XS_UTIL_get_pointer(aTHX_ sv_runtime); |
| 5339 |
|
| |
| 5340 |
0 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 5341 |
|
| |
| 5342 |
0 |
| const char* spvm_version_string = boot_env->get_spvm_version_string(boot_env, NULL); |
| 5343 |
|
| |
| 5344 |
0 |
| SV* sv_spvm_version_string = sv_2mortal(newSVpv(spvm_version_string, 0)); |
| 5345 |
|
| |
| 5346 |
0 |
▶ | XPUSHs(sv_spvm_version_string); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_spvm_version_string); |
0 |
0 |
0 |
|
| 5347 |
0 |
| XSRETURN(1); |
| 5348 |
|
| } |
| 5349 |
|
| |
| 5350 |
|
| MODULE = SPVM::Builder::Native::Env PACKAGE = SPVM::Builder::Native::Env |
| 5351 |
|
| |
| 5352 |
|
| SV* |
| 5353 |
|
| new(...) |
| 5354 |
|
| PPCODE: |
| 5355 |
|
| { |
| 5356 |
1077 |
| SV* sv_class = ST(0); |
| 5357 |
|
| |
| 5358 |
1077 |
| SPVM_ENV* new_env = SPVM_NATIVE_new_env(); |
| 5359 |
|
| |
| 5360 |
1077 |
| SV* sv_self = SPVM_XS_UTIL_new_sv_pointer_object(aTHX_ new_env, "SPVM::Builder::Native::Env"); |
| 5361 |
1077 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 5362 |
|
| |
| 5363 |
1077 |
▶ | XPUSHs(sv_self); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_self); |
0 |
1077 |
1077 |
|
| 5364 |
1077 |
| XSRETURN(1); |
| 5365 |
|
| } |
| 5366 |
|
| |
| 5367 |
|
| SV* |
| 5368 |
|
| DESTROY(...) |
| 5369 |
|
| PPCODE: |
| 5370 |
|
| { |
| 5371 |
|
| |
| 5372 |
2154 |
| SV* sv_self = ST(0); |
| 5373 |
2154 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 5374 |
|
| |
| 5375 |
2154 |
| SV** sv_no_destroy_ptr = hv_fetch(hv_self, "no_destroy", strlen("no_destroy"), 0); |
| 5376 |
2154 |
▶ | SV* sv_no_destroy = sv_no_destroy_ptr ? *sv_no_destroy_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_no_destroy = sv_no_destroy_ptr ? *sv_no_destroy_ptr : &PL_sv_undef; |
1077 |
1077 |
2154 |
|
| 5377 |
|
| |
| 5378 |
2154 |
▶ | if (!(SvOK(sv_no_destroy) && SvIV(sv_no_destroy))) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(SvOK(sv_no_destroy) && SvIV(sv_no_destroy))) { |
1077 |
1077 |
2154 |
| if (!(SvOK(sv_no_destroy) && SvIV(sv_no_destroy))) { |
0 |
1077 |
1077 |
|
| 5379 |
1077 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 5380 |
|
| |
| 5381 |
1077 |
| env->free_env(env); |
| 5382 |
|
| } |
| 5383 |
|
| |
| 5384 |
2154 |
| XSRETURN(0); |
| 5385 |
|
| } |
| 5386 |
|
| |
| 5387 |
|
| SV* |
| 5388 |
|
| set_command_info_program_name(...) |
| 5389 |
|
| PPCODE: |
| 5390 |
|
| { |
| 5391 |
|
| |
| 5392 |
311 |
| SV* sv_env = ST(0); |
| 5393 |
311 |
| SV* sv_stack = ST(1); |
| 5394 |
|
| |
| 5395 |
311 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_pointer(aTHX_ sv_env); |
| 5396 |
311 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_pointer(aTHX_ sv_stack); |
| 5397 |
|
| |
| 5398 |
311 |
| SV* sv_program_name = ST(2); |
| 5399 |
311 |
| const char* program_name = SvPV_nolen(sv_program_name); |
| 5400 |
311 |
| int32_t program_name_length = strlen(program_name); |
| 5401 |
|
| |
| 5402 |
|
| { |
| 5403 |
311 |
| int32_t scope_id = env->enter_scope(env, stack); |
| 5404 |
|
| |
| 5405 |
|
| // Program name - string |
| 5406 |
311 |
| void* spvm_program_name = env->new_string(env, stack, program_name, program_name_length); |
| 5407 |
|
| |
| 5408 |
|
| // Set command info |
| 5409 |
|
| { |
| 5410 |
|
| int32_t error_id; |
| 5411 |
311 |
| error_id = env->set_command_info_program_name(env, stack, spvm_program_name); |
| 5412 |
|
| assert(error_id == 0); |
| 5413 |
|
| } |
| 5414 |
|
| |
| 5415 |
311 |
| env->leave_scope(env, stack, scope_id); |
| 5416 |
|
| } |
| 5417 |
|
| |
| 5418 |
311 |
| XSRETURN(0); |
| 5419 |
|
| } |
| 5420 |
|
| |
| 5421 |
|
| SV* |
| 5422 |
|
| set_command_info_argv(...) |
| 5423 |
|
| PPCODE: |
| 5424 |
|
| { |
| 5425 |
|
| |
| 5426 |
311 |
| SV* sv_env = ST(0); |
| 5427 |
311 |
| SV* sv_stack = ST(1); |
| 5428 |
|
| |
| 5429 |
311 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_pointer(aTHX_ sv_env); |
| 5430 |
311 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_pointer(aTHX_ sv_stack); |
| 5431 |
|
| |
| 5432 |
311 |
| SV* sv_argv = ST(2); |
| 5433 |
311 |
| AV* av_argv = (AV*)SvRV(sv_argv); |
| 5434 |
311 |
| int32_t argv_length = av_len(av_argv) + 1; |
| 5435 |
|
| |
| 5436 |
|
| { |
| 5437 |
311 |
| int32_t scope_id = env->enter_scope(env, stack); |
| 5438 |
|
| |
| 5439 |
311 |
| void* spvm_argv = env->new_string_array(env, stack, argv_length); |
| 5440 |
314 |
▶ | for (int32_t index = 0; index < argv_length; index++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int32_t index = 0; index < argv_length; index++) { |
3 |
311 |
314 |
|
| 5441 |
3 |
| SV** sv_arg_ptr = av_fetch(av_argv, index, 0); |
| 5442 |
3 |
▶ | SV* sv_arg = sv_arg_ptr ? *sv_arg_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_arg = sv_arg_ptr ? *sv_arg_ptr : &PL_sv_undef; |
3 |
0 |
3 |
|
| 5443 |
|
| |
| 5444 |
3 |
| const char* arg = SvPV_nolen(sv_arg); |
| 5445 |
3 |
| int32_t arg_length = strlen(arg); |
| 5446 |
|
| |
| 5447 |
3 |
| void* spvm_arg = env->new_string(env, stack, arg, arg_length); |
| 5448 |
3 |
| env->set_elem_string(env, stack, spvm_argv, index, spvm_arg); |
| 5449 |
|
| } |
| 5450 |
|
| |
| 5451 |
|
| // Set command info |
| 5452 |
|
| { |
| 5453 |
|
| int32_t error_id; |
| 5454 |
311 |
| error_id = env->set_command_info_argv(env, stack, spvm_argv); |
| 5455 |
|
| assert(error_id == 0); |
| 5456 |
|
| } |
| 5457 |
|
| |
| 5458 |
311 |
| env->leave_scope(env, stack, scope_id); |
| 5459 |
|
| } |
| 5460 |
|
| |
| 5461 |
311 |
| XSRETURN(0); |
| 5462 |
|
| } |
| 5463 |
|
| |
| 5464 |
|
| SV* |
| 5465 |
|
| set_command_info_basetime(...) |
| 5466 |
|
| PPCODE: |
| 5467 |
|
| { |
| 5468 |
|
| |
| 5469 |
622 |
| SV* sv_env = ST(0); |
| 5470 |
622 |
| SV* sv_stack = ST(1); |
| 5471 |
|
| |
| 5472 |
622 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_pointer(aTHX_ sv_env); |
| 5473 |
622 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_pointer(aTHX_ sv_stack); |
| 5474 |
|
| |
| 5475 |
622 |
| SV* sv_base_time = ST(2); |
| 5476 |
622 |
| int64_t base_time = SvIV(sv_base_time); |
| 5477 |
|
| |
| 5478 |
|
| { |
| 5479 |
622 |
| int32_t scope_id = env->enter_scope(env, stack); |
| 5480 |
|
| |
| 5481 |
|
| // Set command info |
| 5482 |
|
| { |
| 5483 |
|
| int32_t error_id; |
| 5484 |
622 |
| error_id = env->set_command_info_basetime(env, stack, base_time); |
| 5485 |
|
| assert(error_id == 0); |
| 5486 |
|
| } |
| 5487 |
|
| |
| 5488 |
622 |
| env->leave_scope(env, stack, scope_id); |
| 5489 |
|
| } |
| 5490 |
|
| |
| 5491 |
622 |
| XSRETURN(0); |
| 5492 |
|
| } |
| 5493 |
|
| |
| 5494 |
|
| SV* |
| 5495 |
|
| set_command_info_warning(...) |
| 5496 |
|
| PPCODE: |
| 5497 |
|
| { |
| 5498 |
|
| |
| 5499 |
311 |
| SV* sv_env = ST(0); |
| 5500 |
311 |
| SV* sv_stack = ST(1); |
| 5501 |
|
| |
| 5502 |
311 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_pointer(aTHX_ sv_env); |
| 5503 |
311 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_pointer(aTHX_ sv_stack); |
| 5504 |
|
| |
| 5505 |
311 |
| SV* sv_warning = ST(2); |
| 5506 |
311 |
| int32_t warning = SvIV(sv_warning); |
| 5507 |
|
| |
| 5508 |
|
| { |
| 5509 |
311 |
| int32_t scope_id = env->enter_scope(env, stack); |
| 5510 |
|
| |
| 5511 |
|
| // Set command info |
| 5512 |
|
| { |
| 5513 |
|
| int32_t error_id; |
| 5514 |
311 |
| error_id = env->set_command_info_warning(env, stack, warning); |
| 5515 |
|
| assert(error_id == 0); |
| 5516 |
|
| } |
| 5517 |
|
| |
| 5518 |
311 |
| env->leave_scope(env, stack, scope_id); |
| 5519 |
|
| } |
| 5520 |
|
| |
| 5521 |
311 |
| XSRETURN(0); |
| 5522 |
|
| } |
| 5523 |
|
| |
| 5524 |
|
| SV* |
| 5525 |
|
| call_init_methods(...) |
| 5526 |
|
| PPCODE: |
| 5527 |
|
| { |
| 5528 |
|
| |
| 5529 |
325 |
| SV* sv_env = ST(0); |
| 5530 |
325 |
| SV* sv_stack = ST(1); |
| 5531 |
|
| |
| 5532 |
325 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_pointer(aTHX_ sv_env); |
| 5533 |
325 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_pointer(aTHX_ sv_stack); |
| 5534 |
|
| |
| 5535 |
325 |
| int32_t error_id = env->call_init_methods(env, stack); |
| 5536 |
|
| |
| 5537 |
325 |
▶ | if (error_id) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (error_id) { |
0 |
325 |
325 |
|
| 5538 |
0 |
| croak("[Initialization Exception]%s \n at %s line %d", env->get_chars(env, stack, env->get_exception(env, stack)), FILE_NAME, __LINE__); |
| 5539 |
|
| } |
| 5540 |
|
| |
| 5541 |
325 |
| XSRETURN(0); |
| 5542 |
|
| } |
| 5543 |
|
| |
| 5544 |
|
| SV* |
| 5545 |
|
| call_end_methods(...) |
| 5546 |
|
| PPCODE: |
| 5547 |
|
| { |
| 5548 |
311 |
| SV* sv_env = ST(0); |
| 5549 |
311 |
| SV* sv_stack = ST(1); |
| 5550 |
|
| |
| 5551 |
311 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_pointer(aTHX_ sv_env); |
| 5552 |
311 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_pointer(aTHX_ sv_stack); |
| 5553 |
|
| |
| 5554 |
|
| // Call the consolidated END methods for all classes |
| 5555 |
311 |
| env->call_end_methods(env, stack); |
| 5556 |
|
| |
| 5557 |
311 |
| XSRETURN(0); |
| 5558 |
|
| } |
| 5559 |
|
| |
| 5560 |
|
| SV* |
| 5561 |
|
| destroy_class_vars(...) |
| 5562 |
|
| PPCODE: |
| 5563 |
|
| { |
| 5564 |
|
| |
| 5565 |
311 |
| SV* sv_env = ST(0); |
| 5566 |
311 |
| SV* sv_stack = ST(1); |
| 5567 |
|
| |
| 5568 |
311 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_pointer(aTHX_ sv_env); |
| 5569 |
311 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_pointer(aTHX_ sv_stack); |
| 5570 |
|
| |
| 5571 |
311 |
| env->destroy_class_vars(env, stack); |
| 5572 |
|
| |
| 5573 |
311 |
| XSRETURN(0); |
| 5574 |
|
| } |
| 5575 |
|
| |
| 5576 |
|
| SV* |
| 5577 |
|
| new_stack(...) |
| 5578 |
|
| PPCODE: |
| 5579 |
|
| { |
| 5580 |
|
| |
| 5581 |
|
| // Env |
| 5582 |
311 |
| SV* sv_env = ST(0); |
| 5583 |
311 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_pointer(aTHX_ sv_env); |
| 5584 |
|
| |
| 5585 |
|
| // Create native_stack |
| 5586 |
311 |
| SPVM_VALUE* stack = env->new_stack(env); |
| 5587 |
311 |
| SV* sv_stack = SPVM_XS_UTIL_new_sv_pointer_object(aTHX_ stack, "SPVM::Builder::Native::Stack"); |
| 5588 |
311 |
| HV* hv_stack = (HV*)SvRV(sv_stack); |
| 5589 |
|
| |
| 5590 |
311 |
| (void)hv_store(hv_stack, "env", strlen("env"), SvREFCNT_inc(sv_env), 0); |
| 5591 |
|
| |
| 5592 |
311 |
▶ | XPUSHs(sv_stack); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_stack); |
0 |
311 |
311 |
|
| 5593 |
311 |
| XSRETURN(1); |
| 5594 |
|
| } |
| 5595 |
|
| |
| 5596 |
|
| MODULE = SPVM::Builder::Native::Stack PACKAGE = SPVM::Builder::Native::Stack |
| 5597 |
|
| |
| 5598 |
|
| SV* |
| 5599 |
|
| DESTROY(...) |
| 5600 |
|
| PPCODE: |
| 5601 |
|
| { |
| 5602 |
|
| |
| 5603 |
311 |
| SV* sv_self = ST(0); |
| 5604 |
311 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 5605 |
|
| |
| 5606 |
|
| // Stack |
| 5607 |
311 |
| SPVM_VALUE* stack = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 5608 |
|
| |
| 5609 |
|
| // Env |
| 5610 |
311 |
| SV** sv_env_ptr = hv_fetch(hv_self, "env", strlen("env"), 0); |
| 5611 |
311 |
▶ | SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_env = sv_env_ptr ? *sv_env_ptr : &PL_sv_undef; |
311 |
0 |
311 |
|
| 5612 |
311 |
| SPVM_ENV* env = SPVM_XS_UTIL_get_pointer(aTHX_ sv_env); |
| 5613 |
|
| |
| 5614 |
|
| // Free native_stack |
| 5615 |
311 |
| env->free_stack(env, stack); |
| 5616 |
|
| |
| 5617 |
311 |
| XSRETURN(0); |
| 5618 |
|
| } |
| 5619 |
|
| |
| 5620 |
|
| MODULE = SPVM::Builder::Native::BasicType PACKAGE = SPVM::Builder::Native::BasicType |
| 5621 |
|
| |
| 5622 |
|
| SV* |
| 5623 |
|
| get_parent(...) |
| 5624 |
|
| PPCODE: |
| 5625 |
|
| { |
| 5626 |
|
| |
| 5627 |
324 |
| SV* sv_self = ST(0); |
| 5628 |
324 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 5629 |
324 |
| void* basic_type = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 5630 |
|
| |
| 5631 |
324 |
| SV** sv_runtime_ptr = hv_fetch(hv_self, "runtime", strlen("runtime"), 0); |
| 5632 |
324 |
▶ | SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
324 |
0 |
324 |
|
| 5633 |
324 |
| HV* hv_runtime = (HV*)SvRV(sv_runtime); |
| 5634 |
324 |
| void* runtime = SPVM_XS_UTIL_get_pointer(aTHX_ sv_runtime); |
| 5635 |
|
| |
| 5636 |
324 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 5637 |
|
| |
| 5638 |
324 |
| void* parent_basic_type = boot_env->api->basic_type->get_parent(runtime, basic_type); |
| 5639 |
|
| |
| 5640 |
324 |
| SV* sv_parent_basic_type = &PL_sv_undef; |
| 5641 |
|
| |
| 5642 |
324 |
▶ | if (parent_basic_type) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (parent_basic_type) { |
3 |
321 |
324 |
|
| 5643 |
3 |
| sv_parent_basic_type = SPVM_XS_UTIL_new_sv_pointer_object(aTHX_ parent_basic_type, "SPVM::Builder::Native::BasicType"); |
| 5644 |
3 |
| HV* hv_parent_basic_type = (HV*)SvRV(sv_parent_basic_type); |
| 5645 |
|
| |
| 5646 |
3 |
| (void)hv_store(hv_parent_basic_type, "runtime", strlen("runtime"), SvREFCNT_inc(sv_runtime), 0); |
| 5647 |
|
| } |
| 5648 |
|
| |
| 5649 |
324 |
▶ | XPUSHs(sv_parent_basic_type); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_parent_basic_type); |
0 |
324 |
324 |
|
| 5650 |
324 |
| XSRETURN(1); |
| 5651 |
|
| } |
| 5652 |
|
| |
| 5653 |
|
| SV* |
| 5654 |
|
| get_class_dir(...) |
| 5655 |
|
| PPCODE: |
| 5656 |
|
| { |
| 5657 |
|
| |
| 5658 |
1613 |
| SV* sv_self = ST(0); |
| 5659 |
1613 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 5660 |
1613 |
| void* basic_type = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 5661 |
|
| |
| 5662 |
1613 |
| SV** sv_runtime_ptr = hv_fetch(hv_self, "runtime", strlen("runtime"), 0); |
| 5663 |
1613 |
▶ | SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
1613 |
0 |
1613 |
|
| 5664 |
1613 |
| HV* hv_runtime = (HV*)SvRV(sv_runtime); |
| 5665 |
1613 |
| void* runtime = SPVM_XS_UTIL_get_pointer(aTHX_ sv_runtime); |
| 5666 |
|
| |
| 5667 |
1613 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 5668 |
|
| |
| 5669 |
1613 |
| const char* class_dir = boot_env->api->basic_type->get_class_dir(runtime, basic_type); |
| 5670 |
|
| |
| 5671 |
1613 |
| SV* sv_class_dir = sv_2mortal(newSVpv(class_dir, 0)); |
| 5672 |
|
| |
| 5673 |
1613 |
▶ | XPUSHs(sv_class_dir); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_class_dir); |
0 |
1613 |
1613 |
|
| 5674 |
1613 |
| XSRETURN(1); |
| 5675 |
|
| } |
| 5676 |
|
| |
| 5677 |
|
| SV* |
| 5678 |
|
| get_class_rel_file(...) |
| 5679 |
|
| PPCODE: |
| 5680 |
|
| { |
| 5681 |
|
| |
| 5682 |
1613 |
| SV* sv_self = ST(0); |
| 5683 |
1613 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 5684 |
1613 |
| void* basic_type = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 5685 |
|
| |
| 5686 |
1613 |
| SV** sv_runtime_ptr = hv_fetch(hv_self, "runtime", strlen("runtime"), 0); |
| 5687 |
1613 |
▶ | SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
1613 |
0 |
1613 |
|
| 5688 |
1613 |
| HV* hv_runtime = (HV*)SvRV(sv_runtime); |
| 5689 |
1613 |
| void* runtime = SPVM_XS_UTIL_get_pointer(aTHX_ sv_runtime); |
| 5690 |
|
| |
| 5691 |
1613 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 5692 |
|
| |
| 5693 |
1613 |
| const char* class_rel_file = boot_env->api->basic_type->get_class_rel_file(runtime, basic_type); |
| 5694 |
|
| |
| 5695 |
1613 |
| SV* sv_class_rel_file = sv_2mortal(newSVpv(class_rel_file, 0)); |
| 5696 |
|
| |
| 5697 |
1613 |
▶ | XPUSHs(sv_class_rel_file); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_class_rel_file); |
0 |
1613 |
1613 |
|
| 5698 |
1613 |
| XSRETURN(1); |
| 5699 |
|
| } |
| 5700 |
|
| |
| 5701 |
|
| SV* |
| 5702 |
|
| get_name(...) |
| 5703 |
|
| PPCODE: |
| 5704 |
|
| { |
| 5705 |
|
| |
| 5706 |
35558 |
| SV* sv_self = ST(0); |
| 5707 |
35558 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 5708 |
35558 |
| void* basic_type = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 5709 |
|
| |
| 5710 |
35558 |
| SV** sv_runtime_ptr = hv_fetch(hv_self, "runtime", strlen("runtime"), 0); |
| 5711 |
35558 |
▶ | SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
35558 |
0 |
35558 |
|
| 5712 |
35558 |
| HV* hv_runtime = (HV*)SvRV(sv_runtime); |
| 5713 |
35558 |
| void* runtime = SPVM_XS_UTIL_get_pointer(aTHX_ sv_runtime); |
| 5714 |
|
| |
| 5715 |
35558 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 5716 |
|
| |
| 5717 |
35558 |
| const char* name = boot_env->api->basic_type->get_name(runtime, basic_type); |
| 5718 |
|
| |
| 5719 |
35558 |
| SV* sv_name = sv_2mortal(newSVpv(name, 0)); |
| 5720 |
|
| |
| 5721 |
35558 |
▶ | XPUSHs(sv_name); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_name); |
0 |
35558 |
35558 |
|
| 5722 |
35558 |
| XSRETURN(1); |
| 5723 |
|
| } |
| 5724 |
|
| |
| 5725 |
|
| SV* |
| 5726 |
|
| get_category(...) |
| 5727 |
|
| PPCODE: |
| 5728 |
|
| { |
| 5729 |
|
| |
| 5730 |
3774 |
| SV* sv_self = ST(0); |
| 5731 |
3774 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 5732 |
3774 |
| void* basic_type = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 5733 |
|
| |
| 5734 |
3774 |
| SV** sv_runtime_ptr = hv_fetch(hv_self, "runtime", strlen("runtime"), 0); |
| 5735 |
3774 |
▶ | SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
3774 |
0 |
3774 |
|
| 5736 |
3774 |
| HV* hv_runtime = (HV*)SvRV(sv_runtime); |
| 5737 |
3774 |
| void* runtime = SPVM_XS_UTIL_get_pointer(aTHX_ sv_runtime); |
| 5738 |
|
| |
| 5739 |
3774 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 5740 |
|
| |
| 5741 |
3774 |
| int32_t category = boot_env->api->basic_type->get_category(runtime, basic_type); |
| 5742 |
|
| |
| 5743 |
3774 |
| SV* sv_category = sv_2mortal(newSViv(category)); |
| 5744 |
|
| |
| 5745 |
3774 |
▶ | XPUSHs(sv_category); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_category); |
0 |
3774 |
3774 |
|
| 5746 |
3774 |
| XSRETURN(1); |
| 5747 |
|
| } |
| 5748 |
|
| |
| 5749 |
|
| SV* |
| 5750 |
|
| is_anon(...) |
| 5751 |
|
| PPCODE: |
| 5752 |
|
| { |
| 5753 |
|
| |
| 5754 |
0 |
| SV* sv_self = ST(0); |
| 5755 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 5756 |
0 |
| void* basic_type = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 5757 |
|
| |
| 5758 |
0 |
| SV** sv_runtime_ptr = hv_fetch(hv_self, "runtime", strlen("runtime"), 0); |
| 5759 |
0 |
▶ | SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 5760 |
0 |
| HV* hv_runtime = (HV*)SvRV(sv_runtime); |
| 5761 |
0 |
| void* runtime = SPVM_XS_UTIL_get_pointer(aTHX_ sv_runtime); |
| 5762 |
|
| |
| 5763 |
0 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 5764 |
|
| |
| 5765 |
0 |
| int32_t is_anon = boot_env->api->basic_type->is_anon(runtime, basic_type); |
| 5766 |
|
| |
| 5767 |
0 |
| SV* sv_is_anon = sv_2mortal(newSViv(is_anon)); |
| 5768 |
|
| |
| 5769 |
0 |
▶ | XPUSHs(sv_is_anon); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_is_anon); |
0 |
0 |
0 |
|
| 5770 |
0 |
| XSRETURN(1); |
| 5771 |
|
| } |
| 5772 |
|
| |
| 5773 |
|
| SV* |
| 5774 |
|
| get_methods_length(...) |
| 5775 |
|
| PPCODE: |
| 5776 |
|
| { |
| 5777 |
|
| |
| 5778 |
576 |
| SV* sv_self = ST(0); |
| 5779 |
576 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 5780 |
576 |
| void* basic_type = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 5781 |
|
| |
| 5782 |
576 |
| SV** sv_runtime_ptr = hv_fetch(hv_self, "runtime", strlen("runtime"), 0); |
| 5783 |
576 |
▶ | SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
576 |
0 |
576 |
|
| 5784 |
576 |
| HV* hv_runtime = (HV*)SvRV(sv_runtime); |
| 5785 |
576 |
| void* runtime = SPVM_XS_UTIL_get_pointer(aTHX_ sv_runtime); |
| 5786 |
|
| |
| 5787 |
576 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 5788 |
|
| |
| 5789 |
576 |
| int32_t methods_length = boot_env->api->basic_type->get_methods_length(runtime, basic_type); |
| 5790 |
|
| |
| 5791 |
576 |
| SV* sv_methods_length = sv_2mortal(newSViv(methods_length)); |
| 5792 |
|
| |
| 5793 |
576 |
▶ | XPUSHs(sv_methods_length); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_methods_length); |
0 |
576 |
576 |
|
| 5794 |
576 |
| XSRETURN(1); |
| 5795 |
|
| } |
| 5796 |
|
| |
| 5797 |
|
| SV* |
| 5798 |
|
| get_method_by_index(...) |
| 5799 |
|
| PPCODE: |
| 5800 |
|
| { |
| 5801 |
|
| |
| 5802 |
4329 |
| SV* sv_self = ST(0); |
| 5803 |
4329 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 5804 |
4329 |
| void* basic_type = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 5805 |
|
| |
| 5806 |
4329 |
| SV* sv_method_index = ST(1); |
| 5807 |
4329 |
| int32_t method_index = SvIV(sv_method_index); |
| 5808 |
|
| |
| 5809 |
4329 |
| SV** sv_runtime_ptr = hv_fetch(hv_self, "runtime", strlen("runtime"), 0); |
| 5810 |
4329 |
▶ | SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
4329 |
0 |
4329 |
|
| 5811 |
4329 |
| HV* hv_runtime = (HV*)SvRV(sv_runtime); |
| 5812 |
4329 |
| void* runtime = SPVM_XS_UTIL_get_pointer(aTHX_ sv_runtime); |
| 5813 |
|
| |
| 5814 |
4329 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 5815 |
|
| |
| 5816 |
4329 |
| void* method = boot_env->api->basic_type->get_method_by_index(runtime, basic_type, method_index); |
| 5817 |
|
| |
| 5818 |
4329 |
| SV* sv_method = &PL_sv_undef; |
| 5819 |
|
| |
| 5820 |
4329 |
▶ | if (method) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (method) { |
4329 |
0 |
4329 |
|
| 5821 |
4329 |
| sv_method = SPVM_XS_UTIL_new_sv_pointer_object(aTHX_ method, "SPVM::Builder::Native::Method"); |
| 5822 |
4329 |
| HV* hv_method = (HV*)SvRV(sv_method); |
| 5823 |
|
| |
| 5824 |
4329 |
| (void)hv_store(hv_method, "runtime", strlen("runtime"), SvREFCNT_inc(sv_runtime), 0); |
| 5825 |
|
| } |
| 5826 |
|
| |
| 5827 |
4329 |
▶ | XPUSHs(sv_method); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_method); |
0 |
4329 |
4329 |
|
| 5828 |
4329 |
| XSRETURN(1); |
| 5829 |
|
| } |
| 5830 |
|
| |
| 5831 |
|
| SV* |
| 5832 |
|
| get_method_by_name(...) |
| 5833 |
|
| PPCODE: |
| 5834 |
|
| { |
| 5835 |
|
| |
| 5836 |
20488 |
| SV* sv_self = ST(0); |
| 5837 |
20488 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 5838 |
20488 |
| void* basic_type = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 5839 |
|
| |
| 5840 |
20488 |
| SV* sv_method_name = ST(1); |
| 5841 |
20488 |
| const char* method_name = SvPV_nolen(sv_method_name); |
| 5842 |
|
| |
| 5843 |
20488 |
| SV** sv_runtime_ptr = hv_fetch(hv_self, "runtime", strlen("runtime"), 0); |
| 5844 |
20488 |
▶ | SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
20488 |
0 |
20488 |
|
| 5845 |
20488 |
| HV* hv_runtime = (HV*)SvRV(sv_runtime); |
| 5846 |
20488 |
| void* runtime = SPVM_XS_UTIL_get_pointer(aTHX_ sv_runtime); |
| 5847 |
|
| |
| 5848 |
20488 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 5849 |
|
| |
| 5850 |
20488 |
| void* method = boot_env->api->basic_type->get_method_by_name(runtime, basic_type, method_name); |
| 5851 |
|
| |
| 5852 |
20488 |
| SV* sv_method = &PL_sv_undef; |
| 5853 |
|
| |
| 5854 |
20488 |
▶ | if (method) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (method) { |
20488 |
0 |
20488 |
|
| 5855 |
20488 |
| sv_method = SPVM_XS_UTIL_new_sv_pointer_object(aTHX_ method, "SPVM::Builder::Native::Method"); |
| 5856 |
20488 |
| HV* hv_method = (HV*)SvRV(sv_method); |
| 5857 |
|
| |
| 5858 |
20488 |
| (void)hv_store(hv_method, "runtime", strlen("runtime"), SvREFCNT_inc(sv_runtime), 0); |
| 5859 |
|
| } |
| 5860 |
|
| |
| 5861 |
20488 |
▶ | XPUSHs(sv_method); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_method); |
0 |
20488 |
20488 |
|
| 5862 |
20488 |
| XSRETURN(1); |
| 5863 |
|
| } |
| 5864 |
|
| |
| 5865 |
|
| SV* |
| 5866 |
|
| get_method_names_by_category(...) |
| 5867 |
|
| PPCODE: |
| 5868 |
|
| { |
| 5869 |
|
| |
| 5870 |
60370 |
| SV* sv_self = ST(0); |
| 5871 |
60370 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 5872 |
60370 |
| void* basic_type = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 5873 |
|
| |
| 5874 |
60370 |
| SV* sv_category = ST(1); |
| 5875 |
|
| |
| 5876 |
60370 |
| SV** sv_runtime_ptr = hv_fetch(hv_self, "runtime", strlen("runtime"), 0); |
| 5877 |
60370 |
▶ | SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
60370 |
0 |
60370 |
|
| 5878 |
60370 |
| HV* hv_runtime = (HV*)SvRV(sv_runtime); |
| 5879 |
60370 |
| void* runtime = SPVM_XS_UTIL_get_pointer(aTHX_ sv_runtime); |
| 5880 |
|
| |
| 5881 |
60370 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 5882 |
|
| |
| 5883 |
60370 |
| AV* av_method_names = (AV*)sv_2mortal((SV*)newAV()); |
| 5884 |
60370 |
| SV* sv_method_names = sv_2mortal(newRV_inc((SV*)av_method_names)); |
| 5885 |
|
| |
| 5886 |
60370 |
| int32_t methods_length = boot_env->api->basic_type->get_methods_length(runtime, basic_type); |
| 5887 |
473026 |
▶ | for (int32_t method_index = 0; method_index < methods_length; method_index++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int32_t method_index = 0; method_index < methods_length; method_index++) { |
412656 |
60370 |
473026 |
|
| 5888 |
412656 |
| void* method = boot_env->api->basic_type->get_method_by_index(runtime, basic_type, method_index); |
| 5889 |
412656 |
| const char* method_name = boot_env->api->method->get_name(runtime, method); |
| 5890 |
412656 |
| SV* sv_method_name = sv_2mortal(newSVpv(method_name, 0)); |
| 5891 |
412656 |
| int32_t is_push = 0; |
| 5892 |
412656 |
▶ | if (SvOK(sv_category)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_category)) { |
412656 |
0 |
412656 |
|
| 5893 |
412656 |
▶ | if(strEQ(SvPV_nolen(sv_category), "native") && boot_env->api->method->is_native(runtime, method)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if(strEQ(SvPV_nolen(sv_category), "native") && boot_env->api->method->is_native(runtime, method)) { |
205510 |
207146 |
412656 |
| if(strEQ(SvPV_nolen(sv_category), "native") && boot_env->api->method->is_native(runtime, method)) { |
21059 |
184451 |
205510 |
|
| 5894 |
21059 |
| av_push(av_method_names, SvREFCNT_inc(sv_method_name)); |
| 5895 |
|
| } |
| 5896 |
391597 |
▶ | else if (strEQ(SvPV_nolen(sv_category), "precompile") && boot_env->api->method->is_precompile(runtime, method)) { |
Branch: 2 branches
| Branch | True | False | Total |
| else if (strEQ(SvPV_nolen(sv_category), "precompile") && boot_env->api->method->is_precompile(runtime, method)) { |
207146 |
184451 |
391597 |
| else if (strEQ(SvPV_nolen(sv_category), "precompile") && boot_env->api->method->is_precompile(runtime, method)) { |
22216 |
184930 |
207146 |
|
| 5897 |
22216 |
| av_push(av_method_names, SvREFCNT_inc(sv_method_name)); |
| 5898 |
|
| } |
| 5899 |
|
| } |
| 5900 |
|
| else { |
| 5901 |
0 |
| av_push(av_method_names, SvREFCNT_inc(sv_method_name)); |
| 5902 |
|
| } |
| 5903 |
|
| } |
| 5904 |
|
| |
| 5905 |
60370 |
▶ | XPUSHs(sv_method_names); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_method_names); |
0 |
60370 |
60370 |
|
| 5906 |
60370 |
| XSRETURN(1); |
| 5907 |
|
| } |
| 5908 |
|
| |
| 5909 |
|
| SV* |
| 5910 |
|
| build_precompile_class_source(...) |
| 5911 |
|
| PPCODE: |
| 5912 |
|
| { |
| 5913 |
89 |
| SV* sv_self = ST(0); |
| 5914 |
89 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 5915 |
89 |
| void* basic_type = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 5916 |
|
| |
| 5917 |
89 |
| SV** sv_runtime_ptr = hv_fetch(hv_self, "runtime", strlen("runtime"), 0); |
| 5918 |
89 |
▶ | SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
89 |
0 |
89 |
|
| 5919 |
89 |
| HV* hv_runtime = (HV*)SvRV(sv_runtime); |
| 5920 |
89 |
| void* runtime = SPVM_XS_UTIL_get_pointer(aTHX_ sv_runtime); |
| 5921 |
|
| |
| 5922 |
89 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 5923 |
|
| |
| 5924 |
89 |
| void* allocator = boot_env->api->allocator->new_instance(); |
| 5925 |
|
| |
| 5926 |
89 |
| void* string_buffer = boot_env->api->string_buffer->new_instance(allocator, 0); |
| 5927 |
|
| |
| 5928 |
89 |
| boot_env->api->runtime->build_precompile_class_source(runtime, string_buffer, basic_type); |
| 5929 |
|
| |
| 5930 |
89 |
| const char* string_buffer_value = boot_env->api->string_buffer->get_string(string_buffer); |
| 5931 |
89 |
| int32_t string_buffer_length = boot_env->api->string_buffer->get_length(string_buffer); |
| 5932 |
89 |
| SV* sv_precompile_source = sv_2mortal(newSVpv(string_buffer_value, string_buffer_length)); |
| 5933 |
|
| |
| 5934 |
89 |
| boot_env->api->string_buffer->free_instance(string_buffer); |
| 5935 |
|
| |
| 5936 |
89 |
| boot_env->api->allocator->free_instance(allocator); |
| 5937 |
|
| |
| 5938 |
89 |
▶ | XPUSHs(sv_precompile_source); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_precompile_source); |
0 |
89 |
89 |
|
| 5939 |
89 |
| XSRETURN(1); |
| 5940 |
|
| } |
| 5941 |
|
| |
| 5942 |
|
| SV* |
| 5943 |
|
| get_anon_basic_type_names(...) |
| 5944 |
|
| PPCODE: |
| 5945 |
|
| { |
| 5946 |
|
| |
| 5947 |
305 |
| SV* sv_self = ST(0); |
| 5948 |
305 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 5949 |
305 |
| void* basic_type = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 5950 |
|
| |
| 5951 |
305 |
| SV** sv_runtime_ptr = hv_fetch(hv_self, "runtime", strlen("runtime"), 0); |
| 5952 |
305 |
▶ | SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
305 |
0 |
305 |
|
| 5953 |
305 |
| HV* hv_runtime = (HV*)SvRV(sv_runtime); |
| 5954 |
305 |
| void* runtime = SPVM_XS_UTIL_get_pointer(aTHX_ sv_runtime); |
| 5955 |
|
| |
| 5956 |
305 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 5957 |
|
| |
| 5958 |
305 |
| AV* av_anon_basic_type_names = (AV*)sv_2mortal((SV*)newAV()); |
| 5959 |
305 |
| SV* sv_anon_basic_type_names = sv_2mortal(newRV_inc((SV*)av_anon_basic_type_names)); |
| 5960 |
|
| |
| 5961 |
305 |
| int32_t basic_type_anon_basic_types_length = boot_env->api->basic_type->get_anon_basic_types_length(runtime, basic_type); |
| 5962 |
357 |
▶ | for (int32_t anon_basic_type_index = 0; anon_basic_type_index < basic_type_anon_basic_types_length; anon_basic_type_index++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int32_t anon_basic_type_index = 0; anon_basic_type_index < basic_type_anon_basic_types_length; anon_basic_type_index++) { |
52 |
305 |
357 |
|
| 5963 |
52 |
| void* anon_basic_type = boot_env->api->basic_type->get_anon_basic_type_by_index(runtime, basic_type, anon_basic_type_index); |
| 5964 |
|
| |
| 5965 |
52 |
| const char* anon_basic_type_name = boot_env->api->basic_type->get_name(runtime, anon_basic_type); |
| 5966 |
52 |
| SV* sv_anon_basic_type_name = sv_2mortal(newSVpv(anon_basic_type_name, 0)); |
| 5967 |
52 |
| av_push(av_anon_basic_type_names, SvREFCNT_inc(sv_anon_basic_type_name)); |
| 5968 |
|
| } |
| 5969 |
|
| |
| 5970 |
305 |
▶ | XPUSHs(sv_anon_basic_type_names); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_anon_basic_type_names); |
0 |
305 |
305 |
|
| 5971 |
305 |
| XSRETURN(1); |
| 5972 |
|
| } |
| 5973 |
|
| |
| 5974 |
|
| SV* |
| 5975 |
|
| get_version_string(...) |
| 5976 |
|
| PPCODE: |
| 5977 |
|
| { |
| 5978 |
541 |
| SV* sv_self = ST(0); |
| 5979 |
541 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 5980 |
541 |
| void* basic_type = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 5981 |
|
| |
| 5982 |
541 |
| SV** sv_runtime_ptr = hv_fetch(hv_self, "runtime", strlen("runtime"), 0); |
| 5983 |
541 |
▶ | SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
541 |
0 |
541 |
|
| 5984 |
541 |
| HV* hv_runtime = (HV*)SvRV(sv_runtime); |
| 5985 |
541 |
| void* runtime = SPVM_XS_UTIL_get_pointer(aTHX_ sv_runtime); |
| 5986 |
|
| |
| 5987 |
541 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 5988 |
|
| |
| 5989 |
541 |
| const char* version_string = boot_env->api->basic_type->get_version_string(runtime, basic_type); |
| 5990 |
|
| |
| 5991 |
541 |
| SV* sv_version_string = &PL_sv_undef; |
| 5992 |
|
| |
| 5993 |
541 |
▶ | if (version_string) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (version_string) { |
23 |
518 |
541 |
|
| 5994 |
23 |
| sv_version_string = sv_2mortal(newSVpv(version_string, 0)); |
| 5995 |
|
| } |
| 5996 |
|
| |
| 5997 |
541 |
▶ | XPUSHs(sv_version_string); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_version_string); |
0 |
541 |
541 |
|
| 5998 |
541 |
| XSRETURN(1); |
| 5999 |
|
| } |
| 6000 |
|
| |
| 6001 |
|
| SV* |
| 6002 |
|
| get_basic_type_in_version_from(...) |
| 6003 |
|
| PPCODE: |
| 6004 |
|
| { |
| 6005 |
|
| |
| 6006 |
541 |
| SV* sv_self = ST(0); |
| 6007 |
541 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 6008 |
541 |
| void* basic_type = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 6009 |
|
| |
| 6010 |
541 |
| SV** sv_runtime_ptr = hv_fetch(hv_self, "runtime", strlen("runtime"), 0); |
| 6011 |
541 |
▶ | SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
541 |
0 |
541 |
|
| 6012 |
541 |
| HV* hv_runtime = (HV*)SvRV(sv_runtime); |
| 6013 |
541 |
| void* runtime = SPVM_XS_UTIL_get_pointer(aTHX_ sv_runtime); |
| 6014 |
|
| |
| 6015 |
541 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 6016 |
|
| |
| 6017 |
541 |
| void* basic_type_in_version_from = boot_env->api->basic_type->get_basic_type_in_version_from(runtime, basic_type); |
| 6018 |
|
| |
| 6019 |
541 |
| SV* sv_basic_type_in_version_from = &PL_sv_undef; |
| 6020 |
|
| |
| 6021 |
541 |
▶ | if (basic_type_in_version_from) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (basic_type_in_version_from) { |
486 |
55 |
541 |
|
| 6022 |
486 |
| sv_basic_type_in_version_from = SPVM_XS_UTIL_new_sv_pointer_object(aTHX_ basic_type_in_version_from, "SPVM::Builder::Native::BasicType"); |
| 6023 |
486 |
| HV* hv_basic_type_in_version_from = (HV*)SvRV(sv_basic_type_in_version_from); |
| 6024 |
|
| |
| 6025 |
486 |
| (void)hv_store(hv_basic_type_in_version_from, "runtime", strlen("runtime"), SvREFCNT_inc(sv_runtime), 0); |
| 6026 |
|
| } |
| 6027 |
|
| |
| 6028 |
541 |
▶ | XPUSHs(sv_basic_type_in_version_from); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_basic_type_in_version_from); |
0 |
541 |
541 |
|
| 6029 |
541 |
| XSRETURN(1); |
| 6030 |
|
| } |
| 6031 |
|
| |
| 6032 |
|
| MODULE = SPVM::Builder::Native::Method PACKAGE = SPVM::Builder::Native::Method |
| 6033 |
|
| |
| 6034 |
|
| SV* |
| 6035 |
|
| get_name(...) |
| 6036 |
|
| PPCODE: |
| 6037 |
|
| { |
| 6038 |
|
| |
| 6039 |
4329 |
| SV* sv_self = ST(0); |
| 6040 |
4329 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 6041 |
4329 |
| void* method = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 6042 |
|
| |
| 6043 |
4329 |
| SV** sv_runtime_ptr = hv_fetch(hv_self, "runtime", strlen("runtime"), 0); |
| 6044 |
4329 |
▶ | SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
4329 |
0 |
4329 |
|
| 6045 |
4329 |
| HV* hv_runtime = (HV*)SvRV(sv_runtime); |
| 6046 |
4329 |
| void* runtime = SPVM_XS_UTIL_get_pointer(aTHX_ sv_runtime); |
| 6047 |
|
| |
| 6048 |
4329 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 6049 |
|
| |
| 6050 |
4329 |
| const char* name = boot_env->api->method->get_name(runtime, method); |
| 6051 |
|
| |
| 6052 |
4329 |
| SV* sv_name = sv_2mortal(newSVpv(name, 0)); |
| 6053 |
|
| |
| 6054 |
4329 |
▶ | XPUSHs(sv_name); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_name); |
0 |
4329 |
4329 |
|
| 6055 |
4329 |
| XSRETURN(1); |
| 6056 |
|
| } |
| 6057 |
|
| |
| 6058 |
|
| SV* |
| 6059 |
|
| is_native(...) |
| 6060 |
|
| PPCODE: |
| 6061 |
|
| { |
| 6062 |
|
| |
| 6063 |
688 |
| SV* sv_self = ST(0); |
| 6064 |
688 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 6065 |
688 |
| void* method = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 6066 |
|
| |
| 6067 |
688 |
| SV** sv_runtime_ptr = hv_fetch(hv_self, "runtime", strlen("runtime"), 0); |
| 6068 |
688 |
▶ | SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
688 |
0 |
688 |
|
| 6069 |
688 |
| HV* hv_runtime = (HV*)SvRV(sv_runtime); |
| 6070 |
688 |
| void* runtime = SPVM_XS_UTIL_get_pointer(aTHX_ sv_runtime); |
| 6071 |
|
| |
| 6072 |
688 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 6073 |
|
| |
| 6074 |
688 |
| int32_t is_native = boot_env->api->method->is_native(runtime, method); |
| 6075 |
|
| |
| 6076 |
688 |
| SV* sv_is_native = sv_2mortal(newSViv(is_native)); |
| 6077 |
|
| |
| 6078 |
688 |
▶ | XPUSHs(sv_is_native); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_is_native); |
0 |
688 |
688 |
|
| 6079 |
688 |
| XSRETURN(1); |
| 6080 |
|
| } |
| 6081 |
|
| |
| 6082 |
|
| SV* |
| 6083 |
|
| is_precompile(...) |
| 6084 |
|
| PPCODE: |
| 6085 |
|
| { |
| 6086 |
|
| |
| 6087 |
688 |
| SV* sv_self = ST(0); |
| 6088 |
688 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 6089 |
688 |
| void* method = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 6090 |
|
| |
| 6091 |
688 |
| SV** sv_runtime_ptr = hv_fetch(hv_self, "runtime", strlen("runtime"), 0); |
| 6092 |
688 |
▶ | SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
688 |
0 |
688 |
|
| 6093 |
688 |
| HV* hv_runtime = (HV*)SvRV(sv_runtime); |
| 6094 |
688 |
| void* runtime = SPVM_XS_UTIL_get_pointer(aTHX_ sv_runtime); |
| 6095 |
|
| |
| 6096 |
688 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 6097 |
|
| |
| 6098 |
688 |
| int32_t is_precompile = boot_env->api->method->is_precompile(runtime, method); |
| 6099 |
|
| |
| 6100 |
688 |
| SV* sv_is_precompile = sv_2mortal(newSViv(is_precompile)); |
| 6101 |
|
| |
| 6102 |
688 |
▶ | XPUSHs(sv_is_precompile); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_is_precompile); |
0 |
688 |
688 |
|
| 6103 |
688 |
| XSRETURN(1); |
| 6104 |
|
| } |
| 6105 |
|
| |
| 6106 |
|
| SV* |
| 6107 |
|
| is_class_method(...) |
| 6108 |
|
| PPCODE: |
| 6109 |
|
| { |
| 6110 |
|
| |
| 6111 |
2950 |
| SV* sv_self = ST(0); |
| 6112 |
2950 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 6113 |
2950 |
| void* method = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 6114 |
|
| |
| 6115 |
2950 |
| SV** sv_runtime_ptr = hv_fetch(hv_self, "runtime", strlen("runtime"), 0); |
| 6116 |
2950 |
▶ | SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
2950 |
0 |
2950 |
|
| 6117 |
2950 |
| HV* hv_runtime = (HV*)SvRV(sv_runtime); |
| 6118 |
2950 |
| void* runtime = SPVM_XS_UTIL_get_pointer(aTHX_ sv_runtime); |
| 6119 |
|
| |
| 6120 |
2950 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 6121 |
|
| |
| 6122 |
2950 |
| int32_t is_class_method = boot_env->api->method->is_class_method(runtime, method); |
| 6123 |
|
| |
| 6124 |
2950 |
| SV* sv_is_class_method = sv_2mortal(newSViv(is_class_method)); |
| 6125 |
|
| |
| 6126 |
2950 |
▶ | XPUSHs(sv_is_class_method); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_is_class_method); |
0 |
2950 |
2950 |
|
| 6127 |
2950 |
| XSRETURN(1); |
| 6128 |
|
| } |
| 6129 |
|
| |
| 6130 |
|
| SV* |
| 6131 |
|
| set_native_address(...) |
| 6132 |
|
| PPCODE: |
| 6133 |
|
| { |
| 6134 |
|
| |
| 6135 |
10183 |
| SV* sv_self = ST(0); |
| 6136 |
10183 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 6137 |
10183 |
| void* method = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 6138 |
|
| |
| 6139 |
10183 |
| SV* sv_native_address = ST(1); |
| 6140 |
|
| |
| 6141 |
10183 |
| SV** sv_runtime_ptr = hv_fetch(hv_self, "runtime", strlen("runtime"), 0); |
| 6142 |
10183 |
▶ | SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
10183 |
0 |
10183 |
|
| 6143 |
10183 |
| HV* hv_runtime = (HV*)SvRV(sv_runtime); |
| 6144 |
10183 |
| void* runtime = SPVM_XS_UTIL_get_pointer(aTHX_ sv_runtime); |
| 6145 |
|
| |
| 6146 |
10183 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 6147 |
|
| |
| 6148 |
10183 |
| void* native_address = INT2PTR(void*, SvIV(sv_native_address)); |
| 6149 |
|
| |
| 6150 |
10183 |
| boot_env->api->method->set_native_address(runtime, method, native_address); |
| 6151 |
|
| |
| 6152 |
|
| assert(native_address == boot_env->api->method->get_native_address(runtime, method)); |
| 6153 |
|
| |
| 6154 |
10183 |
| XSRETURN(0); |
| 6155 |
|
| } |
| 6156 |
|
| |
| 6157 |
|
| SV* |
| 6158 |
|
| set_precompile_address(...) |
| 6159 |
|
| PPCODE: |
| 6160 |
|
| { |
| 6161 |
|
| |
| 6162 |
10305 |
| SV* sv_self = ST(0); |
| 6163 |
10305 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 6164 |
10305 |
| void* method = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 6165 |
|
| |
| 6166 |
10305 |
| SV* sv_precompile_address = ST(1); |
| 6167 |
|
| |
| 6168 |
10305 |
| SV** sv_runtime_ptr = hv_fetch(hv_self, "runtime", strlen("runtime"), 0); |
| 6169 |
10305 |
▶ | SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
10305 |
0 |
10305 |
|
| 6170 |
10305 |
| HV* hv_runtime = (HV*)SvRV(sv_runtime); |
| 6171 |
10305 |
| void* runtime = SPVM_XS_UTIL_get_pointer(aTHX_ sv_runtime); |
| 6172 |
|
| |
| 6173 |
10305 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 6174 |
|
| |
| 6175 |
10305 |
| void* precompile_address = INT2PTR(void*, SvIV(sv_precompile_address)); |
| 6176 |
|
| |
| 6177 |
10305 |
| boot_env->api->method->set_precompile_address(runtime, method, precompile_address); |
| 6178 |
|
| |
| 6179 |
|
| assert(precompile_address == boot_env->api->method->get_precompile_address(runtime, method)); |
| 6180 |
|
| |
| 6181 |
10305 |
| XSRETURN(0); |
| 6182 |
|
| } |
| 6183 |
|
| |
| 6184 |
|
| MODULE = SPVM::Builder::Native::ClassFile PACKAGE = SPVM::Builder::Native::ClassFile |
| 6185 |
|
| |
| 6186 |
|
| SV* |
| 6187 |
|
| get_file(...) |
| 6188 |
|
| PPCODE: |
| 6189 |
|
| { |
| 6190 |
|
| |
| 6191 |
0 |
| SV* sv_self = ST(0); |
| 6192 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 6193 |
0 |
| void* class_file = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 6194 |
|
| |
| 6195 |
0 |
| SV** sv_compiler_ptr = hv_fetch(hv_self, "compiler", strlen("compiler"), 0); |
| 6196 |
0 |
▶ | SV* sv_compiler = sv_compiler_ptr ? *sv_compiler_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_compiler = sv_compiler_ptr ? *sv_compiler_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 6197 |
0 |
| HV* hv_compiler = (HV*)SvRV(sv_compiler); |
| 6198 |
0 |
| void* compiler = SPVM_XS_UTIL_get_pointer(aTHX_ sv_compiler); |
| 6199 |
|
| |
| 6200 |
0 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 6201 |
|
| |
| 6202 |
0 |
| const char* file = boot_env->api->class_file->get_file(compiler, class_file); |
| 6203 |
|
| |
| 6204 |
0 |
| SV* sv_file = &PL_sv_undef; |
| 6205 |
|
| |
| 6206 |
0 |
▶ | if (file) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (file) { |
0 |
0 |
0 |
|
| 6207 |
0 |
| sv_file = sv_2mortal(newSVpv(file, 0)); |
| 6208 |
|
| } |
| 6209 |
|
| |
| 6210 |
0 |
▶ | XPUSHs(sv_file); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_file); |
0 |
0 |
0 |
|
| 6211 |
0 |
| XSRETURN(1); |
| 6212 |
|
| } |
| 6213 |
|
| |
| 6214 |
|
| SV* |
| 6215 |
|
| get_dir(...) |
| 6216 |
|
| PPCODE: |
| 6217 |
|
| { |
| 6218 |
|
| |
| 6219 |
0 |
| SV* sv_self = ST(0); |
| 6220 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 6221 |
0 |
| void* class_file = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 6222 |
|
| |
| 6223 |
0 |
| SV** sv_compiler_ptr = hv_fetch(hv_self, "compiler", strlen("compiler"), 0); |
| 6224 |
0 |
▶ | SV* sv_compiler = sv_compiler_ptr ? *sv_compiler_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_compiler = sv_compiler_ptr ? *sv_compiler_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 6225 |
0 |
| HV* hv_compiler = (HV*)SvRV(sv_compiler); |
| 6226 |
0 |
| void* compiler = SPVM_XS_UTIL_get_pointer(aTHX_ sv_compiler); |
| 6227 |
|
| |
| 6228 |
0 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 6229 |
|
| |
| 6230 |
0 |
| const char* dir = boot_env->api->class_file->get_dir(compiler, class_file); |
| 6231 |
|
| |
| 6232 |
0 |
| SV* sv_dir = &PL_sv_undef; |
| 6233 |
|
| |
| 6234 |
0 |
▶ | if (dir) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (dir) { |
0 |
0 |
0 |
|
| 6235 |
0 |
| sv_dir = sv_2mortal(newSVpv(dir, 0)); |
| 6236 |
|
| } |
| 6237 |
|
| |
| 6238 |
0 |
▶ | XPUSHs(sv_dir); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_dir); |
0 |
0 |
0 |
|
| 6239 |
0 |
| XSRETURN(1); |
| 6240 |
|
| } |
| 6241 |
|
| |
| 6242 |
|
| SV* |
| 6243 |
|
| get_rel_file(...) |
| 6244 |
|
| PPCODE: |
| 6245 |
|
| { |
| 6246 |
|
| |
| 6247 |
63 |
| SV* sv_self = ST(0); |
| 6248 |
63 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 6249 |
63 |
| void* class_file = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 6250 |
|
| |
| 6251 |
63 |
| SV** sv_compiler_ptr = hv_fetch(hv_self, "compiler", strlen("compiler"), 0); |
| 6252 |
63 |
▶ | SV* sv_compiler = sv_compiler_ptr ? *sv_compiler_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_compiler = sv_compiler_ptr ? *sv_compiler_ptr : &PL_sv_undef; |
63 |
0 |
63 |
|
| 6253 |
63 |
| HV* hv_compiler = (HV*)SvRV(sv_compiler); |
| 6254 |
63 |
| void* compiler = SPVM_XS_UTIL_get_pointer(aTHX_ sv_compiler); |
| 6255 |
|
| |
| 6256 |
63 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 6257 |
|
| |
| 6258 |
63 |
| const char* rel_file = boot_env->api->class_file->get_rel_file(compiler, class_file); |
| 6259 |
|
| |
| 6260 |
63 |
| SV* sv_rel_file = &PL_sv_undef; |
| 6261 |
|
| |
| 6262 |
63 |
▶ | if (rel_file) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (rel_file) { |
63 |
0 |
63 |
|
| 6263 |
63 |
| sv_rel_file = sv_2mortal(newSVpv(rel_file, 0)); |
| 6264 |
|
| } |
| 6265 |
|
| |
| 6266 |
63 |
▶ | XPUSHs(sv_rel_file); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_rel_file); |
0 |
63 |
63 |
|
| 6267 |
63 |
| XSRETURN(1); |
| 6268 |
|
| } |
| 6269 |
|
| |
| 6270 |
|
| SV* |
| 6271 |
|
| get_content(...) |
| 6272 |
|
| PPCODE: |
| 6273 |
|
| { |
| 6274 |
|
| |
| 6275 |
63 |
| SV* sv_self = ST(0); |
| 6276 |
63 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 6277 |
63 |
| void* class_file = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 6278 |
|
| |
| 6279 |
63 |
| SV** sv_compiler_ptr = hv_fetch(hv_self, "compiler", strlen("compiler"), 0); |
| 6280 |
63 |
▶ | SV* sv_compiler = sv_compiler_ptr ? *sv_compiler_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_compiler = sv_compiler_ptr ? *sv_compiler_ptr : &PL_sv_undef; |
63 |
0 |
63 |
|
| 6281 |
63 |
| HV* hv_compiler = (HV*)SvRV(sv_compiler); |
| 6282 |
63 |
| void* compiler = SPVM_XS_UTIL_get_pointer(aTHX_ sv_compiler); |
| 6283 |
|
| |
| 6284 |
63 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 6285 |
|
| |
| 6286 |
63 |
| const char* content = boot_env->api->class_file->get_content(compiler, class_file); |
| 6287 |
|
| |
| 6288 |
63 |
| SV* sv_content = &PL_sv_undef; |
| 6289 |
|
| |
| 6290 |
63 |
▶ | if (content) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (content) { |
63 |
0 |
63 |
|
| 6291 |
63 |
| sv_content = sv_2mortal(newSVpv(content, 0)); |
| 6292 |
|
| } |
| 6293 |
|
| |
| 6294 |
63 |
▶ | XPUSHs(sv_content); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_content); |
0 |
63 |
63 |
|
| 6295 |
63 |
| XSRETURN(1); |
| 6296 |
|
| } |
| 6297 |
|
| |
| 6298 |
|
| SV* |
| 6299 |
|
| get_content_length(...) |
| 6300 |
|
| PPCODE: |
| 6301 |
|
| { |
| 6302 |
|
| |
| 6303 |
63 |
| SV* sv_self = ST(0); |
| 6304 |
63 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 6305 |
63 |
| void* class_file = SPVM_XS_UTIL_get_pointer(aTHX_ sv_self); |
| 6306 |
|
| |
| 6307 |
63 |
| SV** sv_compiler_ptr = hv_fetch(hv_self, "compiler", strlen("compiler"), 0); |
| 6308 |
63 |
▶ | SV* sv_compiler = sv_compiler_ptr ? *sv_compiler_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_compiler = sv_compiler_ptr ? *sv_compiler_ptr : &PL_sv_undef; |
63 |
0 |
63 |
|
| 6309 |
63 |
| HV* hv_compiler = (HV*)SvRV(sv_compiler); |
| 6310 |
63 |
| void* compiler = SPVM_XS_UTIL_get_pointer(aTHX_ sv_compiler); |
| 6311 |
|
| |
| 6312 |
63 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 6313 |
|
| |
| 6314 |
63 |
| int32_t content_length = boot_env->api->class_file->get_content_length(compiler, class_file); |
| 6315 |
|
| |
| 6316 |
63 |
| SV* sv_content_length = sv_2mortal(newSViv(content_length)); |
| 6317 |
|
| |
| 6318 |
63 |
▶ | XPUSHs(sv_content_length); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_content_length); |
0 |
63 |
63 |
|
| 6319 |
63 |
| XSRETURN(1); |
| 6320 |
|
| } |
| 6321 |
|
| |
| 6322 |
|
| MODULE = SPVM::Builder::Native::Runtime::Info PACKAGE = SPVM::Builder::Native::Runtime::Info |
| 6323 |
|
| |
| 6324 |
|
| SV* |
| 6325 |
|
| get_basic_type_names(...) |
| 6326 |
|
| PPCODE: |
| 6327 |
|
| { |
| 6328 |
|
| |
| 6329 |
0 |
| SV* sv_self = ST(0); |
| 6330 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 6331 |
|
| |
| 6332 |
0 |
| SV** sv_runtime_ptr = hv_fetch(hv_self, "runtime", strlen("runtime"), 0); |
| 6333 |
0 |
▶ | SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 6334 |
0 |
| HV* hv_runtime = (HV*)SvRV(sv_runtime); |
| 6335 |
0 |
| void* runtime = SPVM_XS_UTIL_get_pointer(aTHX_ sv_runtime); |
| 6336 |
|
| |
| 6337 |
0 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 6338 |
|
| |
| 6339 |
0 |
| AV* av_basic_type_names = (AV*)sv_2mortal((SV*)newAV()); |
| 6340 |
0 |
| SV* sv_basic_type_names = sv_2mortal(newRV_inc((SV*)av_basic_type_names)); |
| 6341 |
|
| |
| 6342 |
0 |
| int32_t basic_types_length = boot_env->api->runtime->get_basic_types_length(runtime); |
| 6343 |
0 |
▶ | for (int32_t basic_type_id = 0; basic_type_id < basic_types_length; basic_type_id++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int32_t basic_type_id = 0; basic_type_id < basic_types_length; basic_type_id++) { |
0 |
0 |
0 |
|
| 6344 |
0 |
| void* basic_type = boot_env->api->runtime->get_basic_type_by_id(runtime, basic_type_id); |
| 6345 |
0 |
| int32_t basic_type_category = boot_env->api->basic_type->get_category(runtime, basic_type); |
| 6346 |
0 |
| const char* basic_type_name = boot_env->api->basic_type->get_name(runtime, basic_type); |
| 6347 |
0 |
| SV* sv_basic_type_name = sv_2mortal(newSVpv(basic_type_name, 0)); |
| 6348 |
0 |
| av_push(av_basic_type_names, SvREFCNT_inc(sv_basic_type_name)); |
| 6349 |
|
| } |
| 6350 |
|
| |
| 6351 |
0 |
▶ | XPUSHs(sv_basic_type_names); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_basic_type_names); |
0 |
0 |
0 |
|
| 6352 |
0 |
| XSRETURN(1); |
| 6353 |
|
| } |
| 6354 |
|
| |
| 6355 |
|
| SV* |
| 6356 |
|
| get_method_names(...) |
| 6357 |
|
| PPCODE: |
| 6358 |
|
| { |
| 6359 |
|
| |
| 6360 |
0 |
| SV* sv_self = ST(0); |
| 6361 |
0 |
| HV* hv_self = (HV*)SvRV(sv_self); |
| 6362 |
|
| |
| 6363 |
0 |
| SV* sv_basic_type_name = ST(1); |
| 6364 |
0 |
| SV* sv_category = ST(2); |
| 6365 |
|
| |
| 6366 |
0 |
| const char* basic_type_name = SvPV_nolen(sv_basic_type_name); |
| 6367 |
|
| |
| 6368 |
0 |
| SV** sv_runtime_ptr = hv_fetch(hv_self, "runtime", strlen("runtime"), 0); |
| 6369 |
0 |
▶ | SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| SV* sv_runtime = sv_runtime_ptr ? *sv_runtime_ptr : &PL_sv_undef; |
0 |
0 |
0 |
|
| 6370 |
0 |
| HV* hv_runtime = (HV*)SvRV(sv_runtime); |
| 6371 |
0 |
| void* runtime = SPVM_XS_UTIL_get_pointer(aTHX_ sv_runtime); |
| 6372 |
|
| |
| 6373 |
0 |
| SPVM_ENV* boot_env = SPVM_XS_UTIL_get_boot_env(aTHX_ sv_self); |
| 6374 |
|
| |
| 6375 |
0 |
| AV* av_method_names = (AV*)sv_2mortal((SV*)newAV()); |
| 6376 |
0 |
| SV* sv_method_names = sv_2mortal(newRV_inc((SV*)av_method_names)); |
| 6377 |
|
| |
| 6378 |
0 |
| void* basic_type = boot_env->api->runtime->get_basic_type_by_name(runtime, basic_type_name); |
| 6379 |
|
| |
| 6380 |
0 |
| int32_t methods_length = boot_env->api->basic_type->get_methods_length(runtime, basic_type); |
| 6381 |
0 |
▶ | for (int32_t method_index = 0; method_index < methods_length; method_index++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int32_t method_index = 0; method_index < methods_length; method_index++) { |
0 |
0 |
0 |
|
| 6382 |
0 |
| void* method = boot_env->api->basic_type->get_method_by_index(runtime, basic_type, method_index); |
| 6383 |
0 |
| const char* method_name = boot_env->api->method->get_name(runtime, method); |
| 6384 |
0 |
| SV* sv_method_name = sv_2mortal(newSVpv(method_name, 0)); |
| 6385 |
0 |
| int32_t is_push = 0; |
| 6386 |
0 |
▶ | if (SvOK(sv_category)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv_category)) { |
0 |
0 |
0 |
|
| 6387 |
0 |
▶ | if(strEQ(SvPV_nolen(sv_category), "native") && boot_env->api->method->is_native(runtime, method)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if(strEQ(SvPV_nolen(sv_category), "native") && boot_env->api->method->is_native(runtime, method)) { |
0 |
0 |
0 |
| if(strEQ(SvPV_nolen(sv_category), "native") && boot_env->api->method->is_native(runtime, method)) { |
0 |
0 |
0 |
|
| 6388 |
0 |
| av_push(av_method_names, SvREFCNT_inc(sv_method_name)); |
| 6389 |
|
| } |
| 6390 |
0 |
▶ | else if (strEQ(SvPV_nolen(sv_category), "precompile") && boot_env->api->method->is_precompile(runtime, method)) { |
Branch: 2 branches
| Branch | True | False | Total |
| else if (strEQ(SvPV_nolen(sv_category), "precompile") && boot_env->api->method->is_precompile(runtime, method)) { |
0 |
0 |
0 |
| else if (strEQ(SvPV_nolen(sv_category), "precompile") && boot_env->api->method->is_precompile(runtime, method)) { |
0 |
0 |
0 |
|
| 6391 |
0 |
| av_push(av_method_names, SvREFCNT_inc(sv_method_name)); |
| 6392 |
|
| } |
| 6393 |
|
| } |
| 6394 |
|
| else { |
| 6395 |
0 |
| av_push(av_method_names, SvREFCNT_inc(sv_method_name)); |
| 6396 |
|
| } |
| 6397 |
|
| } |
| 6398 |
|
| |
| 6399 |
0 |
▶ | XPUSHs(sv_method_names); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_method_names); |
0 |
0 |
0 |
|
| 6400 |
0 |
| XSRETURN(1); |
| 6401 |
|
| } |
| 6402 |
|
| |
| 6403 |
|
| MODULE = SPVM PACKAGE = SPVM |