Skip to content

Commit

Permalink
Start implementing compose protocol for P6int REPR.
Browse files Browse the repository at this point in the history
  • Loading branch information
arnsholt committed Jan 22, 2013
1 parent 3615620 commit 6302a6e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/6model/reprs/P6int.c
Expand Up @@ -20,6 +20,9 @@ static PMC * type_object_for(PARROT_INTERP, PMC *HOW) {
PMC *st_pmc = create_stable(interp, this_repr, HOW);
STable *st = STABLE_STRUCT(st_pmc);

/* Attach a REPR data object to the STable. */
st->REPR_data = mem_allocate_zeroed_typed(P6intREPRData);

/* Create type object and point it back at the STable. */
obj->common.stable = st_pmc;
st->WHAT = wrap_object(interp, obj);
Expand All @@ -34,6 +37,11 @@ static PMC * type_object_for(PARROT_INTERP, PMC *HOW) {
/* Composes the representation. */
static void compose(PARROT_INTERP, STable *st, PMC *repr_info) {
/* Nothing to do yet (but later, size). */
/* TODO: Set bit width and alignment requirements. */
P6intREPRData *repr_data = (P6intREPRData *) st->REPR_data;
repr_data->bits = VTABLE_get_integer_keyed_str(interp, repr_info,
Parrot_str_new_constant(interp, "bits"));
printf("bits: %ld\n", repr_data->bits);
}

/* Creates a new instance based on the type object. */
Expand Down
7 changes: 7 additions & 0 deletions src/6model/reprs/P6int.h
Expand Up @@ -12,6 +12,13 @@ typedef struct {
P6intBody body;
} P6intInstance;

/* The bit width and alignment requirements is shared for all instances of the
* same type.*/
typedef struct {
INTVAL bits;
INTVAL align;
} P6intREPRData;

/* Initializes the P6int REPR. */
REPROps * P6int_initialize(PARROT_INTERP);

Expand Down

0 comments on commit 6302a6e

Please sign in to comment.