From 22674528dae5a7bf8d1385aad0d59c34d2ffd185 Mon Sep 17 00:00:00 2001 From: Peter McGoron Date: Thu, 23 Mar 2023 18:13:11 +0000 Subject: [PATCH] modify reader --- creole.c | 9 +++++++-- creole.h | 4 +++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/creole.c b/creole.c index aa80c42..0d5c27d 100644 --- a/creole.c +++ b/creole.c @@ -338,6 +338,7 @@ int creole_encode(creole_word i, unsigned encode_to, unsigned high_bits, struct ins { unsigned char *start; unsigned char *datapt; + size_t dataptlen; enum creole_opcode opcode; creole_word w[CREOLE_MAX_ARG]; creole_word w_flags[CREOLE_MAX_ARG]; @@ -404,10 +405,12 @@ parse_line(struct creole_env *env, struct ins *ins, struct creole_reader *r) if (ins->opcode == CREOLE_DB) { ins->datapt = r->p; + ins->dataptlen = 0; do { if (!creole_decode(r, &w)) return CREOLE_ARG_READ_ERROR; } while (w.len != 1); + ins->dataptlen = r->p - ins->datapt - 1; if (w.word != 0) return CREOLE_LAST_READ_ERROR; return CREOLE_COMPILE_OK; @@ -430,7 +433,8 @@ add_to_env(struct creole_env *env, struct ins *ins) { switch (ins->opcode) { case CREOLE_DB: - env->dats[ins->w[0]] = ins->datapt; + env->dats[ins->w[0]].p = ins->datapt; + env->dats[ins->w[0]].left = ins->dataptlen; break; default: ; @@ -570,7 +574,8 @@ enum creole_run_ret creole_step(struct creole_env *env, creole_word *sc) switch (ins.opcode) { case CREOLE_DB: - env->dats[ins.w[0]] = ins.datapt; + env->dats[ins->w[0]].p = ins->datapt; + env->dats[ins->w[0]].left = ins->dataptlen; break; case CREOLE_PUSH: check(read_val(env, &ins, 0, &a1)); diff --git a/creole.h b/creole.h index 8ebb2c2..4f8256d 100644 --- a/creole.h +++ b/creole.h @@ -106,7 +106,7 @@ struct creole_reader { }; struct creole_env { - unsigned char **dats; + struct creole_reader *dats; size_t datlen; creole_word *reg; @@ -117,6 +117,8 @@ struct creole_env { struct creole_reader r_current; struct creole_reader r_start; + + void *send_ctx; }; int creole_decode(struct creole_reader *r, struct creole_word *w);