Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add an nqp::ishash.
  • Loading branch information
jnthn committed Aug 7, 2012
1 parent 2524810 commit 4660299
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/QAST/Operations.nqp
Expand Up @@ -1350,6 +1350,7 @@ QAST::Operations.add_core_pirop_mapping('unshift_i', 'unshift', '0Pi', :inlinabl
QAST::Operations.add_core_pirop_mapping('unshift_n', 'unshift', '0Pn', :inlinable(1));
QAST::Operations.add_core_pirop_mapping('splice', 'splice', '0PPii', :inlinable(1));
QAST::Operations.add_core_pirop_mapping('islist', 'nqp_islist', 'IP', :inlinable(1));
QAST::Operations.add_core_pirop_mapping('ishash', 'nqp_ishash', 'IP', :inlinable(1));

# repr-level aggregate operations
QAST::Operations.add_core_pirop_mapping('r_atpos', 'repr_at_pos_obj', 'PPi', :inlinable(1));
Expand Down
20 changes: 20 additions & 0 deletions src/ops/nqp.ops
Expand Up @@ -95,6 +95,13 @@ nqp_islist(PMC *pmc) {
return (INTVAL)(type == qrpa_id || type == enum_class_ResizablePMCArray);
}

/* Test for something being a list (RPA or QRPA). */
static INTVAL
nqp_ishash(PMC *pmc) {
INTVAL type = pmc->vtable->base_type;
return (INTVAL)(type == enum_class_Hash);
}

/* This public-domain C quick sort implementation by Darel Rex Finley. */
static INTVAL
quicksort(INTVAL *arr, INTVAL elements) {
Expand Down Expand Up @@ -2055,6 +2062,19 @@ inline op nqp_islist(out INT, invar PMC) :base_core {

/*

=item nqp_ishash

Checks if the type of thing in $2 is a nqp hash.

=cut

*/
inline op nqp_ishash(out INT, invar PMC) :base_core {
$1 = nqp_ishash($2)
}

/*

=item is_container

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

0 comments on commit 4660299

Please sign in to comment.