modify reader
This commit is contained in:
parent
6d30be57f7
commit
22674528da
9
creole.c
9
creole.c
|
@ -338,6 +338,7 @@ int creole_encode(creole_word i, unsigned encode_to, unsigned high_bits,
|
||||||
struct ins {
|
struct ins {
|
||||||
unsigned char *start;
|
unsigned char *start;
|
||||||
unsigned char *datapt;
|
unsigned char *datapt;
|
||||||
|
size_t dataptlen;
|
||||||
enum creole_opcode opcode;
|
enum creole_opcode opcode;
|
||||||
creole_word w[CREOLE_MAX_ARG];
|
creole_word w[CREOLE_MAX_ARG];
|
||||||
creole_word w_flags[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) {
|
if (ins->opcode == CREOLE_DB) {
|
||||||
ins->datapt = r->p;
|
ins->datapt = r->p;
|
||||||
|
ins->dataptlen = 0;
|
||||||
do {
|
do {
|
||||||
if (!creole_decode(r, &w))
|
if (!creole_decode(r, &w))
|
||||||
return CREOLE_ARG_READ_ERROR;
|
return CREOLE_ARG_READ_ERROR;
|
||||||
} while (w.len != 1);
|
} while (w.len != 1);
|
||||||
|
ins->dataptlen = r->p - ins->datapt - 1;
|
||||||
if (w.word != 0)
|
if (w.word != 0)
|
||||||
return CREOLE_LAST_READ_ERROR;
|
return CREOLE_LAST_READ_ERROR;
|
||||||
return CREOLE_COMPILE_OK;
|
return CREOLE_COMPILE_OK;
|
||||||
|
@ -430,7 +433,8 @@ add_to_env(struct creole_env *env, struct ins *ins)
|
||||||
{
|
{
|
||||||
switch (ins->opcode) {
|
switch (ins->opcode) {
|
||||||
case CREOLE_DB:
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
;
|
;
|
||||||
|
@ -570,7 +574,8 @@ enum creole_run_ret creole_step(struct creole_env *env, creole_word *sc)
|
||||||
|
|
||||||
switch (ins.opcode) {
|
switch (ins.opcode) {
|
||||||
case CREOLE_DB:
|
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;
|
break;
|
||||||
case CREOLE_PUSH:
|
case CREOLE_PUSH:
|
||||||
check(read_val(env, &ins, 0, &a1));
|
check(read_val(env, &ins, 0, &a1));
|
||||||
|
|
4
creole.h
4
creole.h
|
@ -106,7 +106,7 @@ struct creole_reader {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct creole_env {
|
struct creole_env {
|
||||||
unsigned char **dats;
|
struct creole_reader *dats;
|
||||||
size_t datlen;
|
size_t datlen;
|
||||||
|
|
||||||
creole_word *reg;
|
creole_word *reg;
|
||||||
|
@ -117,6 +117,8 @@ struct creole_env {
|
||||||
|
|
||||||
struct creole_reader r_current;
|
struct creole_reader r_current;
|
||||||
struct creole_reader r_start;
|
struct creole_reader r_start;
|
||||||
|
|
||||||
|
void *send_ctx;
|
||||||
};
|
};
|
||||||
|
|
||||||
int creole_decode(struct creole_reader *r, struct creole_word *w);
|
int creole_decode(struct creole_reader *r, struct creole_word *w);
|
||||||
|
|
Loading…
Reference in New Issue