/home/travis/build/MoarVM/MoarVM/src/6model/reprs/MVMException.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 MVMException_this_repr; |
5 | | |
6 | | /* Creates a new type object of this representation, and associates it with |
7 | | * the given HOW. Also sets the invocation protocol handler in the STable. */ |
8 | 145 | static MVMObject * type_object_for(MVMThreadContext *tc, MVMObject *HOW) { |
9 | 145 | MVMSTable *st = MVM_gc_allocate_stable(tc, &MVMException_this_repr, HOW); |
10 | 145 | |
11 | 145 | MVMROOT(tc, st, { |
12 | 145 | MVMObject *obj = MVM_gc_allocate_type_object(tc, st); |
13 | 145 | MVM_ASSIGN_REF(tc, &(st->header), st->WHAT, obj); |
14 | 145 | st->size = sizeof(MVMException); |
15 | 145 | }); |
16 | 145 | |
17 | 145 | return st->WHAT; |
18 | 145 | } |
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 | MVM_panic(MVM_exitcode_NYI, "MVMException copy_to NYI"); |
23 | 0 | } |
24 | | |
25 | | /* Adds held objects to the GC worklist. */ |
26 | 1 | static void gc_mark(MVMThreadContext *tc, MVMSTable *st, void *data, MVMGCWorklist *worklist) { |
27 | 1 | MVMExceptionBody *body = (MVMExceptionBody *)data; |
28 | 1 | MVM_gc_worklist_add(tc, worklist, &body->message); |
29 | 1 | MVM_gc_worklist_add(tc, worklist, &body->payload); |
30 | 1 | MVM_gc_worklist_add(tc, worklist, &body->origin); |
31 | 1 | } |
32 | | |
33 | | static const MVMStorageSpec storage_spec = { |
34 | | MVM_STORAGE_SPEC_REFERENCE, /* inlineable */ |
35 | | 0, /* bits */ |
36 | | 0, /* align */ |
37 | | MVM_STORAGE_SPEC_BP_NONE, /* boxed_primitive */ |
38 | | 0, /* can_box */ |
39 | | 0, /* is_unsigned */ |
40 | | }; |
41 | | |
42 | | |
43 | | /* Gets the storage specification for this representation. */ |
44 | 51 | static const MVMStorageSpec * get_storage_spec(MVMThreadContext *tc, MVMSTable *st) { |
45 | 51 | return &storage_spec; |
46 | 51 | } |
47 | | |
48 | | /* Compose the representation. */ |
49 | 1 | static void compose(MVMThreadContext *tc, MVMSTable *st, MVMObject *info) { |
50 | 1 | /* Nothing to do for this REPR. */ |
51 | 1 | } |
52 | | |
53 | | /* Initializes the representation. */ |
54 | 144 | const MVMREPROps * MVMException_initialize(MVMThreadContext *tc) { |
55 | 144 | return &MVMException_this_repr; |
56 | 144 | } |
57 | | |
58 | | static const MVMREPROps MVMException_this_repr = { |
59 | | type_object_for, |
60 | | MVM_gc_allocate_object, |
61 | | NULL, /* initialize */ |
62 | | copy_to, |
63 | | MVM_REPR_DEFAULT_ATTR_FUNCS, |
64 | | MVM_REPR_DEFAULT_BOX_FUNCS, |
65 | | MVM_REPR_DEFAULT_POS_FUNCS, |
66 | | MVM_REPR_DEFAULT_ASS_FUNCS, |
67 | | MVM_REPR_DEFAULT_ELEMS, |
68 | | get_storage_spec, |
69 | | NULL, /* change_type */ |
70 | | NULL, /* serialize */ |
71 | | NULL, /* deserialize */ |
72 | | NULL, /* serialize_repr_data */ |
73 | | NULL, /* deserialize_repr_data */ |
74 | | NULL, /* deserialize_stable_size */ |
75 | | gc_mark, |
76 | | NULL, /* gc_free */ |
77 | | NULL, /* gc_cleanup */ |
78 | | NULL, /* gc_mark_repr_data */ |
79 | | NULL, /* gc_free_repr_data */ |
80 | | compose, |
81 | | NULL, /* spesh */ |
82 | | "VMException", /* name */ |
83 | | MVM_REPR_ID_MVMException, |
84 | | NULL, /* unmanaged_size */ |
85 | | NULL, /* describe_refs */ |
86 | | }; |