Skip to content

Commit b4d08d1

Browse files
committed
Merge branch 'qrpa'
2 parents 10994ce + fad75ad commit b4d08d1

File tree

6 files changed

+1887
-1
lines changed

6 files changed

+1887
-1
lines changed

src/PAST/NQP.pir

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,7 @@ entry to produce the node to be returned.
612612
maphash['existskey'] = 'exists__IQs'
613613
maphash['existspos'] = 'exists__IQi'
614614
maphash['elems'] = 'elements__IP'
615+
maphash['islist'] = 'nqp_islist__IP'
615616
maphash['iterator'] = 'iter__PP'
616617
maphash['push'] = 'push__0PP'
617618
maphash['push_s'] = 'push__0Ps'
@@ -637,6 +638,14 @@ entry to produce the node to be returned.
637638
$P0['pasttype'] = 'hash'
638639
maphash['hash'] = $P0
639640

641+
# nqp::qlist is a temporary operation for creating QRPA lists
642+
# instead of RPA lists. Eventually we expect nqp::list to do the same,
643+
# at which point nqp::qlist can go away.
644+
$P0 = new ['Hash']
645+
$P0['pasttype'] = 'list'
646+
$P0['returns'] = 'QRPA'
647+
maphash['qlist'] = $P0
648+
640649
# repr-level aggregate operations
641650
maphash['r_atpos'] = 'repr_at_pos_obj__PPi'
642651
maphash['r_atpos_i'] = 'repr_at_pos_int__IPi'

src/ops/nqp.ops

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ static INTVAL initialized = 0;
2929
static INTVAL stable_id = 0;
3030
static INTVAL smo_id = 0;
3131
static INTVAL disp_id = 0;
32+
static INTVAL qrpa_id = 0;
3233

3334
/* Built-in meta-objects. */
3435
static PMC *KnowHOW = NULL;
@@ -82,6 +83,16 @@ static void SC_write_barrier_st(PARROT_INTERP, STable *st) {
8283
}
8384
}
8485

86+
87+
/* Test for something being a list (RPA or QRPA). This isn't
88+
* declared 'static' because we want to be able to call it from
89+
* other C functions (in both nqp and rakudo) as well. */
90+
INTVAL
91+
nqp_islist(PMC *pmc) {
92+
INTVAL type = pmc->vtable->base_type;
93+
return (INTVAL)(type == qrpa_id || type == enum_class_ResizablePMCArray);
94+
}
95+
8596
END_OPS_PREAMBLE
8697

8798
/*
@@ -101,6 +112,7 @@ inline op nqp_dynop_setup() :base_core {
101112
stable_id = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "STable", 0));
102113
smo_id = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "SixModelObject", 0));
103114
disp_id = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "DispatcherSub", 0));
115+
qrpa_id = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "QRPA", 0));
104116

105117
/* Initialize the object model. */
106118
SixModelObject_initialize(interp, &KnowHOW, &KnowHOWAttribute);
@@ -1854,6 +1866,19 @@ inline op repr_hint_for(out INT, in PMC, in PMC, in STR) :base_core {
18541866

18551867
/*
18561868

1869+
=item nqp_islist
1870+
1871+
Checks if the type of thing in $2 is a nqp list (either QRPA or RPA).
1872+
1873+
=cut
1874+
1875+
*/
1876+
inline op nqp_islist(out INT, in PMC) :base_core {
1877+
$1 = nqp_islist($2)
1878+
}
1879+
1880+
/*
1881+
18571882
=item is_container
18581883

18591884
Checks if the type of thing in $2 is a container or not. Puts a non-zero

0 commit comments

Comments
 (0)