/home/travis/build/MoarVM/MoarVM/src/6model/reprs/KnowHOWAttributeREPR.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 KnowHOWAttributeREPR_this_repr; |
5 | | |
6 | | /* Creates a new type object of this representation, and associates it with |
7 | | * the given HOW. */ |
8 | 144 | static MVMObject * type_object_for(MVMThreadContext *tc, MVMObject *HOW) { |
9 | 144 | MVMSTable *st = MVM_gc_allocate_stable(tc, &KnowHOWAttributeREPR_this_repr, HOW); |
10 | 144 | |
11 | 144 | MVMROOT(tc, st, { |
12 | 144 | MVMObject *obj = MVM_gc_allocate_type_object(tc, st); |
13 | 144 | MVM_ASSIGN_REF(tc, &(st->header), st->WHAT, obj); |
14 | 144 | st->size = sizeof(MVMKnowHOWAttributeREPR); |
15 | 144 | }); |
16 | 144 | |
17 | 144 | return st->WHAT; |
18 | 144 | } |
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 | MVMKnowHOWAttributeREPRBody *src_body = (MVMKnowHOWAttributeREPRBody *)src; |
23 | 0 | MVMKnowHOWAttributeREPRBody *dest_body = (MVMKnowHOWAttributeREPRBody *)dest; |
24 | 0 | MVM_ASSIGN_REF(tc, &(dest_root->header), dest_body->name, src_body->name); |
25 | 0 | MVM_ASSIGN_REF(tc, &(dest_root->header), dest_body->type, src_body->type); |
26 | 0 | dest_body->box_target = src_body->box_target; |
27 | 0 | } |
28 | | |
29 | | static const MVMStorageSpec storage_spec = { |
30 | | MVM_STORAGE_SPEC_REFERENCE, /* inlineable */ |
31 | | 0, /* bits */ |
32 | | 0, /* align */ |
33 | | MVM_STORAGE_SPEC_BP_NONE, /* boxed_primitive */ |
34 | | 0, /* can_box */ |
35 | | 0, /* is_unsigned */ |
36 | | }; |
37 | | |
38 | | /* Gets the storage specification for this representation. */ |
39 | 0 | static const MVMStorageSpec * get_storage_spec(MVMThreadContext *tc, MVMSTable *st) { |
40 | 0 | return &storage_spec; |
41 | 0 | } |
42 | | |
43 | | /* Adds held objects to the GC worklist. */ |
44 | 0 | static void gc_mark(MVMThreadContext *tc, MVMSTable *st, void *data, MVMGCWorklist *worklist) { |
45 | 0 | MVMKnowHOWAttributeREPRBody *body = (MVMKnowHOWAttributeREPRBody *)data; |
46 | 0 | MVM_gc_worklist_add(tc, worklist, &body->name); |
47 | 0 | MVM_gc_worklist_add(tc, worklist, &body->type); |
48 | 0 | } |
49 | | |
50 | | /* Compose the representation. */ |
51 | 0 | static void compose(MVMThreadContext *tc, MVMSTable *st, MVMObject *info) { |
52 | 0 | /* Nothing to do for this REPR. */ |
53 | 0 | } |
54 | | |
55 | | /* Set the size of the STable. */ |
56 | 0 | static void deserialize_stable_size(MVMThreadContext *tc, MVMSTable *st, MVMSerializationReader *reader) { |
57 | 0 | st->size = sizeof(MVMKnowHOWAttributeREPR); |
58 | 0 | } |
59 | | |
60 | | /* Serializes the data. */ |
61 | 1 | static void serialize(MVMThreadContext *tc, MVMSTable *st, void *data, MVMSerializationWriter *writer) { |
62 | 1 | MVMKnowHOWAttributeREPRBody *body = (MVMKnowHOWAttributeREPRBody *)data; |
63 | 1 | MVM_serialization_write_str(tc, writer, body->name); |
64 | 1 | } |
65 | | |
66 | | /* Deserializes the data. */ |
67 | 4.44k | static void deserialize(MVMThreadContext *tc, MVMSTable *st, MVMObject *root, void *data, MVMSerializationReader *reader) { |
68 | 4.44k | MVMKnowHOWAttributeREPRBody *body = (MVMKnowHOWAttributeREPRBody *)data; |
69 | 4.44k | MVM_ASSIGN_REF(tc, &(root->header), body->name, MVM_serialization_read_str(tc, reader)); |
70 | 4.44k | MVM_ASSIGN_REF(tc, &(root->header), body->type, tc->instance->KnowHOW); |
71 | 4.44k | } |
72 | | |
73 | | /* Initializes the representation. */ |
74 | 144 | const MVMREPROps * MVMKnowHOWAttributeREPR_initialize(MVMThreadContext *tc) { |
75 | 144 | return &KnowHOWAttributeREPR_this_repr; |
76 | 144 | } |
77 | | |
78 | | static const MVMREPROps KnowHOWAttributeREPR_this_repr = { |
79 | | type_object_for, |
80 | | MVM_gc_allocate_object, |
81 | | NULL, /* initialize */ |
82 | | copy_to, |
83 | | MVM_REPR_DEFAULT_ATTR_FUNCS, |
84 | | MVM_REPR_DEFAULT_BOX_FUNCS, |
85 | | MVM_REPR_DEFAULT_POS_FUNCS, |
86 | | MVM_REPR_DEFAULT_ASS_FUNCS, |
87 | | MVM_REPR_DEFAULT_ELEMS, |
88 | | get_storage_spec, |
89 | | NULL, /* change_type */ |
90 | | serialize, |
91 | | deserialize, |
92 | | NULL, /* serialize_repr_data */ |
93 | | NULL, /* deserialize_repr_data */ |
94 | | deserialize_stable_size, |
95 | | gc_mark, |
96 | | NULL, /* gc_free */ |
97 | | NULL, /* gc_cleanup */ |
98 | | NULL, /* gc_mark_repr_data */ |
99 | | NULL, /* gc_free_repr_data */ |
100 | | compose, |
101 | | NULL, /* spesh */ |
102 | | "KnowHOWAttributeREPR", /* name */ |
103 | | MVM_REPR_ID_KnowHOWAttributeREPR, |
104 | | NULL, /* unmanaged_size */ |
105 | | NULL, /* describe_refs */ |
106 | | }; |