@@ -29,11 +29,32 @@ typedef struct {
29
29
INTVAL hint ; /* Hint for use in static/gradual typing. */
30
30
} AttributeIdentifier ;
31
31
32
- /* Language interop information that we hold if the type is declaring a
33
- * container of some sort. */
32
+ /* Container specification information, for types that serve as containers.
33
+ * A container is something that can be assigned into. It may be some kind
34
+ * of container object (like Perl 6's Scalar) or it may be a reference to a
35
+ * native lexical or object field. The function table determines the way it
36
+ * behaves. */
34
37
typedef struct {
35
- AttributeIdentifier value_slot ;
36
- PMC * fetch_method ;
38
+ /* Fetches a value out of a container. Used for decontainerization. */
39
+ PMC * (* fetch ) (PARROT_INTERP , PMC * cont );
40
+
41
+ /* Stores a value in a container. Used for assignment. */
42
+ void (* store ) (PARROT_INTERP , PMC * cont , PMC * obj );
43
+
44
+ /* Name of this container specification. */
45
+ STRING * name ;
46
+
47
+ /* Marks container data, if any. */
48
+ void (* gc_mark_data ) (PARROT_INTERP , STable * st );
49
+
50
+ /* Frees container data, if any. */
51
+ void (* gc_free_data ) (PARROT_INTERP , STable * st );
52
+
53
+ /* Serializes the container data, if any. */
54
+ void (* serialize ) (PARROT_INTERP , STable * st , SerializationWriter * writer );
55
+
56
+ /* Deserializes the container data, if any. */
57
+ void (* deserialize ) (PARROT_INTERP , STable * st , SerializationReader * reader );
37
58
} ContainerSpec ;
38
59
39
60
/* How do we invoke this thing? Specifies either an attribute to look at for
@@ -138,10 +159,14 @@ struct SixModel_STable {
138
159
INTVAL type_cache_id ;
139
160
140
161
/* If this is a container, then this contains information needed in
141
- * order to fetch the value in it. If not, it'll be null, which can
142
- * be taken as a "not a container" indication. */
162
+ * order to fetch the value in it or assign a value to it. If not,
163
+ * it'll be null, which can be taken as a "not a container" indication. */
143
164
ContainerSpec * container_spec ;
144
165
166
+ /* Data that the container spec may need to function. */
167
+ /* Any data specific to this type that the REPR wants to keep. */
168
+ void * container_data ;
169
+
145
170
/* If this is invokable, then this contains information needed to
146
171
* figure out how to invoke it. If not, it'll be null. */
147
172
InvocationSpec * invocation_spec ;
@@ -394,6 +419,11 @@ struct SixModel_REPROps {
394
419
#define IS_CONCRETE (o ) (!PObj_flag_TEST(private0, (o)))
395
420
#define MARK_AS_TYPE_OBJECT (o ) PObj_flag_SET(private0, (o))
396
421
422
+ /* Macro for decontainerization. */
423
+ #define DECONT (interp , o ) (STABLE(o)->container_spec ? \
424
+ STABLE(o)->container_spec->fetch(interp, o) : \
425
+ o)
426
+
397
427
/* Write barriers for noticing changes to objects or STables with an SC. */
398
428
typedef void (* obj_sc_barrier_func ) (PARROT_INTERP , PMC * obj );
399
429
typedef void (* st_sc_barrier_func ) (PARROT_INTERP , STable * st );
0 commit comments