File Coverage

lib/SPVM/Builder/src/spvm_api_field.c
Criterion Covered Total %
statement 14 22 63.6
branch n/a
condition n/a
subroutine n/a
pod n/a
total 14 22 63.6


line stmt bran cond sub pod time code
1             // Copyright (c) 2023 Yuki Kimoto
2             // MIT License
3              
4             #include
5              
6             #include "spvm_native.h"
7              
8             #include "spvm_api_field.h"
9              
10             #include "spvm_allocator.h"
11             #include "spvm_runtime_field.h"
12              
13 119195           SPVM_API_FIELD* SPVM_API_FIELD_new_api() {
14            
15 119195           void* native_apis_init[] = {
16             SPVM_API_FIELD_get_name,
17             SPVM_API_FIELD_get_index,
18             SPVM_API_FIELD_get_offset,
19             SPVM_API_FIELD_get_basic_type,
20             SPVM_API_FIELD_get_type_dimension,
21             SPVM_API_FIELD_get_type_flag,
22             SPVM_API_FIELD_get_current_basic_type,
23             };
24            
25 119195           SPVM_API_FIELD* native_apis = calloc(1, sizeof(native_apis_init));
26            
27 119195           memcpy(native_apis, native_apis_init, sizeof(native_apis_init));
28            
29 119195           return native_apis;
30             }
31              
32 119195           void SPVM_API_FIELD_free_api(SPVM_API_FIELD* api) {
33            
34 119195           free(api);
35 119195           }
36              
37 872           const char* SPVM_API_FIELD_get_name(SPVM_RUNTIME* runtime, SPVM_RUNTIME_FIELD* field) {
38            
39 872           return field->name;
40             }
41              
42 0           int32_t SPVM_API_FIELD_get_index(SPVM_RUNTIME* runtime, SPVM_RUNTIME_FIELD* field) {
43            
44 0           return field->index;
45             }
46              
47 3026           int32_t SPVM_API_FIELD_get_offset(SPVM_RUNTIME* runtime, SPVM_RUNTIME_FIELD* field) {
48            
49 3026           return field->offset;
50             }
51              
52 784           SPVM_RUNTIME_BASIC_TYPE* SPVM_API_FIELD_get_basic_type(SPVM_RUNTIME* runtime, SPVM_RUNTIME_FIELD* field) {
53            
54 784           return field->basic_type;
55             }
56              
57 0           int32_t SPVM_API_FIELD_get_type_dimension(SPVM_RUNTIME* runtime, SPVM_RUNTIME_FIELD* field) {
58            
59 0           return field->type_dimension;
60             }
61              
62 0           int32_t SPVM_API_FIELD_get_type_flag(SPVM_RUNTIME* runtime, SPVM_RUNTIME_FIELD* field) {
63            
64 0           return field->type_flag;
65             }
66              
67 0           SPVM_RUNTIME_BASIC_TYPE* SPVM_API_FIELD_get_current_basic_type(SPVM_RUNTIME* runtime, SPVM_RUNTIME_FIELD* field) {
68            
69 0           return field->current_basic_type;
70             }