Module: wine Branch: master Commit: 060255d0841d517c6cc48ccaadf6bca4e4a8c2ab URL: http://source.winehq.org/git/wine.git/?a=commit;h=060255d0841d517c6cc48ccaad...
Author: Jacek Caban jacek@codeweavers.com Date: Thu Sep 8 14:54:23 2011 +0200
vbscript: Store call identifier as BSTR.
---
dlls/vbscript/Makefile.in | 1 + dlls/vbscript/compile.c | 47 ++++++++++++++++++++++++++++++++++++++++++-- dlls/vbscript/vbscript.h | 10 +++++++- 3 files changed, 53 insertions(+), 5 deletions(-)
diff --git a/dlls/vbscript/Makefile.in b/dlls/vbscript/Makefile.in index 9e27dd4..cd7e18d 100644 --- a/dlls/vbscript/Makefile.in +++ b/dlls/vbscript/Makefile.in @@ -1,4 +1,5 @@ MODULE = vbscript.dll +IMPORTS = oleaut32
C_SRCS = \ compile.c \ diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index d57abcf..49d933b 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -59,15 +59,45 @@ static unsigned push_instr(compile_ctx_t *ctx, vbsop_t op) return ctx->instr_cnt++; }
-static HRESULT push_instr_str(compile_ctx_t *ctx, vbsop_t op, const WCHAR *arg) +static BSTR alloc_bstr_arg(compile_ctx_t *ctx, const WCHAR *str) +{ + if(!ctx->code->bstr_pool_size) { + ctx->code->bstr_pool = heap_alloc(8 * sizeof(BSTR)); + if(!ctx->code->bstr_pool) + return NULL; + ctx->code->bstr_pool_size = 8; + }else if(ctx->code->bstr_pool_size == ctx->code->bstr_cnt) { + BSTR *new_pool; + + new_pool = heap_realloc(ctx->code->bstr_pool, ctx->code->bstr_pool_size*2*sizeof(BSTR)); + if(!new_pool) + return NULL; + + ctx->code->bstr_pool = new_pool; + ctx->code->bstr_pool_size *= 2; + } + + ctx->code->bstr_pool[ctx->code->bstr_cnt] = SysAllocString(str); + if(!ctx->code->bstr_pool[ctx->code->bstr_cnt]) + return NULL; + + return ctx->code->bstr_pool[ctx->code->bstr_cnt++]; +} + +static HRESULT push_instr_bstr(compile_ctx_t *ctx, vbsop_t op, const WCHAR *arg) { unsigned instr; + BSTR bstr; + + bstr = alloc_bstr_arg(ctx, arg); + if(!bstr) + return E_OUTOFMEMORY;
instr = push_instr(ctx, op); if(instr == -1) return E_OUTOFMEMORY;
- instr_ptr(ctx, instr)->arg1.str = arg; + instr_ptr(ctx, instr)->arg1.bstr = bstr; return S_OK; }
@@ -84,7 +114,7 @@ static HRESULT compile_member_expression(compile_ctx_t *ctx, member_expression_t FIXME("obj_expr not implemented\n"); hres = E_NOTIMPL; }else { - hres = push_instr_str(ctx, OP_icallv, expr->identifier); + hres = push_instr_bstr(ctx, OP_icallv, expr->identifier); }
return hres; @@ -130,7 +160,14 @@ static HRESULT compile_func(compile_ctx_t *ctx, statement_t *stat, function_t *f
void release_vbscode(vbscode_t *code) { + unsigned i; + list_remove(&code->entry); + + for(i=0; i < code->bstr_cnt; i++) + SysFreeString(code->bstr_pool[i]); + + heap_free(code->bstr_pool); heap_free(code->source); heap_free(code->instrs); heap_free(code); @@ -159,6 +196,10 @@ static vbscode_t *alloc_vbscode(compile_ctx_t *ctx, const WCHAR *source) ctx->instr_cnt = 0; ctx->instr_size = 32;
+ ret->bstr_pool = NULL; + ret->bstr_pool_size = 0; + ret->bstr_cnt = 0; + ret->global_code.code_ctx = ret;
list_init(&ret->entry); diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index bca630a..9942ac7 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -64,11 +64,12 @@ HRESULT init_global(script_ctx_t*);
typedef enum { ARG_NONE = 0, - ARG_STR + ARG_STR, + ARG_BSTR } instr_arg_type_t;
#define OP_LIST \ - X(icallv, 1, ARG_STR, 0) \ + X(icallv, 1, ARG_BSTR, 0) \ X(ret, 0, 0, 0)
typedef enum { @@ -80,6 +81,7 @@ OP_LIST
typedef union { const WCHAR *str; + BSTR bstr; } instr_arg_t;
typedef struct { @@ -100,6 +102,10 @@ struct _vbscode_t { BOOL global_executed; function_t global_code;
+ BSTR *bstr_pool; + unsigned bstr_pool_size; + unsigned bstr_cnt; + struct list entry; };