Whoops. Meant to compile that first
This commit is contained in:
parent
17b03dbf4d
commit
f5245eaa23
3 changed files with 10 additions and 9 deletions
|
|
@ -213,7 +213,7 @@ HParseResult *run_trace(HAllocator *mm__, HRVMProg *orig_prog, HRVMTrace *trace,
|
||||||
break;
|
break;
|
||||||
case SVM_ACTION:
|
case SVM_ACTION:
|
||||||
// Action should modify stack appropriately
|
// Action should modify stack appropriately
|
||||||
if (!orig_prog->actions[cur->arg].fn(arena, &ctx, orig_prog->actions[cur->arg].env)) {
|
if (!orig_prog->actions[cur->arg].action(arena, &ctx, orig_prog->actions[cur->arg].env)) {
|
||||||
// action failed... abort somehow
|
// action failed... abort somehow
|
||||||
// TODO: Actually abort
|
// TODO: Actually abort
|
||||||
}
|
}
|
||||||
|
|
@ -257,13 +257,13 @@ uint16_t h_rvm_create_action(HRVMProg *prog, HSVMActionFunc action_func, void* e
|
||||||
// Ensure that there's room in the action array...
|
// Ensure that there's room in the action array...
|
||||||
if (!(prog->action_count & (prog->action_count + 1))) {
|
if (!(prog->action_count & (prog->action_count + 1))) {
|
||||||
// needs to be scaled up.
|
// needs to be scaled up.
|
||||||
array_size = (prog->action_count + 1) * 2; // action_count+1 is a
|
size_t array_size = (prog->action_count + 1) * 2; // action_count+1 is a
|
||||||
// power of two
|
// power of two
|
||||||
prog->actions = prog->allocator->realloc(prog->actions, array_size * sizeof(*prog->actions));
|
prog->actions = prog->allocator->realloc(prog->allocator, prog->actions, array_size * sizeof(*prog->actions));
|
||||||
// TODO: Handle the allocation failed case nicely.
|
// TODO: Handle the allocation failed case nicely.
|
||||||
}
|
}
|
||||||
|
|
||||||
HAction *action = &prog->actions[prog->action_count];
|
HSVMAction *action = &prog->actions[prog->action_count];
|
||||||
action->action = action_func;
|
action->action = action_func;
|
||||||
action->env = env;
|
action->env = env;
|
||||||
return prog->action_count++;
|
return prog->action_count++;
|
||||||
|
|
@ -273,9 +273,9 @@ uint16_t h_rvm_insert_insn(HRVMProg *prog, HRVMOp op, uint16_t arg) {
|
||||||
// Ensure that there's room in the insn array...
|
// Ensure that there's room in the insn array...
|
||||||
if (!(prog->length & (prog->length + 1))) {
|
if (!(prog->length & (prog->length + 1))) {
|
||||||
// needs to be scaled up.
|
// needs to be scaled up.
|
||||||
array_size = (prog->length + 1) * 2; // action_count+1 is a
|
size_t array_size = (prog->length + 1) * 2; // action_count+1 is a
|
||||||
// power of two
|
// power of two
|
||||||
prog->insns = prog->allocator->realloc(prog->insns, array_size * sizeof(*prog->insns));
|
prog->insns = prog->allocator->realloc(prog->allocator, prog->insns, array_size * sizeof(*prog->insns));
|
||||||
// TODO: Handle the allocation failed case nicely.
|
// TODO: Handle the allocation failed case nicely.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ typedef struct HSVMContext_ {
|
||||||
// aliased anywhere.
|
// aliased anywhere.
|
||||||
typedef bool (*HSVMActionFunc)(HArena *arena, HSVMContext *ctx, void* env);
|
typedef bool (*HSVMActionFunc)(HArena *arena, HSVMContext *ctx, void* env);
|
||||||
typedef struct HSVMAction_ {
|
typedef struct HSVMAction_ {
|
||||||
HSVMActionFunc action
|
HSVMActionFunc action;
|
||||||
void* env;
|
void* env;
|
||||||
} HSVMAction;
|
} HSVMAction;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -117,11 +117,12 @@ typedef const HParsedToken* (*HAction)(const HParseResult *p);
|
||||||
*/
|
*/
|
||||||
typedef bool (*HPredicate)(HParseResult *p);
|
typedef bool (*HPredicate)(HParseResult *p);
|
||||||
|
|
||||||
|
typedef struct HRVMProg_ HRVMProg;
|
||||||
typedef struct HParserVtable_ {
|
typedef struct HParserVtable_ {
|
||||||
HParseResult* (*parse)(void *env, HParseState *state);
|
HParseResult* (*parse)(void *env, HParseState *state);
|
||||||
bool (*isValidRegular)(void *env);
|
bool (*isValidRegular)(void *env);
|
||||||
bool (*isValidCF)(void *env);
|
bool (*isValidCF)(void *env);
|
||||||
bool (*compile_to_rvm)(struct HRVMProg_ *prog, void* env);
|
bool (*compile_to_rvm)(HRVMProg *prog, void* env);
|
||||||
} HParserVtable;
|
} HParserVtable;
|
||||||
|
|
||||||
typedef struct HParser_ {
|
typedef struct HParser_ {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue