Coverage Report

Created: 2017-04-15 07:07

/home/travis/build/MoarVM/MoarVM/src/6model/reprs/P6str.c
Line
Count
Source (jump to first uncovered line)
1
#include "moar.h"
2
3
/* This representation's function pointer table. */
4
static const MVMREPROps P6str_this_repr;
5
6
/* Creates a new type object of this representation, and associates it with
7
 * the given HOW. */
8
134
static MVMObject * type_object_for(MVMThreadContext *tc, MVMObject *HOW) {
9
134
    MVMSTable *st  = MVM_gc_allocate_stable(tc, &P6str_this_repr, HOW);
10
134
11
134
    MVMROOT(tc, st, {
12
134
        MVMObject *obj = MVM_gc_allocate_type_object(tc, st);
13
134
        MVM_ASSIGN_REF(tc, &(st->header), st->WHAT, obj);
14
134
        st->size = sizeof(MVMP6str);
15
134
    });
16
134
17
134
    return st->WHAT;
18
134
}
19
20
/* Copies the body of one object to another. */
21
0
static void copy_to(MVMThreadContext *tc, MVMSTable *st, void *src, MVMObject *dest_root, void *dest) {
22
0
    MVMP6strBody *src_body  = (MVMP6strBody *)src;
23
0
    MVMP6strBody *dest_body = (MVMP6strBody *)dest;
24
0
    MVM_ASSIGN_REF(tc, &(dest_root->header), dest_body->value, src_body->value);
25
0
}
26
27
2.61M
static void set_str(MVMThreadContext *tc, MVMSTable *st, MVMObject *root, void *data, MVMString *value) {
28
2.61M
    MVM_ASSIGN_REF(tc, &(root->header), ((MVMP6strBody *)data)->value, value);
29
2.61M
}
30
31
4.44M
static MVMString * get_str(MVMThreadContext *tc, MVMSTable *st, MVMObject *root, void *data) {
32
4.44M
    return ((MVMP6strBody *)data)->value;
33
4.44M
}
34
35
static const MVMStorageSpec storage_spec = {
36
    MVM_STORAGE_SPEC_INLINED, /* inlineable */
37
    sizeof(MVMString*) * 8,   /* bits */
38
    ALIGNOF(void *),               /* align */
39
    MVM_STORAGE_SPEC_BP_STR,       /* boxed_primitive */
40
    MVM_STORAGE_SPEC_CAN_BOX_STR,  /* can_box */
41
    0,                          /* is_unsigned */
42
};
43
44
/* Gets the storage specification for this representation. */
45
1.38M
static const MVMStorageSpec * get_storage_spec(MVMThreadContext *tc, MVMSTable *st) {
46
1.38M
    return &storage_spec;
47
1.38M
}
48
49
/* Compose the representation. */
50
4
static void compose(MVMThreadContext *tc, MVMSTable *st, MVMObject *info) {
51
4
}
52
53
/* Called by the VM to mark any GCable items. */
54
674k
static void gc_mark(MVMThreadContext *tc, MVMSTable *st, void *data, MVMGCWorklist *worklist) {
55
674k
    MVM_gc_worklist_add(tc, worklist, &((MVMP6strBody *)data)->value);
56
674k
}
57
58
/* Set the size of the STable. */
59
130
static void deserialize_stable_size(MVMThreadContext *tc, MVMSTable *st, MVMSerializationReader *reader) {
60
130
    st->size = sizeof(MVMP6str);
61
130
}
62
63
4
static void deserialize(MVMThreadContext *tc, MVMSTable *st, MVMObject *root, void *data, MVMSerializationReader *reader) {
64
4
    MVM_ASSIGN_REF(tc, &(root->header), ((MVMP6strBody *)data)->value,
65
4
        MVM_serialization_read_str(tc, reader));
66
4
}
67
68
4
static void serialize(MVMThreadContext *tc, MVMSTable *st, void *data, MVMSerializationWriter *writer) {
69
4
    MVM_serialization_write_str(tc, writer, ((MVMP6strBody *)data)->value);
70
4
}
71
72
/* Initializes the representation. */
73
130
const MVMREPROps * MVMP6str_initialize(MVMThreadContext *tc) {
74
130
    return &P6str_this_repr;
75
130
}
76
77
static const MVMREPROps P6str_this_repr = {
78
    type_object_for,
79
    MVM_gc_allocate_object,
80
    NULL, /* initialize */
81
    copy_to,
82
    MVM_REPR_DEFAULT_ATTR_FUNCS,
83
    {
84
        MVM_REPR_DEFAULT_SET_INT,
85
        MVM_REPR_DEFAULT_GET_INT,
86
        MVM_REPR_DEFAULT_SET_NUM,
87
        MVM_REPR_DEFAULT_GET_NUM,
88
        set_str,
89
        get_str,
90
        MVM_REPR_DEFAULT_SET_UINT,
91
        MVM_REPR_DEFAULT_GET_UINT,
92
        MVM_REPR_DEFAULT_GET_BOXED_REF
93
    },    /* box_funcs */
94
    MVM_REPR_DEFAULT_POS_FUNCS,
95
    MVM_REPR_DEFAULT_ASS_FUNCS,
96
    MVM_REPR_DEFAULT_ELEMS,
97
    get_storage_spec,
98
    NULL, /* change_type */
99
    serialize,
100
    deserialize, /* deserialize */
101
    NULL, /* serialize_repr_data */
102
    NULL, /* deserialize_repr_data */
103
    deserialize_stable_size,
104
    gc_mark,
105
    NULL, /* gc_free */
106
    NULL, /* gc_cleanup */
107
    NULL, /* gc_mark_repr_data */
108
    NULL, /* gc_free_repr_data */
109
    compose,
110
    NULL, /* spesh */
111
    "P6str", /* name */
112
    MVM_REPR_ID_P6str,
113
    NULL, /* unmanaged_size */
114
    NULL, /* describe_refs */
115
};