Whoops. Meant to compile that first

This commit is contained in:
Dan Hirsch 2013-03-17 22:01:54 -07:00
parent 17b03dbf4d
commit f5245eaa23
3 changed files with 10 additions and 9 deletions

View file

@ -213,7 +213,7 @@ HParseResult *run_trace(HAllocator *mm__, HRVMProg *orig_prog, HRVMTrace *trace,
break;
case SVM_ACTION:
// 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
// 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...
if (!(prog->action_count & (prog->action_count + 1))) {
// 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
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.
}
HAction *action = &prog->actions[prog->action_count];
HSVMAction *action = &prog->actions[prog->action_count];
action->action = action_func;
action->env = env;
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...
if (!(prog->length & (prog->length + 1))) {
// 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
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.
}

View file

@ -39,7 +39,7 @@ typedef struct HSVMContext_ {
// aliased anywhere.
typedef bool (*HSVMActionFunc)(HArena *arena, HSVMContext *ctx, void* env);
typedef struct HSVMAction_ {
HSVMActionFunc action
HSVMActionFunc action;
void* env;
} HSVMAction;

View file

@ -117,11 +117,12 @@ typedef const HParsedToken* (*HAction)(const HParseResult *p);
*/
typedef bool (*HPredicate)(HParseResult *p);
typedef struct HRVMProg_ HRVMProg;
typedef struct HParserVtable_ {
HParseResult* (*parse)(void *env, HParseState *state);
bool (*isValidRegular)(void *env);
bool (*isValidCF)(void *env);
bool (*compile_to_rvm)(struct HRVMProg_ *prog, void* env);
bool (*compile_to_rvm)(HRVMProg *prog, void* env);
} HParserVtable;
typedef struct HParser_ {