Skip to content
Browse files

Kill dead code.

  • Loading branch information...
1 parent a7f47d9 commit 44f22ef33097f74f0cbf8320587ff61a0689a2da @jnthn jnthn committed Feb 12, 2013
Showing with 0 additions and 192 deletions.
  1. +0 −192 src/ops/nqp.ops
View
192 src/ops/nqp.ops
@@ -133,160 +133,6 @@ quicksort(INTVAL *arr, INTVAL elements) {
/* Does a run of the NFA. Produces a list of integers indicating the
* chosen ordering. */
-static INTVAL * nqp_nfa_run_old(PARROT_INTERP, PMC *states, STRING *target, INTVAL offset, INTVAL *total_fates_out) {
- INTVAL eos = Parrot_str_length(interp, target);
- INTVAL gen = 1;
- PMC *curst = nfa_curst;
- PMC *nextst = nfa_nextst;
- INTVAL *done, *fates;
- INTVAL i, num_states, total_fates, prev_fates;
-
- /* Zero out the done array; we don't get zeroed memory by default. */
- num_states = VTABLE_elements(interp, states);
- done = (INTVAL *)mem_sys_allocate_zeroed(num_states * sizeof(INTVAL));
-
- /* Clear out other re-used arrays. */
- VTABLE_set_integer_native(interp, curst, 0);
- VTABLE_set_integer_native(interp, nextst, 0);
-
- /* Allocate fates array. */
- fates = (INTVAL *)mem_sys_allocate(
- sizeof(INTVAL) * (1 + VTABLE_elements(interp,
- VTABLE_get_pmc_keyed_int(interp, states, 0))));
- total_fates = 0;
-
- VTABLE_push_integer(interp, nextst, 1);
- while (VTABLE_elements(interp, nextst) && offset <= eos) {
- /* Translation of:
- * my @curst := @nextst;
- * @nextst := [];
- * But avoids an extra allocation per offset. */
- PMC *temp = curst;
- curst = nextst;
- VTABLE_set_integer_native(interp, temp, 0);
- nextst = temp;
-
- /* Save how many fates we have before this position is considered. */
- prev_fates = total_fates;
-
- while (VTABLE_elements(interp, curst)) {
- PMC *edge_info;
- INTVAL edge_info_elems;
-
- INTVAL st = VTABLE_pop_integer(interp, curst);
- if (st < num_states) {
- if (done[st] == gen)
- continue;
- done[st] = gen;
- }
-
- edge_info = VTABLE_get_pmc_keyed_int(interp, states, st);
- edge_info_elems = VTABLE_elements(interp, edge_info);
- for (i = 0; i < edge_info_elems; i += 3) {
- INTVAL act = VTABLE_get_integer_keyed_int(interp, edge_info, i);
- INTVAL to = VTABLE_get_integer_keyed_int(interp, edge_info, i + 2);
-
- if (act == EDGE_FATE) {
- /* Crossed a fate edge. Check if we already saw this, and
- * if so bump the entry we already saw. */
- INTVAL arg = VTABLE_get_integer_keyed_int(interp, edge_info, i + 1);
- INTVAL j;
- INTVAL found_fate = 0;
- for (j = 0; j < total_fates; j++) {
- if (found_fate)
- fates[j - 1] = fates[j];
- if (fates[j] == arg) {
- found_fate = 1;
- if (j < prev_fates)
- prev_fates--;
- }
- }
- if (found_fate)
- fates[total_fates - 1] = arg;
- else
- fates[total_fates++] = arg;
- }
- else if (act == EDGE_EPSILON && to < num_states && done[to] != gen) {
- VTABLE_push_integer(interp, curst, to);
- }
- else if (offset >= eos) {
- /* Can't match, so drop state. */
- }
- else if (act == EDGE_CODEPOINT) {
- UINTVAL arg = VTABLE_get_integer_keyed_int(interp, edge_info, i + 1);
- if (STRING_ord(interp, target, offset) == arg)
- VTABLE_push_integer(interp, nextst, to);
- }
- else if (act == EDGE_CODEPOINT_NEG) {
- UINTVAL arg = VTABLE_get_integer_keyed_int(interp, edge_info, i + 1);
- if (STRING_ord(interp, target, offset) != arg)
- VTABLE_push_integer(interp, nextst, to);
- }
- else if (act == EDGE_CHARCLASS) {
- INTVAL arg = VTABLE_get_integer_keyed_int(interp, edge_info, i + 1);
- if (Parrot_str_is_cclass(interp, arg, target, offset))
- VTABLE_push_integer(interp, nextst, to);
- }
- else if (act == EDGE_CHARCLASS_NEG) {
- INTVAL arg = VTABLE_get_integer_keyed_int(interp, edge_info, i + 1);
- if (!Parrot_str_is_cclass(interp, arg, target, offset))
- VTABLE_push_integer(interp, nextst, to);
- }
- else if (act == EDGE_CHARLIST) {
- STRING *arg = VTABLE_get_string_keyed_int(interp, edge_info, i + 1);
- STRING *chr = STRING_substr(interp, target, offset, 1);
- if (STRING_index(interp, arg, chr, 0) >= 0)
- VTABLE_push_integer(interp, nextst, to);
- }
- else if (act == EDGE_CHARLIST_NEG) {
- STRING *arg = VTABLE_get_string_keyed_int(interp, edge_info, i + 1);
- STRING *chr = STRING_substr(interp, target, offset, 1);
- if (STRING_index(interp, arg, chr, 0) < 0)
- VTABLE_push_integer(interp, nextst, to);
- }
- else if (act == EDGE_CODEPOINT_I) {
- PMC *arg = VTABLE_get_pmc_keyed_int(interp, edge_info, i + 1);
- UINTVAL lc_arg = VTABLE_get_integer_keyed_int(interp, arg, 0);
- UINTVAL uc_arg = VTABLE_get_integer_keyed_int(interp, arg, 1);
- UINTVAL ord = STRING_ord(interp, target, offset);
- if (ord == lc_arg || ord == uc_arg)
- VTABLE_push_integer(interp, nextst, to);
- }
- else if (act == EDGE_CODEPOINT_I_NEG) {
- PMC *arg = VTABLE_get_pmc_keyed_int(interp, edge_info, i + 1);
- UINTVAL lc_arg = VTABLE_get_integer_keyed_int(interp, arg, 0);
- UINTVAL uc_arg = VTABLE_get_integer_keyed_int(interp, arg, 1);
- UINTVAL ord = STRING_ord(interp, target, offset);
- if (ord != lc_arg && ord != uc_arg)
- VTABLE_push_integer(interp, nextst, to);
- }
- }
- }
-
- /* Move to next character and generation. */
- offset++;
- 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. */
- 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];
- }
- }
- mem_sys_free(done);
-
- *total_fates_out = total_fates;
- return fates;
-}
-
-/* Does a run of the NFA. Produces a list of integers indicating the
- * chosen ordering. */
static INTVAL * nqp_nfa_run(PARROT_INTERP, NFABody *nfa, STRING *target, INTVAL offset, INTVAL *total_fates_out) {
INTVAL eos = Parrot_str_length(interp, target);
INTVAL gen = 1;
@@ -2621,20 +2467,6 @@ inline op nqp_push_label(invar PMC, in LABEL) :base_core {
VTABLE_push_integer(interp, $1, PTR2INTVAL(CUR_OPCODE + $2));
}
-inline op nqp_nfa_run_protoregex(out PMC, invar PMC, in STR, in INT) :base_core {
- /* Run the NFA. */
- INTVAL total_fates, i;
- INTVAL *fates = nqp_nfa_run_old(interp, $2, $3, $4, &total_fates);
-
- /* Copy results into an RIA. */
- PMC *fatepmc = Parrot_pmc_new(interp, enum_class_ResizableIntegerArray);
- for (i = 0; i < total_fates; i++)
- VTABLE_set_integer_keyed_int(interp, fatepmc, i, fates[i]);
- free(fates);
-
- $1 = fatepmc;
-}
-
inline op nqp_nfa_run_proto(out PMC, invar PMC, in STR, in INT) :base_core {
/* Run the NFA. */
INTVAL total_fates, i;
@@ -2649,30 +2481,6 @@ inline op nqp_nfa_run_proto(out PMC, invar PMC, in STR, in INT) :base_core {
$1 = fatepmc;
}
-inline op nqp_nfa_run_alternation(invar PMC, in STR, in INT, invar PMC, invar PMC, invar PMC) :base_core {
- PMC *states = $1;
- STRING *target = $2;
- INTVAL offset = $3;
- PMC *bstack = $4;
- PMC *cstack = $5;
- PMC *labels = $6;
-
- /* Run the NFA. */
- INTVAL total_fates, i;
- INTVAL *fates = nqp_nfa_run_old(interp, states, target, offset, &total_fates);
-
- /* Push the results onto the bstack. */
- INTVAL caps = VTABLE_defined(interp, cstack) ? VTABLE_elements(interp, cstack) : 0;
- for (i = 0; i < total_fates; i++) {
- VTABLE_push_integer(interp, bstack,
- VTABLE_get_integer_keyed_int(interp, labels, fates[i]));
- VTABLE_push_integer(interp, bstack, offset);
- VTABLE_push_integer(interp, bstack, 0);
- VTABLE_push_integer(interp, bstack, caps);
- }
- free(fates);
-}
-
inline op nqp_nfa_run_alt(invar PMC, in STR, in INT, invar PMC, invar PMC, invar PMC) :base_core {
PMC *nfa = $1;
STRING *target = $2;

0 comments on commit 44f22ef

Please sign in to comment.
Something went wrong with that request. Please try again.