1 /* pmc_freeze.h 2 * Copyright (C) 2001-2003, Parrot Foundation. 3 * Overview: 4 * PMC freeze and thaw interface 5 * Data Structure and Algorithms: 6 * History: 7 * Notes: 8 * References: 9 */ 10 11 #ifndef PARROT_PMC_FREEZE_H_GUARD 12 #define PARROT_PMC_FREEZE_H_GUARD 13 14 #include "parrot/packfile.h" 15 16 typedef enum { 17 VISIT_HOW_PMC_TO_VISITOR = 0x00, /* push to visitor */ 18 VISIT_HOW_VISITOR_TO_PMC = 0x01, /* shift from visitor */ 19 VISIT_HOW_PMC_TO_PMC = 0x02, /* push to visitor; then shift from visitor */ 20 VISIT_HOW_VISITOR_TO_VISITOR = 0x03 /* shift from visitor; then push to visitor */ 21 } visit_how_enum_t; 22 23 #define VISIT_HOW_MASK 0x03 24 25 typedef enum { 26 VISIT_WHAT_PMC = 0x04, 27 VISIT_WHAT_STRING = 0x08, 28 VISIT_WHAT_FLOATVAL = 0x10, 29 VISIT_WHAT_INTVAL = 0x20 30 } visit_what_enum_t; 31 32 #define VISIT_WHAT_MASK 0x3c 33 34 /* backwards-compat defns */ 35 #define visit_enum_type INTVAL 36 #define VISIT_FREEZE_NORMAL (VISIT_HOW_PMC_TO_VISITOR | VISIT_WHAT_PMC) 37 #define VISIT_THAW_NORMAL (VISIT_HOW_VISITOR_TO_PMC | VISIT_WHAT_PMC) 38 #define VISIT_THAW_CONSTANTS VISIT_THAW_NORMAL 39 40 typedef enum { 41 EXTRA_IS_NULL, 42 EXTRA_IS_PROP_HASH 43 } extra_flags_enum; 44 45 #define VISIT_PMC(interp, visit, pmc) do {\ 46 const INTVAL _visit_pmc_flags = VTABLE_get_integer((interp), (visit)); \ 47 if (_visit_pmc_flags & VISIT_WHAT_PMC) { \ 48 switch (_visit_pmc_flags & VISIT_HOW_MASK) { \ 49 case VISIT_HOW_PMC_TO_VISITOR: \ 50 VTABLE_push_pmc((interp), (visit), (pmc)); \ 51 break; \ 52 case VISIT_HOW_VISITOR_TO_PMC: \ 53 (pmc) = VTABLE_shift_pmc((interp), (visit)); \ 54 break; \ 55 case VISIT_HOW_PMC_TO_PMC: \ 56 VTABLE_push_pmc((interp), (visit), (pmc)); \ 57 (pmc) = VTABLE_shift_pmc((interp), (visit)); \ 58 break; \ 59 case VISIT_HOW_VISITOR_TO_VISITOR: \ 60 (pmc) = VTABLE_shift_pmc((interp), (visit)); \ 61 VTABLE_push_pmc((interp), (visit), (pmc)); \ 62 break; \ 63 default: \ 64 Parrot_x_panic_and_exit((interp), "Bad VISIT_HOW in VISIT_PMC", __FILE__, __LINE__); \ 65 } \ 66 } \ 67 } while (0) 68 69 #define VISIT_PMC_ATTR(interp, visit, self, pmclass, attr_name) do {\ 70 const INTVAL _visit_pmc_attr_flags = VTABLE_get_integer((interp), (visit)); \ 71 if (_visit_pmc_attr_flags & VISIT_WHAT_PMC) { \ 72 PMC *_visit_pmc_attr; \ 73 switch (_visit_pmc_attr_flags & VISIT_HOW_MASK) { \ 74 case VISIT_HOW_PMC_TO_VISITOR: \ 75 GETATTR_ ## pmclass ## _ ## attr_name((interp), (self), _visit_pmc_attr); \ 76 VTABLE_push_pmc((interp), (visit), _visit_pmc_attr); \ 77 break; \ 78 case VISIT_HOW_VISITOR_TO_PMC: \ 79 _visit_pmc_attr = VTABLE_shift_pmc((interp), (visit)); \ 80 SETATTR_ ## pmclass ## _ ## attr_name((interp), (self), _visit_pmc_attr); \ 81 break; \ 82 case VISIT_HOW_PMC_TO_PMC: \ 83 GETATTR_ ## pmclass ## _ ## attr_name((interp), (self), _visit_pmc_attr); \ 84 VTABLE_push_pmc((interp), (visit), _visit_pmc_attr); \ 85 _visit_pmc_attr = VTABLE_shift_pmc((interp), (visit)); \ 86 SETATTR_ ## pmclass ## _ ## attr_name((interp), (self), _visit_pmc_attr); \ 87 break; \ 88 case VISIT_HOW_VISITOR_TO_VISITOR: \ 89 _visit_pmc_attr = VTABLE_shift_pmc((interp), (visit)); \ 90 SETATTR_ ## pmclass ## _ ## attr_name((interp), (self), _visit_pmc_attr); \ 91 GETATTR_ ## pmclass ## _ ## attr_name((interp), (self), _visit_pmc_attr); \ 92 VTABLE_push_pmc((interp), (visit), _visit_pmc_attr); \ 93 break; \ 94 default: \ 95 Parrot_x_panic_and_exit((interp), \ 96 "Bad VISIT_HOW in VISIT_PMC_ATTR", __FILE__, __LINE__); \ 97 } \ 98 } \ 99 } while (0) 100 101 /* 102 * public interfaces 103 */ 104 105 /* HEADERIZER BEGIN: src/packfile/object_serialization.c */ 106 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */ 107 108 PARROT_EXPORT 109 PARROT_WARN_UNUSED_RESULT 110 PARROT_CAN_RETURN_NULL 111 PMC* Parrot_clone(PARROT_INTERP, ARGIN(PMC *pmc)) 112 __attribute__nonnull__(1) 113 __attribute__nonnull__(2); 114 115 PARROT_EXPORT 116 PARROT_WARN_UNUSED_RESULT 117 PARROT_CANNOT_RETURN_NULL 118 STRING* Parrot_freeze(PARROT_INTERP, ARGIN(PMC *pmc)) 119 __attribute__nonnull__(1) 120 __attribute__nonnull__(2); 121 122 PARROT_EXPORT 123 PARROT_WARN_UNUSED_RESULT 124 PARROT_CAN_RETURN_NULL 125 opcode_t * Parrot_freeze_pbc(PARROT_INTERP, 126 ARGIN(PMC *pmc), 127 ARGIN(const PackFile_ConstTable *pf), 128 ARGOUT(opcode_t *cursor), 129 ARGOUT(Hash **seen)) 130 __attribute__nonnull__(1) 131 __attribute__nonnull__(2) 132 __attribute__nonnull__(3) 133 __attribute__nonnull__(4) 134 __attribute__nonnull__(5) 135 FUNC_MODIFIES(*cursor) 136 FUNC_MODIFIES(*seen); 137 138 PARROT_EXPORT 139 PARROT_WARN_UNUSED_RESULT 140 UINTVAL Parrot_freeze_pbc_size(PARROT_INTERP, 141 ARGIN(PMC *pmc), 142 ARGIN(const PackFile_ConstTable *pf), 143 ARGOUT(Hash **seen)) 144 __attribute__nonnull__(1) 145 __attribute__nonnull__(2) 146 __attribute__nonnull__(3) 147 __attribute__nonnull__(4) 148 FUNC_MODIFIES(*seen); 149 150 PARROT_EXPORT 151 PARROT_WARN_UNUSED_RESULT 152 PARROT_CANNOT_RETURN_NULL 153 PMC * Parrot_freeze_strings(PARROT_INTERP, ARGIN(PMC *pmc)) 154 __attribute__nonnull__(1) 155 __attribute__nonnull__(2); 156 157 PARROT_EXPORT 158 PARROT_WARN_UNUSED_RESULT 159 PARROT_CANNOT_RETURN_NULL 160 PMC * Parrot_thaw(PARROT_INTERP, ARGIN(STRING *image)) 161 __attribute__nonnull__(1) 162 __attribute__nonnull__(2); 163 164 PARROT_EXPORT 165 PARROT_WARN_UNUSED_RESULT 166 PARROT_CANNOT_RETURN_NULL 167 PMC* Parrot_thaw_constants(PARROT_INTERP, ARGIN(STRING *image)) 168 __attribute__nonnull__(1) 169 __attribute__nonnull__(2); 170 171 PARROT_EXPORT 172 PARROT_WARN_UNUSED_RESULT 173 PARROT_CAN_RETURN_NULL 174 PMC* Parrot_thaw_pbc(PARROT_INTERP, 175 ARGIN(PackFile_ConstTable *ct), 176 ARGMOD(const opcode_t **cursor)) 177 __attribute__nonnull__(1) 178 __attribute__nonnull__(2) 179 __attribute__nonnull__(3) 180 FUNC_MODIFIES(*cursor); 181 182 void Parrot_pf_verify_image_string(PARROT_INTERP, ARGIN(STRING *image)) 183 __attribute__nonnull__(1) 184 __attribute__nonnull__(2); 185 186 #define ASSERT_ARGS_Parrot_clone __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 187 PARROT_ASSERT_ARG(interp) \ 188 , PARROT_ASSERT_ARG(pmc)) 189 #define ASSERT_ARGS_Parrot_freeze __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 190 PARROT_ASSERT_ARG(interp) \ 191 , PARROT_ASSERT_ARG(pmc)) 192 #define ASSERT_ARGS_Parrot_freeze_pbc __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 193 PARROT_ASSERT_ARG(interp) \ 194 , PARROT_ASSERT_ARG(pmc) \ 195 , PARROT_ASSERT_ARG(pf) \ 196 , PARROT_ASSERT_ARG(cursor) \ 197 , PARROT_ASSERT_ARG(seen)) 198 #define ASSERT_ARGS_Parrot_freeze_pbc_size __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 199 PARROT_ASSERT_ARG(interp) \ 200 , PARROT_ASSERT_ARG(pmc) \ 201 , PARROT_ASSERT_ARG(pf) \ 202 , PARROT_ASSERT_ARG(seen)) 203 #define ASSERT_ARGS_Parrot_freeze_strings __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 204 PARROT_ASSERT_ARG(interp) \ 205 , PARROT_ASSERT_ARG(pmc)) 206 #define ASSERT_ARGS_Parrot_thaw __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 207 PARROT_ASSERT_ARG(interp) \ 208 , PARROT_ASSERT_ARG(image)) 209 #define ASSERT_ARGS_Parrot_thaw_constants __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 210 PARROT_ASSERT_ARG(interp) \ 211 , PARROT_ASSERT_ARG(image)) 212 #define ASSERT_ARGS_Parrot_thaw_pbc __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 213 PARROT_ASSERT_ARG(interp) \ 214 , PARROT_ASSERT_ARG(ct) \ 215 , PARROT_ASSERT_ARG(cursor)) 216 #define ASSERT_ARGS_Parrot_pf_verify_image_string __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 217 PARROT_ASSERT_ARG(interp) \ 218 , PARROT_ASSERT_ARG(image)) 219 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */ 220 /* HEADERIZER END: src/packfile/object_serialization.c */ 221 222 #endif /* PARROT_PMC_FREEZE_H_GUARD */ 223 224 /* 225 * Local variables: 226 * c-file-style: "parrot" 227 * End: 228 * vim: expandtab shiftwidth=4 cinoptions='\:2=2' : 229 */ 230