Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Updates to work with latest NQP.
  • Loading branch information
jnthn committed Jul 25, 2013
1 parent 2bc8e22 commit 351339d
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 8 deletions.
82 changes: 76 additions & 6 deletions nqp-cc/src/sixmodelobject.h
Expand Up @@ -29,13 +29,49 @@ typedef struct {
INTVAL hint; /* Hint for use in static/gradual typing. */
} AttributeIdentifier;

/* Language interop information that we hold if the type is declaring a
* container of some sort. */
/* Container specification information, for types that serve as containers.
* A container is something that can be assigned into. It may be some kind
* of container object (like Perl 6's Scalar) or it may be a reference to a
* native lexical or object field. The function table determines the way it
* behaves. */
typedef struct {
AttributeIdentifier value_slot;
PMC *fetch_method;
/* Fetches a value out of a container. Used for decontainerization. */
PMC * (*fetch) (PARROT_INTERP, PMC *cont);

/* Stores a value in a container. Used for assignment. */
void (*store) (PARROT_INTERP, PMC *cont, PMC *obj);

/* Stores a value in a container, without any checking of it (this
* assumes an optimizer or something else already did it). Used for
* assignment. */
void (*store_unchecked) (PARROT_INTERP, PMC *cont, PMC *obj);

/* Name of this container specification. */
STRING *name;

/* Marks container data, if any. */
void (*gc_mark_data) (PARROT_INTERP, STable *st);

/* Frees container data, if any. */
void (*gc_free_data) (PARROT_INTERP, STable *st);

/* Serializes the container data, if any. */
void (*serialize) (PARROT_INTERP, STable *st, SerializationWriter *writer);

/* Deserializes the container data, if any. */
void (*deserialize) (PARROT_INTERP, STable *st, SerializationReader *reader);
} ContainerSpec;

/* A container configurer knows how to attach a certain type of container
* to an STable and configure it. */
typedef struct {
/* Sets this container spec in place for the specified STable. */
void (*set_container_spec) (PARROT_INTERP, STable *st);

/* Configures the container spec with the specified info. */
void (*configure_container_spec) (PARROT_INTERP, STable *st, PMC *config);
} ContainerConfigurer;

/* How do we invoke this thing? Specifies either an attribute to look at for
* an invokable thing, or alternatively a method to call. */
typedef struct {
Expand Down Expand Up @@ -88,6 +124,15 @@ typedef struct {
/* This flag is set if we consider the method cche authoritative. */
#define METHOD_CACHE_AUTHORITATIVE 4

/* HLL type roles. */
#define HLL_ROLE_NONE 0
#define HLL_ROLE_INT 1
#define HLL_ROLE_NUM 2
#define HLL_ROLE_STR 3
#define HLL_ROLE_ARRAY 4
#define HLL_ROLE_HASH 5
#define HLL_ROLE_CODE 6

/* S-Tables (short for Shared Table) contains the commonalities shared between
* a (HOW, REPR) pairing (for example, (HOW for the class Dog, P6Opaque). */
typedef struct SixModel_REPROps REPROps;
Expand Down Expand Up @@ -138,10 +183,14 @@ struct SixModel_STable {
INTVAL type_cache_id;

/* If this is a container, then this contains information needed in
* order to fetch the value in it. If not, it'll be null, which can
* be taken as a "not a container" indication. */
* order to fetch the value in it or assign a value to it. If not,
* it'll be null, which can be taken as a "not a container" indication. */
ContainerSpec *container_spec;

/* Data that the container spec may need to function. */
/* Any data specific to this type that the REPR wants to keep. */
void *container_data;

/* If this is invokable, then this contains information needed to
* figure out how to invoke it. If not, it'll be null. */
InvocationSpec *invocation_spec;
Expand All @@ -165,6 +214,12 @@ struct SixModel_STable {

/* The PMC that wraps this s-table. */
PMC *stable_pmc;

/* The HLL that this type is owned by, if any. */
INTVAL hll_owner;

/* The role that the type plays in the HLL, if any. */
INTVAL hll_role;
};

/* A representation is what controls the layout of an object and access and
Expand Down Expand Up @@ -394,6 +449,11 @@ struct SixModel_REPROps {
#define IS_CONCRETE(o) (!PObj_flag_TEST(private0, (o)))
#define MARK_AS_TYPE_OBJECT(o) PObj_flag_SET(private0, (o))

/* Macro for decontainerization. */
#define DECONT(interp, o) (IS_CONCRETE(o) && STABLE(o)->container_spec ? \
STABLE(o)->container_spec->fetch(interp, o) : \
o)

/* Write barriers for noticing changes to objects or STables with an SC. */
typedef void (* obj_sc_barrier_func) (PARROT_INTERP, PMC *obj);
typedef void (* st_sc_barrier_func) (PARROT_INTERP, STable *st);
Expand All @@ -420,6 +480,8 @@ void set_wrapping_object(PMC *wrapper);
PMC * wrap_object(PARROT_INTERP, void *obj);
PMC * create_stable(PARROT_INTERP, REPROps *REPR, PMC *HOW);
PMC * decontainerize(PARROT_INTERP, PMC *var);
PMC * get_hll_config(PARROT_INTERP, STRING *hll);
PMC * hllize(PARROT_INTERP, PMC *obj, INTVAL hll_id);

/* Dynamic representation registration. */
typedef PMC * (*wrap_object_t)(PARROT_INTERP, void *obj);
Expand All @@ -431,4 +493,12 @@ typedef INTVAL (* rf) (PARROT_INTERP, STRING *name, REPROps * (*reg) (PARROT_INT
VTABLE_get_pmc_keyed_str(interp, interp->root_namespace, \
Parrot_str_new_constant(interp, "_REGISTER_REPR"))))(interp, name, reg_func)

/* Dynamic container configuration registration. */
typedef void (*cspec_conf) (PARROT_INTERP, STRING *name, ContainerConfigurer *configurer);
#define REGISTER_DYNAMIC_CONTAINER_CONFIG(interp, name, configurer) \
((cspec_conf) \
VTABLE_get_pointer(interp, \
VTABLE_get_pmc_keyed_str(interp, interp->root_namespace, \
Parrot_str_new_constant(interp, "_REGISTER_CONTCONF"))))(interp, name, configurer)

#endif
3 changes: 3 additions & 0 deletions nqp-cc/src/storage_spec.h
Expand Up @@ -24,6 +24,9 @@ typedef struct {

/* The types that this one can box/unbox to. */
INTVAL can_box;

/* For ints, whether it's an usigned value. */
INTVAL is_unsigned;
} storage_spec;

/* Inlined or not. */
Expand Down
2 changes: 1 addition & 1 deletion nqp-cc/tools/build/NQP_REVISION
@@ -1 +1 @@
2013.05-148-g76f3e34
2013.07-21-g9e2d04c
2 changes: 1 addition & 1 deletion src/6model/serialization.c
Expand Up @@ -7,7 +7,7 @@

/* Version of the serialization format that we are currently at and lowest
* version we support. */
#define CURRENT_VERSION 5
#define CURRENT_VERSION 6
#define MIN_VERSION 5

/* Various sizes (in bytes). */
Expand Down

0 comments on commit 351339d

Please sign in to comment.