Skip to content

Commit

Permalink
implement is_attribute_initialized in P6opaque
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuomingliang committed Jun 10, 2013
1 parent 9e35676 commit 7e2668b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/6model/6model.h
Expand Up @@ -268,7 +268,7 @@ typedef struct _MVMREPROps_Attribute {
MVMObject *class_handle, struct _MVMString *name);

/* Checks if an attribute has been initialized. */
MVMint32 (*is_attribute_initialized) (struct _MVMThreadContext *tc, MVMSTable *st,
MVMint64 (*is_attribute_initialized) (struct _MVMThreadContext *tc, MVMSTable *st,
void *data, MVMObject *class_handle, struct _MVMString *name,
MVMint64 hint);
} MVMREPROps_Attribute;
Expand Down
2 changes: 1 addition & 1 deletion src/6model/reprs.c
Expand Up @@ -21,7 +21,7 @@ static void default_bind_attribute(MVMThreadContext *tc, MVMSTable *st, MVMObjec
die_no_attrs(tc, st->REPR->name);
}
GCC_DIAG_OFF(return-type)
static MVMint32 default_is_attribute_initialized(MVMThreadContext *tc, MVMSTable *st, void *data, MVMObject *class_handle, MVMString *name, MVMint64 hint) {
static MVMint64 default_is_attribute_initialized(MVMThreadContext *tc, MVMSTable *st, void *data, MVMObject *class_handle, MVMString *name, MVMint64 hint) {
die_no_attrs(tc, st->REPR->name);
}
GCC_DIAG_ON(return-type)
Expand Down
2 changes: 1 addition & 1 deletion src/6model/reprs/HashAttrStore.c
Expand Up @@ -121,7 +121,7 @@ static void bind_attribute(MVMThreadContext *tc, MVMSTable *st, MVMObject *root,
}
}

static MVMint32 is_attribute_initialized(MVMThreadContext *tc, MVMSTable *st, void *data, MVMObject *class_handle, MVMString *name, MVMint64 hint) {
static MVMint64 is_attribute_initialized(MVMThreadContext *tc, MVMSTable *st, void *data, MVMObject *class_handle, MVMString *name, MVMint64 hint) {
HashAttrStoreBody *body = (HashAttrStoreBody *)data;
void *kdata;
MVMHashEntry *entry;
Expand Down
12 changes: 11 additions & 1 deletion src/6model/reprs/P6opaque.c
Expand Up @@ -403,6 +403,16 @@ static void bind_attribute(MVMThreadContext *tc, MVMSTable *st, MVMObject *root,
}
}

/* Checks if an attribute has been initialized. */
static MVMint64 is_attribute_initialized(MVMThreadContext *tc, MVMSTable *st, void *data, MVMObject *class_handle, MVMString *name, MVMint64 hint) {
MVMP6opaqueREPRData *repr_data = (MVMP6opaqueREPRData *)st->REPR_data;
MVMint64 slot = try_get_slot(tc, repr_data, class_handle, name);
if (slot >= 0)
return NULL != get_obj_at_offset(data, repr_data->attribute_offsets[slot]);
else
no_such_attribute(tc, "initializedness check", class_handle, name);
}

/* Gets the hint for the given attribute ID. */
static MVMint64 hint_for(MVMThreadContext *tc, MVMSTable *st, MVMObject *class_key, MVMString *name) {
MVMint64 slot;
Expand Down Expand Up @@ -1120,7 +1130,7 @@ MVMREPROps * MVMP6opaque_initialize(MVMThreadContext *tc) {
memset(this_repr->attr_funcs, 0, sizeof(MVMREPROps_Attribute));
this_repr->attr_funcs->get_attribute = get_attribute;
this_repr->attr_funcs->bind_attribute = bind_attribute;
/*this_repr->attr_funcs->is_attribute_initialized = is_attribute_initialized;*/
this_repr->attr_funcs->is_attribute_initialized = is_attribute_initialized;
this_repr->attr_funcs->hint_for = hint_for;
this_repr->box_funcs = malloc(sizeof(MVMREPROps_Boxing));
this_repr->box_funcs->set_int = set_int;
Expand Down

0 comments on commit 7e2668b

Please sign in to comment.