From f5245eaa23b18c05e37d830612167ff79c00da60 Mon Sep 17 00:00:00 2001 From: Dan Hirsch <thequux@upstandinghackers.com> Date: Sun, 17 Mar 2013 22:01:54 -0700 Subject: [PATCH] Whoops. Meant to compile that first --- src/backends/regex.c | 14 +++++++------- src/backends/regex.h | 2 +- src/hammer.h | 3 ++- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/backends/regex.c b/src/backends/regex.c index 53032de8..fa695d94 100644 --- a/src/backends/regex.c +++ b/src/backends/regex.c @@ -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 - // power of two - prog->insns = prog->allocator->realloc(prog->insns, array_size * sizeof(*prog->insns)); + size_t array_size = (prog->length + 1) * 2; // action_count+1 is a + // power of two + prog->insns = prog->allocator->realloc(prog->allocator, prog->insns, array_size * sizeof(*prog->insns)); // TODO: Handle the allocation failed case nicely. } diff --git a/src/backends/regex.h b/src/backends/regex.h index 9d612987..3528e82f 100644 --- a/src/backends/regex.h +++ b/src/backends/regex.h @@ -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; diff --git a/src/hammer.h b/src/hammer.h index 1d8e2a86..ccb10c8d 100644 --- a/src/hammer.h +++ b/src/hammer.h @@ -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_ { -- GitLab