1
0
forked from GitHub/gf-core

bugfix in the pattern matching compiler and a number of other fixes that I somehow did not push before

This commit is contained in:
kr.angelov
2014-09-29 15:00:04 +00:00
parent 0d08417efe
commit 698329f469
5 changed files with 275 additions and 187 deletions

View File

@@ -119,7 +119,8 @@ typedef enum {
PGF_INSTR_PUSH = 9,
PGF_INSTR_EVAL = 10,
PGF_INSTR_RET = 13,
PGF_INSTR_FAIL = 15
PGF_INSTR_DROP = 15,
PGF_INSTR_FAIL = 16
} PgfInstruction;
struct PgfPGF {

View File

@@ -1093,6 +1093,28 @@ pgf_jit_function(PgfReader* rdr, PgfAbstr* abstr,
jit_bare_ret(a*sizeof(PgfClosure*));
break;
}
case PGF_INSTR_DROP: {
size_t n = pgf_read_int(rdr);
size_t target = pgf_read_int(rdr);
#ifdef PGF_JIT_DEBUG
gu_printf(out, err, "DROP %d %03d\n", n, target);
#endif
if (n > 0)
jit_addi_p(JIT_SP, JIT_SP, n*sizeof(PgfClosure*));
jit_insn *jump =
jit_jmpi(jit_forward());
PgfSegmentPatch label_patch;
label_patch.segment = target;
label_patch.ref = jump;
label_patch.is_abs = false;
gu_buf_push(rdr->jit_state->segment_patches, PgfSegmentPatch, label_patch);
break;
}
case PGF_INSTR_FAIL:
#ifdef PGF_JIT_DEBUG
gu_printf(out, err, "FAIL\n");