@@ -29,6 +29,7 @@ static INTVAL initialized = 0;
29
29
static INTVAL stable_id = 0;
30
30
static INTVAL smo_id = 0;
31
31
static INTVAL disp_id = 0;
32
+ static INTVAL qrpa_id = 0;
32
33
33
34
/* Built-in meta-objects. */
34
35
static PMC *KnowHOW = NULL;
@@ -82,6 +83,16 @@ static void SC_write_barrier_st(PARROT_INTERP, STable *st) {
82
83
}
83
84
}
84
85
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
+
85
96
END_OPS_PREAMBLE
86
97
87
98
/*
@@ -101,6 +112,7 @@ inline op nqp_dynop_setup() :base_core {
101
112
stable_id = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "STable", 0));
102
113
smo_id = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "SixModelObject", 0));
103
114
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));
104
116
105
117
/* Initialize the object model. */
106
118
SixModelObject_initialize(interp, &KnowHOW, &KnowHOWAttribute);
@@ -1854,6 +1866,19 @@ inline op repr_hint_for(out INT, in PMC, in PMC, in STR) :base_core {
1854
1866
1855
1867
/*
1856
1868
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
+
1857
1882
=item is_container
1858
1883
1859
1884
Checks if the type of thing in $2 is a container or not. Puts a non-zero
0 commit comments