Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Stash flag for when we're in an MI situation. Also a little cleanup.
  • Loading branch information
jnthn committed Jul 5, 2011
1 parent f14f5b6 commit 4c68b90
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
18 changes: 9 additions & 9 deletions src/6model/reprs/P6opaque.c
Expand Up @@ -73,7 +73,8 @@ static PMC * accessor_call(PARROT_INTERP, PMC *obj, STRING *name) {
* list of attributes (populating the passed flat_list). Also builds
* the index mapping for doing named lookups. Note index is not related
* to the storage position. */
P6opaqueNameMap * index_mapping_and_flat_list(PARROT_INTERP, PMC *WHAT, PMC *flat_list) {
PMC * index_mapping_and_flat_list(PARROT_INTERP, PMC *WHAT, P6opaqueREPRData *repr_data) {
PMC *flat_list = pmc_new(interp, enum_class_ResizablePMCArray);
PMC *class_list = pmc_new(interp, enum_class_ResizablePMCArray);
PMC *attr_map_list = pmc_new(interp, enum_class_ResizablePMCArray);
STRING *attributes_str = Parrot_str_new_constant(interp, "attributes");
Expand Down Expand Up @@ -127,9 +128,10 @@ P6opaqueNameMap * index_mapping_and_flat_list(PARROT_INTERP, PMC *WHAT, PMC *fla
VTABLE_push_pmc(interp, class_list, current_class);
VTABLE_push_pmc(interp, attr_map_list, attr_map);

/* If there's more than one parent, flag that we in an
* MI situation. */

/* If there's more than one parent, flag that we in an MI
* situation. */
if (num_parents > 1)
repr_data->mi = 1;
}

/* We can now form the name map. */
Expand All @@ -139,8 +141,9 @@ P6opaqueNameMap * index_mapping_and_flat_list(PARROT_INTERP, PMC *WHAT, PMC *fla
result[i].class_key = VTABLE_get_pmc_keyed_int(interp, class_list, i);
result[i].name_map = VTABLE_get_pmc_keyed_int(interp, attr_map_list, i);
}
repr_data->name_to_index_mapping = result;

return result;
return flat_list;
}

/* This works out an allocation strategy for the object. It takes care of
Expand All @@ -163,11 +166,8 @@ static void compute_allocation_strategy(PARROT_INTERP, PMC *WHAT, P6opaqueREPRDa
*/
Parrot_block_GC_mark(interp);

/* Create flat list that we'll analyze to determine allocation info. */
flat_list = pmc_new(interp, enum_class_ResizablePMCArray);

/* Compute index mapping table and get flat list of attributes. */
repr_data->name_to_index_mapping = index_mapping_and_flat_list(interp, WHAT, flat_list);
flat_list = index_mapping_and_flat_list(interp, WHAT, repr_data);

/* If we have no attributes in the index mapping, then just the header. */
if (repr_data->name_to_index_mapping[0].class_key == NULL) {
Expand Down
19 changes: 9 additions & 10 deletions src/6model/reprs/P6opaque.h
Expand Up @@ -35,18 +35,20 @@ typedef struct {
* for the Shared Table pointer, spill hash and then for storing the
* actual, pre-declared attributes. Note, this is in bytes. */
INTVAL allocation_size;

/* Instantiated objects are just a blank piece of memory that needs to
* be set up. However, in some cases we'd like them to magically turn in
* to some container type. */
P6opaqueAutoViv *auto_viv_conf;

/* The number of attributes we have allocated slots for. Does not include
* any in the spill hash. */
/* The number of attributes we have allocated slots for. */
INTVAL num_attributes;

/* Maps attribute position numbers to the byte offset in the object. */
INTVAL *attribute_offsets;

/* Flags if we are MI or not. */
INTVAL mi;

/* Instantiated objects are just a blank piece of memory that needs to
* be set up. However, in some cases we'd like them to magically turn in
* to some container type. */
P6opaqueAutoViv *auto_viv_conf;

/* If we can unbox to a native integer, this is the offset to find it. */
INTVAL unbox_int_offset;
Expand All @@ -68,9 +70,6 @@ typedef struct {
INTVAL *gc_str_mark_offsets;
} P6opaqueREPRData;

/* function declarations */
P6opaqueNameMap * index_mapping_and_flat_list(PARROT_INTERP, PMC * WHAT, PMC * flat_list);

/* Initializes the P6opaque REPR. */
PMC * P6opaque_initialize(PARROT_INTERP);

Expand Down

0 comments on commit 4c68b90

Please sign in to comment.