Coverage Report

Created: 2018-07-03 15:31

/home/travis/build/MoarVM/MoarVM/src/mast/nodes.h
Line
Count
Source (jump to first uncovered line)
1
/* MAST::CompUnit */
2
typedef struct {
3
    MVMP6opaque  p6o_header;
4
    MVMObject   *frames;
5
    MVMString   *hll;
6
    MVMObject   *main_frame;
7
    MVMObject   *load_frame;
8
    MVMObject   *deserialize_frame;
9
    MVMObject   *sc_handles;
10
    MVMObject   *sc_lookup;
11
    MVMObject   *extop_sigs;
12
    MVMObject   *extop_idx;
13
    MVMObject   *extop_names;
14
} MAST_CompUnit;
15
16
/* MAST::Frame */
17
typedef struct {
18
    MVMP6opaque  p6o_header;
19
    MVMString   *cuuid;
20
    MVMString   *name;
21
    MVMObject   *lexical_types;
22
    MVMObject   *lexical_names;
23
    MVMObject   *local_types;
24
    MVMObject   *instructions;
25
    MVMObject   *outer;
26
    MVMObject   *lexical_map;
27
    MVMint64     flags;
28
    MVMint64     index;
29
    MVMObject   *static_lex_values;
30
    MVMint64     code_obj_sc_dep_idx;
31
    MVMint64     code_obj_sc_idx;
32
} MAST_Frame;
33
34
/* MAST::Op */
35
typedef struct {
36
    MVMP6opaque  p6o_header;
37
    MVMint64     op;
38
    MVMObject   *operands;
39
} MAST_Op;
40
41
/* MAST::ExtOp */
42
typedef struct {
43
    MVMP6opaque  p6o_header;
44
    MVMint64     op;
45
    MVMObject   *operands;
46
    MVMString   *name;
47
} MAST_ExtOp;
48
49
/* MAST::SVal */
50
typedef struct {
51
    MVMP6opaque  p6o_header;
52
    MVMString   *value;
53
} MAST_SVal;
54
55
/* MAST::IVal */
56
typedef struct {
57
    MVMP6opaque p6o_header;
58
    MVMint64    value;
59
} MAST_IVal;
60
61
/* MAST::NVal */
62
typedef struct {
63
    MVMP6opaque p6o_header;
64
    MVMnum64    value;
65
} MAST_NVal;
66
67
/* MAST::Label */
68
typedef struct {
69
    MVMP6opaque  p6o_header;
70
} MAST_Label;
71
72
/* MAST::Local */
73
typedef struct {
74
    MVMP6opaque p6o_header;
75
    MVMint64    index;
76
} MAST_Local;
77
78
/* MAST::Lexical */
79
typedef struct {
80
    MVMP6opaque p6o_header;
81
    MVMint64    index;
82
    MVMint64    frames_out;
83
} MAST_Lexical;
84
85
/* MAST::Call */
86
typedef struct {
87
    MVMP6opaque  p6o_header;
88
    MVMObject   *target;
89
    MVMObject   *flags;
90
    MVMObject   *args;
91
    MVMObject   *result;
92
    MVMint64     op;
93
} MAST_Call;
94
95
/* MAST::Annotated */
96
typedef struct {
97
    MVMP6opaque  p6o_header;
98
    MVMString   *file;
99
    MVMint64     line;
100
    MVMObject   *instructions;
101
} MAST_Annotated;
102
103
/* MAST::HandlerScope */
104
typedef struct {
105
    MVMP6opaque  p6o_header;
106
    MVMObject   *instructions;
107
    MVMint64     category_mask;
108
    MVMint64     action;
109
    MVMObject   *goto_label;
110
    MVMObject   *block_local;
111
    MVMObject   *label_local;
112
} MAST_HandlerScope;
113
114
/* Node types structure. */
115
typedef struct _MASTNodeTypes {
116
    MVMObject *CompUnit;
117
    MVMObject *Frame;
118
    MVMObject *Op;
119
    MVMObject *ExtOp;
120
    MVMObject *SVal;
121
    MVMObject *IVal;
122
    MVMObject *NVal;
123
    MVMObject *Label;
124
    MVMObject *Local;
125
    MVMObject *Lexical;
126
    MVMObject *Call;
127
    MVMObject *Annotated;
128
    MVMObject *HandlerScope;
129
} MASTNodeTypes;
130
131
/* This means we can talk about MASTNode in the compiler, not MVMObject. */
132
typedef MVMObject MASTNode;
133
134
/* Similar for strings. */
135
typedef MVMString VMSTR;
136
137
/* Way of talking about the interpreter. */
138
#define VM MVMThreadContext *tc
139
2.00M
#define vm tc
140
141
/* Some macros for getting at and examining nodes data. */
142
986k
#define ISTYPE(VM, s, t)            (STABLE(s) == STABLE(t))
143
0
#define DIE(vm, msg, ...)           MVM_exception_throw_adhoc(tc, msg, ## __VA_ARGS__)
144
1.21k
#define GET_CompUnit(n)             ((MAST_CompUnit *)n)
145
4.52k
#define GET_Frame(n)                ((MAST_Frame *)n)
146
248k
#define GET_Op(n)                   ((MAST_Op *)n)
147
0
#define GET_ExtOp(n)                ((MAST_ExtOp *)n)
148
51.2k
#define GET_Label(n)                ((MAST_Label *)n)
149
435k
#define GET_Local(n)                ((MAST_Local *)n)
150
4.26k
#define GET_Lexical(n)              ((MAST_Lexical *)n)
151
79.4k
#define GET_IVal(n)                 ((MAST_IVal *)n)
152
498
#define GET_NVal(n)                 ((MAST_NVal *)n)
153
42.1k
#define GET_SVal(n)                 ((MAST_SVal *)n)
154
14.9k
#define GET_Call(n)                 ((MAST_Call *)n)
155
11.4k
#define GET_Annotated(n)            ((MAST_Annotated *)n)
156
431
#define GET_HandlerScope(n)         ((MAST_HandlerScope *)n)
157
#define NEWLIST_I(vm)               (MVM_repr_alloc_init(tc, tc->instance->boot_types.BOOTIntArray))
158
1.21k
#define NEWLIST_S(vm)               (MVM_repr_alloc_init(tc, tc->instance->boot_types.BOOTStrArray))
159
329k
#define ELEMS(vm, arr)              ((unsigned int )MVM_repr_elems(vm, arr))
160
900k
#define ATPOS(vm, arr, i)           (MVM_repr_at_pos_o(vm, arr, i))
161
4.35k
#define ATPOS_I(vm, arr, i)         (MVM_repr_at_pos_i(vm, arr, i))
162
34.0k
#define ATPOS_S(vm, arr, i)         (MVM_repr_at_pos_s(vm, arr, i))
163
53.8k
#define ATPOS_I_C(vm, arr, i)       (MVM_repr_get_int(vm, MVM_repr_at_pos_o(vm, arr, i)))
164
5.44k
#define ATPOS_S_C(vm, arr, i)       (MVM_repr_get_str(vm, MVM_repr_at_pos_o(vm, arr, i)))
165
#define BINDPOS(vm, arr, i, v)      (MVM_repr_bind_pos_o(vm, arr, i, v))
166
#define BINDPOS_I(vm, arr, i, v)    (MVM_repr_bind_pos_i(vm, arr, i, v))
167
34.0k
#define BINDPOS_S(vm, arr, i, v)    (MVM_repr_bind_pos_s(vm, arr, i, v))
168
1.21k
#define NEWHASH(vm)                 (MVM_repr_alloc_init(tc, tc->instance->boot_types.BOOTHash))
169
#define HASHELEMS(vm, hash)         ((unsigned int )MVM_repr_elems(vm, hash))
170
#define ATKEY(vm, hash, k)          (MVM_repr_at_key_o(vm, hash, k))
171
38.3k
#define ATKEY_I(vm, hash, k)        (MVM_repr_get_int(tc, MVM_repr_at_key_o(vm, hash, k)))
172
#define BINDKEY(vm, hash, k, v)     (MVM_repr_bind_key_o(vm, hash, k, v))
173
34.0k
#define BINDKEY_I(vm, hash, k, v)   do {                                          \
174
34.0k
    MVMObject *boxed = MVM_repr_box_int(tc, tc->instance->boot_types.BOOTInt, v); \
175
34.0k
    MVM_repr_bind_key_o(vm, hash, k, boxed);                                      \
176
34.0k
} while (0)
177
72.4k
#define EXISTSKEY(vm, hash, k)      (MVM_repr_exists_key(vm, hash, k))
178
#define DELETEKEY(vm, hash, k)      (MVM_repr_delete_key(vm, hash, k))
179
97
#define EMPTY_STRING(vm)            (tc->instance->str_consts.empty)
180
1.21k
#define VM_STRING_IS_NULL(s)        (s == NULL)
181
65.0k
#define VM_OBJ_IS_NULL(o)           (o == NULL)
182
0
#define VM_STRING_TO_C_STRING(vm, s) (MVM_string_ascii_encode_any(tc, s))
183
184
0
#define DIE_FREE(vm, waste, msg, ...) MVM_exception_throw_adhoc_free(tc, waste, msg, ## __VA_ARGS__)