Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge remote-tracking branch 'origin/master' into lexopts
  • Loading branch information
jnthn committed May 10, 2014
2 parents c9e9e90 + 948999a commit 7d6bcb2
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 18 deletions.
28 changes: 16 additions & 12 deletions src/QRegex/Cursor.nqp
Expand Up @@ -751,19 +751,23 @@ class NQPMatch is NQPCapture {
}

my int $i := 0;
for self.list() {
if $_ {
nqp::islist($_)
?? dump_match_array(@chunks, $indent, $i, $_)
!! dump_match(@chunks, $indent, $i, $_);
}
$i := $i + 1;
if self.list() {
for self.list() {
if $_ {
nqp::islist($_)
?? dump_match_array(@chunks, $indent, $i, $_)
!! dump_match(@chunks, $indent, $i, $_);
}
$i := $i + 1;
}
}
for self.hash() {
if $_.value {
nqp::islist($_.value)
?? dump_match_array(@chunks, $indent, $_.key, $_.value)
!! dump_match(@chunks, $indent, $_.key, $_.value);
if self.hash() {
for self.hash() {
if $_.value {
nqp::islist($_.value)
?? dump_match_array(@chunks, $indent, $_.key, $_.value)
!! dump_match(@chunks, $indent, $_.key, $_.value);
}
}
}
return join('', @chunks);
Expand Down
8 changes: 8 additions & 0 deletions src/vm/jvm/runtime/org/perl6/nqp/runtime/Ops.java
Expand Up @@ -2503,27 +2503,35 @@ public static String bindpos_s(SixModelObject arr, long idx, String value, Threa
}
public static SixModelObject push(SixModelObject arr, SixModelObject value, ThreadContext tc) {
arr.push_boxed(tc, value);
if (arr.sc != null)
scwbObject(tc, arr);
return value;
}
public static long push_i(SixModelObject arr, long value, ThreadContext tc) {
tc.native_i = value;
arr.push_native(tc);
if (tc.native_type != ThreadContext.NATIVE_INT)
throw ExceptionHandling.dieInternal(tc, "This is not a native int array");
if (arr.sc != null)
scwbObject(tc, arr);
return value;
}
public static double push_n(SixModelObject arr, double value, ThreadContext tc) {
tc.native_n = value;
arr.push_native(tc);
if (tc.native_type != ThreadContext.NATIVE_NUM)
throw ExceptionHandling.dieInternal(tc, "This is not a native num array");
if (arr.sc != null)
scwbObject(tc, arr);
return value;
}
public static String push_s(SixModelObject arr, String value, ThreadContext tc) {
tc.native_s = value;
arr.push_native(tc);
if (tc.native_type != ThreadContext.NATIVE_STR)
throw ExceptionHandling.dieInternal(tc, "This is not a native str array");
if (arr.sc != null)
scwbObject(tc, arr);
return value;
}
public static SixModelObject pop(SixModelObject arr, ThreadContext tc) {
Expand Down
1 change: 1 addition & 0 deletions src/vm/moar/QAST/QASTOperationsMAST.nqp
Expand Up @@ -2408,6 +2408,7 @@ QAST::MASTOperations.add_core_moarop_mapping('openpipe', 'openpipe');
QAST::MASTOperations.add_core_moarop_mapping('rand_i', 'rand_i');
QAST::MASTOperations.add_core_moarop_mapping('rand_n', 'randscale_n');
QAST::MASTOperations.add_core_moarop_mapping('srand', 'srand', 0);
QAST::MASTOperations.add_core_moarop_mapping('execname', 'execname');

# thread related opcodes
QAST::MASTOperations.add_core_moarop_mapping('newthread', 'newthread');
Expand Down
7 changes: 5 additions & 2 deletions src/vm/parrot/6model/reprs/CArray.c
Expand Up @@ -362,11 +362,12 @@ static void bind_pos_native(PARROT_INTERP, STable *st, void *data, INTVAL index,
CArrayREPRData *repr_data = (CArrayREPRData *)st->REPR_data;
CArrayBody *body = (CArrayBody *)data;
STable *type_st = STABLE(repr_data->elem_type);
void *ptr = ((char *)body->storage) + index * repr_data->elem_size;
void *ptr;
if (body->managed && index >= body->allocated)
expand(interp, repr_data, body, index + 1);
if (index >= body->elems)
body->elems = index + 1;
ptr = ((char *)body->storage) + index * repr_data->elem_size;
switch (repr_data->elem_kind) {
case CARRAY_ELEM_KIND_NUMERIC:
switch (value->type) {
Expand All @@ -392,7 +393,7 @@ static void bind_pos_native(PARROT_INTERP, STable *st, void *data, INTVAL index,
static void bind_pos_boxed(PARROT_INTERP, STable *st, void *data, INTVAL index, PMC *obj) {
CArrayREPRData *repr_data = (CArrayREPRData *)st->REPR_data;
CArrayBody *body = (CArrayBody *)data;
void **storage = (void **) body->storage;
void **storage;
void *cptr; /* Pointer to C data. */

/* Enlarge child_objs if needed. */
Expand All @@ -401,6 +402,8 @@ static void bind_pos_boxed(PARROT_INTERP, STable *st, void *data, INTVAL index,
if (index >= body->elems)
body->elems = index + 1;

storage = (void **) body->storage;

/* Make sure the type isn't something we can't handle. */
switch (repr_data->elem_kind) {
case CARRAY_ELEM_KIND_STRING:
Expand Down
82 changes: 79 additions & 3 deletions src/vm/parrot/6model/reprs/CStruct.c
Expand Up @@ -667,13 +667,89 @@ static storage_spec get_storage_spec(PARROT_INTERP, STable *st) {
/* Serializes the REPR data. */
static void serialize_repr_data(PARROT_INTERP, STable *st, SerializationWriter *writer) {
CStructREPRData *repr_data = (CStructREPRData *)st->REPR_data;
/* Could do this, but can also re-compute it each time for now. */
INTVAL i, num_classes, num_slots;

writer->write_int(interp, writer, repr_data->struct_size);
writer->write_int(interp, writer, repr_data->num_attributes);
writer->write_int(interp, writer, repr_data->num_child_objs);
writer->write_int(interp, writer, repr_data->num_child_strs);
for(i = 0; i < repr_data->num_attributes; i++){
writer->write_int(interp, writer, repr_data->attribute_locations[i]);
writer->write_int(interp, writer, repr_data->struct_offsets[i]);

writer->write_int(interp, writer, repr_data->flattened_stables[i] != NULL);
if (repr_data->flattened_stables[i])
writer->write_stable_ref(interp, writer, repr_data->flattened_stables[i]);

writer->write_ref(interp, writer, repr_data->member_types[i]);
}

i=0;
while (repr_data->name_to_index_mapping[i].class_key)
i++;
num_classes = i;
writer->write_int(interp, writer, num_classes);
for(i = 0; i < num_classes; i++){
writer->write_ref(interp, writer, repr_data->name_to_index_mapping[i].class_key);
writer->write_ref(interp, writer, repr_data->name_to_index_mapping[i].name_map);
}

i=0;
while(repr_data->initialize_slots && repr_data->initialize_slots[i] != -1)
i++;
num_slots = i;
writer->write_int(interp, writer, num_slots);
for(i = 0; i < num_slots; i++){
writer->write_int(interp, writer, repr_data->initialize_slots[i]);
}
}

/* Deserializes the REPR data. */
static void deserialize_repr_data(PARROT_INTERP, STable *st, SerializationReader *reader) {
/* Just allocating it will do for now. */
st->REPR_data = mem_sys_allocate_zeroed(sizeof(CStructREPRData));
CStructREPRData *repr_data = (CStructREPRData *) mem_sys_allocate(sizeof(CStructREPRData));
INTVAL i, num_classes, num_slots;

repr_data->struct_size = reader->read_int(interp, reader);
repr_data->num_attributes = reader->read_int(interp, reader);
repr_data->num_child_objs = reader->read_int(interp, reader);
repr_data->num_child_strs = reader->read_int(interp, reader);

repr_data->attribute_locations = (INTVAL *)mem_sys_allocate(sizeof(INTVAL) * repr_data->num_attributes);
repr_data->struct_offsets = (INTVAL *)mem_sys_allocate(sizeof(INTVAL) * repr_data->num_attributes);
repr_data->flattened_stables = (STable **)mem_sys_allocate(repr_data->num_attributes * sizeof(STable *));
repr_data->member_types = (PMC **)mem_sys_allocate(repr_data->num_attributes * sizeof(PMC *));

for(i = 0; i < repr_data->num_attributes; i++) {
repr_data->attribute_locations[i] = reader->read_int(interp, reader);
repr_data->struct_offsets[i] = reader->read_int(interp, reader);

if(reader->read_int(interp, reader)){
repr_data->flattened_stables[i] = reader->read_stable_ref(interp, reader);
}
else {
repr_data->flattened_stables[i] = NULL;
}

repr_data->member_types[i] = reader->read_ref(interp, reader);
}

num_classes = reader->read_int(interp, reader);
repr_data->name_to_index_mapping = (CStructNameMap *)mem_sys_allocate(sizeof(CStructNameMap) * (1 + num_classes));
for(i = 0; i < num_classes; i++){
repr_data->name_to_index_mapping[i].class_key = reader->read_ref(interp, reader);
repr_data->name_to_index_mapping[i].name_map = reader->read_ref(interp, reader);
}
repr_data->name_to_index_mapping[i].class_key = NULL;
repr_data->name_to_index_mapping[i].name_map = NULL;

num_slots = reader->read_int(interp, reader);
repr_data->initialize_slots = (INTVAL *)mem_sys_allocate(sizeof(INTVAL) * (1 + num_slots));
for(i = 0; i < num_slots; i++){
repr_data->initialize_slots[i] = reader->read_int(interp, reader);
}
repr_data->initialize_slots[i] = -1;

st->REPR_data = repr_data;
}

/* Initializes the CStruct representation. */
Expand Down
2 changes: 1 addition & 1 deletion tools/build/MOAR_REVISION
@@ -1 +1 @@
2014.04-49-gaa7bbef
2014.04-57-g61f9cdb

0 comments on commit 7d6bcb2

Please sign in to comment.