prepare for reading globals from ctx

0.96
Török Edvin 15 years ago
parent 18204a6726
commit bc157ce357
  1. 2
      libclamav/bytecode.c
  2. 2
      libclamav/bytecode_priv.h
  3. 10
      libclamav/bytecode_vm.c

@ -67,6 +67,8 @@ struct cli_bc_ctx *cli_bytecode_context_alloc(void)
ctx->line = 0;
ctx->col = 0;
ctx->mpool = NULL;
ctx->numGlobals = 0;
ctx->globals = NULL;
return ctx;
}

@ -147,6 +147,8 @@ struct cli_bc_ctx {
unsigned line;
unsigned col;
mpool_t *mpool;
uint32_t numGlobals;
uint8_t* globals;
};
struct cli_all_bc;
int cli_vm_execute(const struct cli_bc *bc, struct cli_bc_ctx *ctx, const struct cli_bc_func *func, const struct cli_bc_inst *inst);

@ -262,7 +262,15 @@ static always_inline struct stack_entry *pop_stack(struct stack *stack,
x = *(uint_type(n)*)&(from)[(p)];\
TRACE_R(x)
#define READN(x, n, p) READNfrom(func->numBytes, values, x, n, p)
#define READN(x, n, p)\
do {\
if (p&0x80000000) {\
uint32_t pg = p&0x7fffffff;\
READNfrom(ctx->numGlobals, ctx->globals, x, n, p);\
} else {\
READNfrom(func->numBytes, values, x, n, p);\
}\
} while (0)
#define READ1(x, p) READN(x, 8, p);\
x = x&1

Loading…
Cancel
Save