Skip to content

Commit

Permalink
Merge branch 'master' of github.com:perl6/nqp into openpipe
Browse files Browse the repository at this point in the history
  • Loading branch information
FROGGS committed Nov 15, 2014
2 parents 4818829 + 28ff049 commit 4019ecc
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 23 deletions.
12 changes: 6 additions & 6 deletions docs/ops.markdown
Expand Up @@ -108,7 +108,7 @@ Return the modulus of $l by $r.
* `mul_n(num $l, num $r)`
* `mul_I(Int $l, Int $r, Mu:T $type)`

Multiple two numbers, returning the result.
Multiply two numbers, returning the result.
`_I` variant returns an object of the given type.

## neg
Expand Down Expand Up @@ -142,7 +142,7 @@ Return the ceiling of a number.
## exp
* `exp_n(num $exponent)`

Return the value of `e` raised to $exponent;
Return the value of `e` raised to $exponent.

## floor
* `floor_n(num $n)`
Expand Down Expand Up @@ -274,31 +274,31 @@ Return non-zero if the two parameters are equal.
* `isgt_s(str $l, str $r)`
* `isgt_I(Int $l, Int $r)`

Return non-zero if $l is greater than two $r.
Return non-zero if $l is greater than $r.

## isge
* `isge_i(int $l, int $r)`
* `isge_n(num $l, num $r)`
* `isge_s(str $l, str $r)`
* `isge_I(Int $l, Int $r)`

Return non-zero if $l is greater than or equal two $r.
Return non-zero if $l is greater than or equal to $r.

## islt
* `islt_i(int $l, int $r)`
* `islt_n(num $l, num $r)`
* `islt_s(str $l, str $r)`
* `islt_I(Int $l, Int $r)`

Return non-zero if $l is less than two $r.
Return non-zero if $l is less than $r.

## isle
* `isle_i(int $l, int $r)`
* `isle_n(num $l, num $r)`
* `isle_s(str $l, str $r)`
* `isle_I(Int $l, Int $r)`

Return non-zero if $l is less than or equal two $r.
Return non-zero if $l is less than or equal to $r.

## isne
* `isne_i(int $l, int $r)`
Expand Down
2 changes: 1 addition & 1 deletion src/NQP/Actions.nqp
Expand Up @@ -1647,7 +1647,7 @@ class NQP::Actions is HLL::Actions {
make QAST::Op.new(
QAST::Var.new( :name('$/'), :scope('lexical') ),
:op('callmethod'),
:name('!make'),
:name('make'),
:node($/)
);
}
Expand Down
5 changes: 3 additions & 2 deletions src/QRegex/Cursor.nqp
Expand Up @@ -324,7 +324,7 @@ role NQPCursorRole is export {
my $cur;
my $rxname;
while @fates {
$rxname := nqp::atpos(@rxfate, nqp::bitand_i(nqp::pop_i(@fates), 0xffffffff));
$rxname := nqp::atpos(@rxfate, nqp::pop_i(@fates));
#nqp::say("invoking $rxname");
$cur := self."$rxname"();
@fates := @EMPTY if nqp::getattr_i($cur, $?CLASS, '$!pos') >= 0;
Expand Down Expand Up @@ -733,7 +733,8 @@ class NQPMatch is NQPCapture {
$!cursor := NQPMu;
}

method !make($made) { $!made := $made }
method !make($made) { $!made := $made } # remove after rebootstrap
method make($made) { $!made := $made }
method made() { $!made }
method ast() { $!made } # for historical reasons

Expand Down
4 changes: 2 additions & 2 deletions src/QRegex/NFA.nqp
Expand Up @@ -375,7 +375,7 @@ class QRegex::NFA {
my int $k := nqp::elems($substate);
while $j < $k {
$substate[$j+2] := $substate[$j+2] + $substart;
$substate[$j+1] := $fate # XXX add in $lits +< 32 after rebootstrap
$substate[$j+1] := $fate # XXX add in $lits +< 24 after rebootstrap
if $substate[$j] == $EDGE_FATE;
self.mergesubrule($i, $substate[$j+2], $fate, $cursor, $substate[$j+1], %seen)
if $substate[$j] == $EDGE_SUBRULE;
Expand All @@ -392,7 +392,7 @@ class QRegex::NFA {
self.addedge($start, $substart+1, $EDGE_EPSILON, 0);
$to > 0
?? self.addedge($substart, $to, $EDGE_EPSILON, 0)
!! self.addedge($substart, 0, $EDGE_FATE, $fate) # XXX add in $lits +< 32 after rebootstrap
!! self.addedge($substart, 0, $EDGE_FATE, $fate) # XXX add in $lits +< 24 after rebootstrap
}
else {
self.addedge($start, 0, $EDGE_FATE, $fate);
Expand Down
3 changes: 2 additions & 1 deletion src/vm/jvm/runtime/org/perl6/nqp/runtime/Ops.java
Expand Up @@ -5066,9 +5066,10 @@ else if (act == NFA.EDGE_CHARRANGE_NEG) {
}
}

/* strip any literal lengths, leaving only fates */
int[] result = new int[fates.size()];
for (int i = 0; i < fates.size(); i++)
result[i] = fates.get(i);
result[i] = fates.get(i) & 0xffffff;
return result;
}

Expand Down
23 changes: 12 additions & 11 deletions src/vm/parrot/ops/nqp.ops
Expand Up @@ -100,7 +100,7 @@ nqp_ishash(PMC *pmc) {

/* This public-domain C quick sort implementation by Darel Rex Finley. */
static INTVAL
quicksort(INTVAL *arr, INTVAL elements) {
revquicksort(INTVAL *arr, INTVAL elements) {
#define MAX_LEVELS 100
INTVAL piv, beg[MAX_LEVELS], end[MAX_LEVELS], i = 0, L, R ;
beg[0] = 0;
Expand All @@ -113,11 +113,11 @@ quicksort(INTVAL *arr, INTVAL elements) {
if (i == MAX_LEVELS - 1)
return 0;
while (L < R) {
while (arr[R] >= piv && L < R)
while (arr[R] <= piv && L < R)
R--;
if (L < R)
arr[L++] = arr[R];
while (arr[L] <= piv && L < R)
while (arr[L] >= piv && L < R)
L++;
if (L < R)
arr[R--] =arr[L];
Expand Down Expand Up @@ -285,21 +285,22 @@ static INTVAL * nqp_nfa_run(PARROT_INTERP, NFABody *nfa, STRING *target, INTVAL
gen++;

/* If we got multiple fates at this offset, sort them by the
* declaration order (represented by the fate number). In the
* future, we'll want to factor in longest literal prefix too. */
* literal length and declaration order (both encoded in fate number).
* The high 40 bits of the fate encodes literal length, while the low
* 24 bits encode fate. Both want to be descending order. */
if (total_fates - prev_fates > 1) {
INTVAL char_fates = total_fates - prev_fates;
for (i = total_fates - char_fates; i < total_fates; i++)
fates[i] = -fates[i];
quicksort(&fates[total_fates - char_fates], char_fates);
for (i = total_fates - char_fates; i < total_fates; i++)
fates[i] = -fates[i];
revquicksort(&fates[total_fates - char_fates], char_fates);
}
}
mem_sys_free(done);
mem_sys_free(curst);
mem_sys_free(nextst);


/* strip any literal lengths, leaving only fates */
for (i = 0; i < total_fates; i++)
fates[i] &= 0xffffff;

*total_fates_out = total_fates;
return fates;
}
Expand Down

0 comments on commit 4019ecc

Please sign in to comment.