/home/travis/build/MoarVM/MoarVM/src/6model/reprs/MVMNull.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 MVMNull_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, &MVMNull_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(MVMNull); |
15 | 144 | }); |
16 | 144 | |
17 | 144 | return st->WHAT; |
18 | 144 | } |
19 | | |
20 | | /* Creates a new instance based on the type object. */ |
21 | 0 | static MVMObject * allocate(MVMThreadContext *tc, MVMSTable *st) { |
22 | 0 | MVM_exception_throw_adhoc(tc, "Cannot create an instance of null type"); |
23 | 0 | } |
24 | | |
25 | | /* Copies the body of one object to another. */ |
26 | 0 | static void copy_to(MVMThreadContext *tc, MVMSTable *st, void *src, MVMObject *dest_root, void *dest) { |
27 | 0 | MVM_exception_throw_adhoc(tc, "Cannot clone null type"); |
28 | 0 | } |
29 | | |
30 | | static const MVMStorageSpec storage_spec = { |
31 | | MVM_STORAGE_SPEC_REFERENCE, /* inlineable */ |
32 | | 0, /* bits */ |
33 | | 0, /* align */ |
34 | | MVM_STORAGE_SPEC_BP_NONE, /* boxed_primitive */ |
35 | | 0, /* can_box */ |
36 | | 0, /* is_unsigned */ |
37 | | }; |
38 | | |
39 | | /* Gets the storage specification for this representation. */ |
40 | 6 | static const MVMStorageSpec * get_storage_spec(MVMThreadContext *tc, MVMSTable *st) { |
41 | 6 | return &storage_spec; |
42 | 6 | } |
43 | | |
44 | | /* Compose the representation. */ |
45 | 0 | static void compose(MVMThreadContext *tc, MVMSTable *st, MVMObject *info) { |
46 | 0 | MVM_exception_throw_adhoc(tc, "Cannot compose null type"); |
47 | 0 | } |
48 | | |
49 | | /* Set the size of the STable. */ |
50 | 0 | static void deserialize_stable_size(MVMThreadContext *tc, MVMSTable *st, MVMSerializationReader *reader) { |
51 | 0 | st->size = sizeof(MVMNull); |
52 | 0 | } |
53 | | |
54 | | /* Initializes the representation. */ |
55 | 144 | const MVMREPROps * MVMNull_initialize(MVMThreadContext *tc) { |
56 | 144 | return &MVMNull_this_repr; |
57 | 144 | } |
58 | | |
59 | | static const MVMREPROps MVMNull_this_repr = { |
60 | | type_object_for, |
61 | | allocate, |
62 | | NULL, /* initialize */ |
63 | | copy_to, |
64 | | MVM_REPR_DEFAULT_ATTR_FUNCS, |
65 | | MVM_REPR_DEFAULT_BOX_FUNCS, |
66 | | MVM_REPR_DEFAULT_POS_FUNCS, |
67 | | MVM_REPR_DEFAULT_ASS_FUNCS, |
68 | | MVM_REPR_DEFAULT_ELEMS, |
69 | | get_storage_spec, |
70 | | NULL, /* change_type */ |
71 | | NULL, /* serialize */ |
72 | | NULL, /* deserialize */ |
73 | | NULL, /* serialize_repr_data */ |
74 | | NULL, /* deserialize_repr_data */ |
75 | | deserialize_stable_size, |
76 | | NULL, /* gc_mark */ |
77 | | NULL, /* gc_free */ |
78 | | NULL, /* gc_cleanup */ |
79 | | NULL, /* gc_mark_repr_data */ |
80 | | NULL, /* gc_free_repr_data */ |
81 | | compose, |
82 | | NULL, /* spesh */ |
83 | | "Null", /* name */ |
84 | | MVM_REPR_ID_MVMNull, |
85 | | NULL, /* unmanaged_size */ |
86 | | NULL, /* describe_refs */ |
87 | | }; |