1 /* context.h
2  *  Copyright (C) 2009-2011, Parrot Foundation.
3  *  Overview:
4  *     Context
5  */
6 
7 #ifndef PARROT_CONTEXT_H_GUARD
8 #define PARROT_CONTEXT_H_GUARD
9 
10 #include "parrot/string.h"
11 #include "parrot/compiler.h"
12 
13 struct PackFile_ConstTable;
14 
15 typedef union {
16     PMC         **regs_p;
17     STRING      **regs_s;
18 } Regs_ps;
19 
20 typedef union {
21     FLOATVAL     *regs_n;
22     INTVAL       *regs_i;
23 } Regs_ni;
24 
25 #include "pmc/pmc_callcontext.h"
26 
27 typedef struct Parrot_CallContext_attributes Parrot_Context;
28 
29 #define CONTEXT_STRUCT(c) (PMC_data_typed((c), Parrot_Context *))
30 /* ((Parrot_Context *)ctx->data)->n_regs_used */
31 #define PCC_GET_REGS_USED(ctx, type) CONTEXT_STRUCT(ctx)->n_regs_used[type]
32 
33 /*
34  * Macros to make accessing registers more convenient/readable.
35  */
36 
37 #ifndef NDEBUG
38 #  define CTX_REG_PMC(i, p, x) (*Parrot_pcc_get_PMC_reg((i), (p), (x)))
39 #  define CTX_REG_STR(i, p, x) (*Parrot_pcc_get_STRING_reg((i), (p), (x)))
40 #  define CTX_REG_NUM(i, p, x) (*Parrot_pcc_get_FLOATVAL_reg((i), (p), (x)))
41 #  define CTX_REG_INT(i, p, x) (*Parrot_pcc_get_INTVAL_reg((i), (p), (x)))
42 #else /* NDEBUG */
43 /* Manually inlined macros. Used in optimized builds */
44 #  define CTX_REG_PMC(i, p, x) (CONTEXT_STRUCT(p)->bp_ps.regs_p[-1L - (x)])
45 #  define CTX_REG_STR(i, p, x) (CONTEXT_STRUCT(p)->bp_ps.regs_s[(x)])
46 #  define CTX_REG_NUM(i, p, x) (CONTEXT_STRUCT(p)->bp.regs_n[-1L - (x)])
47 #  define CTX_REG_INT(i, p, x) (CONTEXT_STRUCT(p)->bp.regs_i[(x)])
48 #endif
49 
50 #define REG_NUM(interp, x) CTX_REG_NUM((interp), (interp)->ctx, (x))
51 #define REG_INT(interp, x) CTX_REG_INT((interp), (interp)->ctx, (x))
52 #define REG_PMC(interp, x) CTX_REG_PMC((interp), (interp)->ctx, (x))
53 #define REG_STR(interp, x) CTX_REG_STR((interp), (interp)->ctx, (x))
54 
55 
56 #define REGNO_INT 0
57 #define REGNO_NUM 1
58 #define REGNO_STR 2
59 #define REGNO_PMC 3
60 
61 /* Context accessors functions */
62 
63 /*
64  * For optimized builds we provide macros which directly poke into
65  * Parrot_Context.
66  */
67 
68 /* HEADERIZER BEGIN: src/call/context_accessors.c */
69 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
70 
71 PARROT_EXPORT
72 UINTVAL Parrot_pcc_dec_recursion_depth_func(PARROT_INTERP, ARGIN(PMC *ctx))
73         __attribute__nonnull__(2);
74 
75 PARROT_EXPORT
76 void Parrot_pcc_errors_off_func(PARROT_INTERP,
77     ARGIN(PMC *ctx),
78     UINTVAL flags)
79         __attribute__nonnull__(2);
80 
81 PARROT_EXPORT
82 void Parrot_pcc_errors_on_func(PARROT_INTERP,
83     ARGIN(PMC *ctx),
84     UINTVAL flags)
85         __attribute__nonnull__(2);
86 
87 PARROT_EXPORT
88 PARROT_PURE_FUNCTION
89 UINTVAL Parrot_pcc_errors_test_func(PARROT_INTERP,
90     ARGIN(PMC *ctx),
91     UINTVAL flags)
92         __attribute__nonnull__(2);
93 
94 PARROT_EXPORT
95 PARROT_PURE_FUNCTION
96 PARROT_CAN_RETURN_NULL
97 PMC* Parrot_pcc_get_caller_ctx_func(PARROT_INTERP, ARGIN(const PMC *ctx))
98         __attribute__nonnull__(2);
99 
100 PARROT_EXPORT
101 PARROT_CAN_RETURN_NULL
102 PARROT_PURE_FUNCTION
103 Parrot_Context* Parrot_pcc_get_context_struct_func(PARROT_INTERP,
104     ARGIN_NULLOK(PMC *ctx));
105 
106 PARROT_EXPORT
107 PARROT_PURE_FUNCTION
108 PARROT_CAN_RETURN_NULL
109 PMC* Parrot_pcc_get_continuation_func(PARROT_INTERP, ARGIN(const PMC *ctx))
110         __attribute__nonnull__(2);
111 
112 PARROT_EXPORT
113 PARROT_PURE_FUNCTION
114 PARROT_CAN_RETURN_NULL
115 PMC* Parrot_pcc_get_handlers_func(PARROT_INTERP, ARGIN(const PMC *ctx))
116         __attribute__nonnull__(2);
117 
118 PARROT_EXPORT
119 PARROT_PURE_FUNCTION
120 INTVAL Parrot_pcc_get_HLL_func(PARROT_INTERP, ARGIN(const PMC *ctx))
121         __attribute__nonnull__(2);
122 
123 PARROT_EXPORT
124 PARROT_PURE_FUNCTION
125 PARROT_CANNOT_RETURN_NULL
126 PMC* Parrot_pcc_get_lex_pad_func(PARROT_INTERP, ARGIN(const PMC *ctx))
127         __attribute__nonnull__(2);
128 
129 PARROT_EXPORT
130 PARROT_PURE_FUNCTION
131 PARROT_CAN_RETURN_NULL
132 PMC* Parrot_pcc_get_namespace_func(PARROT_INTERP, ARGIN(const PMC *ctx))
133         __attribute__nonnull__(2);
134 
135 PARROT_EXPORT
136 PARROT_PURE_FUNCTION
137 PARROT_CAN_RETURN_NULL
138 FLOATVAL Parrot_pcc_get_num_constant_func(PARROT_INTERP,
139     ARGIN(const PMC *ctx),
140     INTVAL idx)
141         __attribute__nonnull__(2);
142 
143 PARROT_EXPORT
144 PARROT_CANNOT_RETURN_NULL
145 PARROT_PURE_FUNCTION
146 FLOATVAL * Parrot_pcc_get_num_constants_func(PARROT_INTERP,
147     ARGIN(const PMC *ctx))
148         __attribute__nonnull__(2);
149 
150 PARROT_EXPORT
151 PARROT_PURE_FUNCTION
152 PARROT_CAN_RETURN_NULL
153 PMC* Parrot_pcc_get_outer_ctx_func(PARROT_INTERP, ARGIN(const PMC *ctx))
154         __attribute__nonnull__(2);
155 
156 PARROT_EXPORT
157 PARROT_PURE_FUNCTION
158 PARROT_CAN_RETURN_NULL
159 opcode_t* Parrot_pcc_get_pc_func(PARROT_INTERP, ARGIN(const PMC *ctx))
160         __attribute__nonnull__(2);
161 
162 PARROT_EXPORT
163 PARROT_PURE_FUNCTION
164 PARROT_CAN_RETURN_NULL
165 PMC* Parrot_pcc_get_pmc_constant_func(PARROT_INTERP,
166     ARGIN(const PMC *ctx),
167     INTVAL idx)
168         __attribute__nonnull__(2);
169 
170 PARROT_EXPORT
171 PARROT_CANNOT_RETURN_NULL
172 PARROT_PURE_FUNCTION
173 PMC ** Parrot_pcc_get_pmc_constants_func(PARROT_INTERP,
174     ARGIN(const PMC *ctx))
175         __attribute__nonnull__(2);
176 
177 PARROT_EXPORT
178 PARROT_PURE_FUNCTION
179 UINTVAL Parrot_pcc_get_recursion_depth_func(PARROT_INTERP,
180     ARGIN(const PMC *ctx))
181         __attribute__nonnull__(2);
182 
183 PARROT_EXPORT
184 PARROT_PURE_FUNCTION
185 PARROT_CAN_RETURN_NULL
186 PMC* Parrot_pcc_get_signature_func(PARROT_INTERP, ARGIN(const PMC *ctx))
187         __attribute__nonnull__(2);
188 
189 PARROT_EXPORT
190 PARROT_CANNOT_RETURN_NULL
191 PARROT_PURE_FUNCTION
192 STRING ** Parrot_pcc_get_str_constants_func(PARROT_INTERP,
193     ARGIN(const PMC *ctx))
194         __attribute__nonnull__(2);
195 
196 PARROT_EXPORT
197 PARROT_PURE_FUNCTION
198 PARROT_CAN_RETURN_NULL
199 STRING* Parrot_pcc_get_string_constant_func(PARROT_INTERP,
200     ARGIN(const PMC *ctx),
201     INTVAL idx)
202         __attribute__nonnull__(2);
203 
204 PARROT_EXPORT
205 UINTVAL Parrot_pcc_inc_recursion_depth_func(PARROT_INTERP, ARGIN(PMC *ctx))
206         __attribute__nonnull__(2);
207 
208 PARROT_EXPORT
209 void Parrot_pcc_set_caller_ctx_func(PARROT_INTERP,
210     ARGIN(PMC *ctx),
211     ARGIN(PMC *caller_ctx))
212         __attribute__nonnull__(1)
213         __attribute__nonnull__(2)
214         __attribute__nonnull__(3);
215 
216 PARROT_EXPORT
217 PARROT_CAN_RETURN_NULL
218 void Parrot_pcc_set_constants_func(PARROT_INTERP,
219     ARGIN(PMC *ctx),
220     ARGIN(const struct PackFile_ConstTable *ct))
221         __attribute__nonnull__(2)
222         __attribute__nonnull__(3);
223 
224 PARROT_EXPORT
225 void Parrot_pcc_set_continuation_func(PARROT_INTERP,
226     ARGIN(PMC *ctx),
227     ARGIN_NULLOK(PMC *_continuation))
228         __attribute__nonnull__(1)
229         __attribute__nonnull__(2);
230 
231 PARROT_EXPORT
232 void Parrot_pcc_set_handlers_func(PARROT_INTERP,
233     ARGIN(PMC *ctx),
234     ARGIN(PMC *handlers))
235         __attribute__nonnull__(1)
236         __attribute__nonnull__(2)
237         __attribute__nonnull__(3);
238 
239 PARROT_EXPORT
240 void Parrot_pcc_set_HLL_func(PARROT_INTERP, ARGIN(PMC *ctx), INTVAL hll)
241         __attribute__nonnull__(2);
242 
243 PARROT_EXPORT
244 void Parrot_pcc_set_lex_pad_func(PARROT_INTERP,
245     ARGIN(PMC *ctx),
246     ARGIN(PMC *lex_pad))
247         __attribute__nonnull__(1)
248         __attribute__nonnull__(2)
249         __attribute__nonnull__(3);
250 
251 PARROT_EXPORT
252 void Parrot_pcc_set_namespace_func(PARROT_INTERP,
253     ARGIN(PMC *ctx),
254     ARGIN_NULLOK(PMC *_namespace))
255         __attribute__nonnull__(1)
256         __attribute__nonnull__(2);
257 
258 PARROT_EXPORT
259 void Parrot_pcc_set_outer_ctx_func(PARROT_INTERP,
260     ARGIN(PMC *ctx),
261     ARGIN(PMC *outer_ctx))
262         __attribute__nonnull__(1)
263         __attribute__nonnull__(2)
264         __attribute__nonnull__(3);
265 
266 PARROT_EXPORT
267 void Parrot_pcc_set_pc_func(PARROT_INTERP,
268     ARGIN(const PMC *ctx),
269     ARGIN_NULLOK(opcode_t *pc))
270         __attribute__nonnull__(2);
271 
272 PARROT_EXPORT
273 UINTVAL Parrot_pcc_set_recursion_depth_func(PARROT_INTERP,
274     ARGIN(const PMC *ctx),
275     const int new_depth)
276         __attribute__nonnull__(2);
277 
278 PARROT_EXPORT
279 void Parrot_pcc_set_signature_func(PARROT_INTERP,
280     ARGIN(PMC *ctx),
281     ARGIN_NULLOK(PMC *sig_object))
282         __attribute__nonnull__(1)
283         __attribute__nonnull__(2);
284 
285 PARROT_EXPORT
286 void Parrot_pcc_trace_flags_off_func(PARROT_INTERP,
287     ARGIN(PMC *ctx),
288     UINTVAL flags)
289         __attribute__nonnull__(2);
290 
291 PARROT_EXPORT
292 void Parrot_pcc_trace_flags_on_func(PARROT_INTERP,
293     ARGIN(PMC *ctx),
294     UINTVAL flags)
295         __attribute__nonnull__(2);
296 
297 PARROT_EXPORT
298 PARROT_PURE_FUNCTION
299 UINTVAL Parrot_pcc_trace_flags_test_func(PARROT_INTERP,
300     ARGIN(PMC *ctx),
301     UINTVAL flags)
302         __attribute__nonnull__(2);
303 
304 PARROT_EXPORT
305 void Parrot_pcc_warnings_off_func(PARROT_INTERP,
306     ARGIN(PMC *ctx),
307     UINTVAL flags)
308         __attribute__nonnull__(2);
309 
310 PARROT_EXPORT
311 UINTVAL Parrot_pcc_warnings_on_func(PARROT_INTERP,
312     ARGIN(PMC *ctx),
313     UINTVAL flags)
314         __attribute__nonnull__(2);
315 
316 PARROT_EXPORT
317 PARROT_PURE_FUNCTION
318 UINTVAL Parrot_pcc_warnings_test_func(PARROT_INTERP,
319     ARGIN(const PMC *ctx),
320     UINTVAL flags)
321         __attribute__nonnull__(2);
322 
323 #define ASSERT_ARGS_Parrot_pcc_dec_recursion_depth_func \
324      __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
325        PARROT_ASSERT_ARG(ctx))
326 #define ASSERT_ARGS_Parrot_pcc_errors_off_func __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
327        PARROT_ASSERT_ARG(ctx))
328 #define ASSERT_ARGS_Parrot_pcc_errors_on_func __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
329        PARROT_ASSERT_ARG(ctx))
330 #define ASSERT_ARGS_Parrot_pcc_errors_test_func __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
331        PARROT_ASSERT_ARG(ctx))
332 #define ASSERT_ARGS_Parrot_pcc_get_caller_ctx_func \
333      __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
334        PARROT_ASSERT_ARG(ctx))
335 #define ASSERT_ARGS_Parrot_pcc_get_context_struct_func \
336      __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
337 #define ASSERT_ARGS_Parrot_pcc_get_continuation_func \
338      __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
339        PARROT_ASSERT_ARG(ctx))
340 #define ASSERT_ARGS_Parrot_pcc_get_handlers_func __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
341        PARROT_ASSERT_ARG(ctx))
342 #define ASSERT_ARGS_Parrot_pcc_get_HLL_func __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
343        PARROT_ASSERT_ARG(ctx))
344 #define ASSERT_ARGS_Parrot_pcc_get_lex_pad_func __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
345        PARROT_ASSERT_ARG(ctx))
346 #define ASSERT_ARGS_Parrot_pcc_get_namespace_func __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
347        PARROT_ASSERT_ARG(ctx))
348 #define ASSERT_ARGS_Parrot_pcc_get_num_constant_func \
349      __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
350        PARROT_ASSERT_ARG(ctx))
351 #define ASSERT_ARGS_Parrot_pcc_get_num_constants_func \
352      __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
353        PARROT_ASSERT_ARG(ctx))
354 #define ASSERT_ARGS_Parrot_pcc_get_outer_ctx_func __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
355        PARROT_ASSERT_ARG(ctx))
356 #define ASSERT_ARGS_Parrot_pcc_get_pc_func __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
357        PARROT_ASSERT_ARG(ctx))
358 #define ASSERT_ARGS_Parrot_pcc_get_pmc_constant_func \
359      __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
360        PARROT_ASSERT_ARG(ctx))
361 #define ASSERT_ARGS_Parrot_pcc_get_pmc_constants_func \
362      __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
363        PARROT_ASSERT_ARG(ctx))
364 #define ASSERT_ARGS_Parrot_pcc_get_recursion_depth_func \
365      __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
366        PARROT_ASSERT_ARG(ctx))
367 #define ASSERT_ARGS_Parrot_pcc_get_signature_func __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
368        PARROT_ASSERT_ARG(ctx))
369 #define ASSERT_ARGS_Parrot_pcc_get_str_constants_func \
370      __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
371        PARROT_ASSERT_ARG(ctx))
372 #define ASSERT_ARGS_Parrot_pcc_get_string_constant_func \
373      __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
374        PARROT_ASSERT_ARG(ctx))
375 #define ASSERT_ARGS_Parrot_pcc_inc_recursion_depth_func \
376      __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
377        PARROT_ASSERT_ARG(ctx))
378 #define ASSERT_ARGS_Parrot_pcc_set_caller_ctx_func \
379      __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
380        PARROT_ASSERT_ARG(interp) \
381     , PARROT_ASSERT_ARG(ctx) \
382     , PARROT_ASSERT_ARG(caller_ctx))
383 #define ASSERT_ARGS_Parrot_pcc_set_constants_func __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
384        PARROT_ASSERT_ARG(ctx) \
385     , PARROT_ASSERT_ARG(ct))
386 #define ASSERT_ARGS_Parrot_pcc_set_continuation_func \
387      __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
388        PARROT_ASSERT_ARG(interp) \
389     , PARROT_ASSERT_ARG(ctx))
390 #define ASSERT_ARGS_Parrot_pcc_set_handlers_func __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
391        PARROT_ASSERT_ARG(interp) \
392     , PARROT_ASSERT_ARG(ctx) \
393     , PARROT_ASSERT_ARG(handlers))
394 #define ASSERT_ARGS_Parrot_pcc_set_HLL_func __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
395        PARROT_ASSERT_ARG(ctx))
396 #define ASSERT_ARGS_Parrot_pcc_set_lex_pad_func __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
397        PARROT_ASSERT_ARG(interp) \
398     , PARROT_ASSERT_ARG(ctx) \
399     , PARROT_ASSERT_ARG(lex_pad))
400 #define ASSERT_ARGS_Parrot_pcc_set_namespace_func __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
401        PARROT_ASSERT_ARG(interp) \
402     , PARROT_ASSERT_ARG(ctx))
403 #define ASSERT_ARGS_Parrot_pcc_set_outer_ctx_func __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
404        PARROT_ASSERT_ARG(interp) \
405     , PARROT_ASSERT_ARG(ctx) \
406     , PARROT_ASSERT_ARG(outer_ctx))
407 #define ASSERT_ARGS_Parrot_pcc_set_pc_func __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
408        PARROT_ASSERT_ARG(ctx))
409 #define ASSERT_ARGS_Parrot_pcc_set_recursion_depth_func \
410      __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
411        PARROT_ASSERT_ARG(ctx))
412 #define ASSERT_ARGS_Parrot_pcc_set_signature_func __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
413        PARROT_ASSERT_ARG(interp) \
414     , PARROT_ASSERT_ARG(ctx))
415 #define ASSERT_ARGS_Parrot_pcc_trace_flags_off_func \
416      __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
417        PARROT_ASSERT_ARG(ctx))
418 #define ASSERT_ARGS_Parrot_pcc_trace_flags_on_func \
419      __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
420        PARROT_ASSERT_ARG(ctx))
421 #define ASSERT_ARGS_Parrot_pcc_trace_flags_test_func \
422      __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
423        PARROT_ASSERT_ARG(ctx))
424 #define ASSERT_ARGS_Parrot_pcc_warnings_off_func __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
425        PARROT_ASSERT_ARG(ctx))
426 #define ASSERT_ARGS_Parrot_pcc_warnings_on_func __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
427        PARROT_ASSERT_ARG(ctx))
428 #define ASSERT_ARGS_Parrot_pcc_warnings_test_func __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
429        PARROT_ASSERT_ARG(ctx))
430 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
431 /* HEADERIZER END: src/call/context_accessors.c */
432 
433 /* Map Context manipulating functions to functions or macros */
434 #ifdef NDEBUG
435 #  define Parrot_pcc_get_context_struct(i, c) CONTEXT_STRUCT(c)
436 
437 #  define Parrot_pcc_get_num_constants(i, c) (CONTEXT_STRUCT(c)->num_constants)
438 #  define Parrot_pcc_get_str_constants(i, c) (CONTEXT_STRUCT(c)->str_constants)
439 #  define Parrot_pcc_get_pmc_constants(i, c) (CONTEXT_STRUCT(c)->pmc_constants)
440 #  define Parrot_pcc_set_constants(i, c, ct) do { \
441     CONTEXT_STRUCT(c)->num_constants = (ct)->num.constants; \
442     CONTEXT_STRUCT(c)->str_constants = (ct)->str.constants; \
443     CONTEXT_STRUCT(c)->pmc_constants = (ct)->pmc.constants; \
444 } while (0)
445 
446 #  define Parrot_pcc_get_continuation(i, c) (CONTEXT_STRUCT(c)->current_cont)
447 #  define Parrot_pcc_get_caller_ctx(i, c) (CONTEXT_STRUCT(c)->caller_ctx)
448 #  define Parrot_pcc_get_namespace(i, c) (CONTEXT_STRUCT(c)->current_namespace)
449 #  define Parrot_pcc_get_lex_pad(i, c) (CONTEXT_STRUCT(c)->lex_pad)
450 #  define Parrot_pcc_get_handlers(i, c) (CONTEXT_STRUCT(c)->handlers)
451 
452 #  define Parrot_pcc_get_pc(i, c) (CONTEXT_STRUCT(c)->current_pc)
453 #  define Parrot_pcc_set_pc(i, c, value) (CONTEXT_STRUCT(c)->current_pc = (value))
454 
455 #  define Parrot_pcc_get_HLL(i, c) (CONTEXT_STRUCT(c)->current_HLL)
456 #  define Parrot_pcc_set_HLL(i, c, value) (CONTEXT_STRUCT(c)->current_HLL = (value))
457 
458 #  define Parrot_pcc_get_outer_ctx(i, c) (CONTEXT_STRUCT(c)->outer_ctx)
459 
460 #  define Parrot_pcc_get_signature(i, c) (CONTEXT_STRUCT(c)->current_sig)
461 
462 #  define Parrot_pcc_get_num_constant(i, c, idx) (CONTEXT_STRUCT(c)->num_constants[(idx)])
463 #  define Parrot_pcc_get_string_constant(i, c, idx) (CONTEXT_STRUCT(c)->str_constants[(idx)])
464 #  define Parrot_pcc_get_pmc_constant(i, c, idx) (CONTEXT_STRUCT(c)->pmc_constants[(idx)])
465 
466 #  define Parrot_pcc_get_recursion_depth(i, c) (CONTEXT_STRUCT(c)->recursion_depth)
467 #  define Parrot_pcc_set_recursion_depth(i, c, d) (CONTEXT_STRUCT(c)->recursion_depth = (d))
468 #  define Parrot_pcc_dec_recursion_depth(i, c) (--CONTEXT_STRUCT(c)->recursion_depth)
469 #  define Parrot_pcc_inc_recursion_depth(i, c) (++CONTEXT_STRUCT(c)->recursion_depth)
470 
471 #  define Parrot_pcc_warnings_on(i, c, flags)   (CONTEXT_STRUCT(c)->warns |= (flags))
472 #  define Parrot_pcc_warnings_off(i, c, flags)  (CONTEXT_STRUCT(c)->warns &= ~(flags))
473 #  define Parrot_pcc_warnings_test(i, c, flags) (CONTEXT_STRUCT(c)->warns & (flags))
474 
475 #  define Parrot_pcc_errors_on(i, c, flags)     (CONTEXT_STRUCT(c)->errors |= (flags))
476 #  define Parrot_pcc_errors_off(i, c, flags)    (CONTEXT_STRUCT(c)->errors &= ~(flags))
477 #  define Parrot_pcc_errors_test(i, c, flags)   (CONTEXT_STRUCT(c)->errors & (flags))
478 
479 #  define Parrot_pcc_trace_flags_on(i, c, flags)     (CONTEXT_STRUCT(c)->trace_flags |= (flags))
480 #  define Parrot_pcc_trace_flags_off(i, c, flags)    (CONTEXT_STRUCT(c)->trace_flags &= ~(flags))
481 #  define Parrot_pcc_trace_flags_test(i, c, flags)   (CONTEXT_STRUCT(c)->trace_flags & (flags))
482 
483 #else
484 
485 #  define Parrot_pcc_get_context_struct(i, c) Parrot_pcc_get_context_struct_func((i), (c))
486 
487 #  define Parrot_pcc_get_num_constants(i, c) Parrot_pcc_get_num_constants_func((i), (c))
488 #  define Parrot_pcc_get_str_constants(i, c) Parrot_pcc_get_str_constants_func((i), (c))
489 #  define Parrot_pcc_get_pmc_constants(i, c) Parrot_pcc_get_pmc_constants_func((i), (c))
490 #  define Parrot_pcc_set_constants(i, c, value) Parrot_pcc_set_constants_func((i), (c), (value))
491 
492 #  define Parrot_pcc_get_continuation(i, c) Parrot_pcc_get_continuation_func((i), (c))
493 
494 #  define Parrot_pcc_get_caller_ctx(i, c) Parrot_pcc_get_caller_ctx_func((i), (c))
495 
496 #  define Parrot_pcc_get_namespace(i, c) Parrot_pcc_get_namespace_func((i), (c))
497 
498 #  define Parrot_pcc_get_pc(i, c) Parrot_pcc_get_pc_func((i), (c))
499 #  define Parrot_pcc_set_pc(i, c, value) Parrot_pcc_set_pc_func((i), (c), (value))
500 
501 #  define Parrot_pcc_get_HLL(i, c) Parrot_pcc_get_HLL_func((i), (c))
502 #  define Parrot_pcc_set_HLL(i, c, value) Parrot_pcc_set_HLL_func((i), (c), (value))
503 
504 #  define Parrot_pcc_get_object(i, c) Parrot_pcc_get_object_func((i), (c))
505 
506 #  define Parrot_pcc_get_lex_pad(i, c) Parrot_pcc_get_lex_pad_func((i), (c))
507 
508 #  define Parrot_pcc_get_handlers(i, c) Parrot_pcc_get_handlers_func((i), (c))
509 
510 #  define Parrot_pcc_get_outer_ctx(i, c) Parrot_pcc_get_outer_ctx_func((i), (c))
511 
512 #  define Parrot_pcc_get_signature(i, c) Parrot_pcc_get_signature_func((i), (c))
513 
514 #  define Parrot_pcc_get_num_constant(i, c, idx) Parrot_pcc_get_num_constant_func((i), (c), (idx))
515 #  define Parrot_pcc_get_string_constant(i, c, idx) \
516             Parrot_pcc_get_string_constant_func((i), (c), (idx))
517 #  define Parrot_pcc_get_pmc_constant(i, c, idx) Parrot_pcc_get_pmc_constant_func((i), (c), (idx))
518 
519 #  define Parrot_pcc_get_recursion_depth(i, c) Parrot_pcc_get_recursion_depth_func((i), (c))
520 #  define Parrot_pcc_set_recursion_depth(i, c, d) \
521             Parrot_pcc_set_recursion_depth_func((i), (c), (d))
522 #  define Parrot_pcc_dec_recursion_depth(i, c) Parrot_pcc_dec_recursion_depth_func((i), (c))
523 #  define Parrot_pcc_inc_recursion_depth(i, c) Parrot_pcc_inc_recursion_depth_func((i), (c))
524 
525 #  define Parrot_pcc_warnings_on(i, c, flags) Parrot_pcc_warnings_on_func((i), (c), (flags))
526 #  define Parrot_pcc_warnings_off(i, c, flags) Parrot_pcc_warnings_off_func((i), (c), (flags))
527 #  define Parrot_pcc_warnings_test(i, c, flags) Parrot_pcc_warnings_test_func((i), (c), (flags))
528 
529 #  define Parrot_pcc_errors_on(i, c, flags) Parrot_pcc_errors_on_func((i), (c), (flags))
530 #  define Parrot_pcc_errors_off(i, c, flags) Parrot_pcc_errors_off_func((i), (c), (flags))
531 #  define Parrot_pcc_errors_test(i, c, flags) Parrot_pcc_errors_test_func((i), (c), (flags))
532 
533 #  define Parrot_pcc_trace_flags_on(i, c, flags) Parrot_pcc_trace_flags_on_func((i), (c), (flags))
534 #  define Parrot_pcc_trace_flags_off(i, c, flags) \
535             Parrot_pcc_trace_flags_off_func((i), (c), (flags))
536 #  define Parrot_pcc_trace_flags_test(i, c, flags) \
537             Parrot_pcc_trace_flags_test_func((i), (c), (flags))
538 
539 #endif /* ifndef NDEBUG */
540 
541 
542 #ifdef NDEBUG
543 #  define Parrot_pcc_set_continuation(i, c, value) do { \
544         CONTEXT_STRUCT(c)->current_cont = (value);      \
545         PARROT_GC_WRITE_BARRIER((i), (c));              \
546     } while (0)
547 #  define Parrot_pcc_set_caller_ctx(i, c, value) do {   \
548         CONTEXT_STRUCT(c)->caller_ctx = (value);        \
549         PARROT_GC_WRITE_BARRIER((i), (c));              \
550     } while (0)
551 #  define Parrot_pcc_set_namespace(i, c, value) do {    \
552         PARROT_ASSERT_INTERP((value), (i));             \
553         CONTEXT_STRUCT(c)->current_namespace = (value); \
554         PARROT_GC_WRITE_BARRIER((i), (c));              \
555     } while (0)
556 #  define Parrot_pcc_set_lex_pad(i, c, value) do {      \
557         CONTEXT_STRUCT(c)->lex_pad = (value);           \
558         PARROT_GC_WRITE_BARRIER((i), (c));              \
559     } while (0)
560 #  define Parrot_pcc_set_handlers(i, c, value) do {     \
561         CONTEXT_STRUCT(c)->handlers = (value);          \
562         PARROT_GC_WRITE_BARRIER((i), (c));              \
563     } while (0)
564 #  define Parrot_pcc_set_outer_ctx(i, c, value) do {    \
565         CONTEXT_STRUCT(c)->outer_ctx = (value);         \
566         PARROT_GC_WRITE_BARRIER((i), (c));              \
567     } while (0)
568 #  define Parrot_pcc_set_signature(i, c, value) do {    \
569         CONTEXT_STRUCT(c)->current_sig = (value);       \
570         PARROT_GC_WRITE_BARRIER((i), (c));              \
571     } while (0)
572 #  define Parrot_pcc_set_context(i, c)   do {           \
573         CURRENT_CONTEXT(i) = (c);                       \
574     } while (0)
575 #else
576 #  define Parrot_pcc_set_continuation(i, c, value) \
577             Parrot_pcc_set_continuation_func((i), (c), (value))
578 #  define Parrot_pcc_set_caller_ctx(i, c, value) Parrot_pcc_set_caller_ctx_func((i), (c), (value))
579 #  define Parrot_pcc_set_namespace(i, c, value) Parrot_pcc_set_namespace_func((i), (c), (value))
580 #  define Parrot_pcc_set_object(i, c, value) Parrot_pcc_set_object_func((i), (c), (value))
581 #  define Parrot_pcc_set_lex_pad(i, c, value) Parrot_pcc_set_lex_pad_func((i), (c), (value))
582 #  define Parrot_pcc_set_handlers(i, c, value) Parrot_pcc_set_handlers_func((i), (c), (value))
583 #  define Parrot_pcc_set_outer_ctx(i, c, value) Parrot_pcc_set_outer_ctx_func((i), (c), (value))
584 #  define Parrot_pcc_set_signature(i, c, value) Parrot_pcc_set_signature_func((i), (c), (value))
585 #  define Parrot_pcc_set_context(i, c)   Parrot_pcc_set_context_func((i), (c))
586 #endif /* ifdef NDEBUG */
587 
588 #endif /* PARROT_CONTEXT_H_GUARD */
589 
590 /*
591  * Local variables:
592  *   c-file-style: "parrot"
593  * End:
594  * vim: expandtab shiftwidth=4 cinoptions='\:2=2' :
595  */
596