Jacek Caban : vbscript: Added bytecode decompiler implementation.
Alexandre Julliard
julliard at winehq.org
Tue Sep 13 12:18:10 CDT 2011
Module: wine
Branch: master
Commit: d44940cc6a52d0ec9d53cd49dc17f502260916e7
URL: http://source.winehq.org/git/wine.git/?a=commit;h=d44940cc6a52d0ec9d53cd49dc17f502260916e7
Author: Jacek Caban <jacek at codeweavers.com>
Date: Tue Sep 13 11:39:41 2011 +0200
vbscript: Added bytecode decompiler implementation.
---
dlls/vbscript/compile.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 42 insertions(+), 1 deletions(-)
diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c
index c50452a..71af0f3 100644
--- a/dlls/vbscript/compile.c
+++ b/dlls/vbscript/compile.c
@@ -25,6 +25,7 @@
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(vbscript);
+WINE_DECLARE_DEBUG_CHANNEL(vbscript_disas);
typedef struct {
parser_ctx_t parser;
@@ -45,14 +46,51 @@ static HRESULT compile_expression(compile_ctx_t*,expression_t*);
static HRESULT compile_statement(compile_ctx_t*,statement_t*);
static const struct {
+ const char *op_str;
instr_arg_type_t arg1_type;
instr_arg_type_t arg2_type;
} instr_info[] = {
-#define X(n,a,b,c) {b,c},
+#define X(n,a,b,c) {#n,b,c},
OP_LIST
#undef X
};
+static void dump_instr_arg(instr_arg_type_t type, instr_arg_t *arg)
+{
+ switch(type) {
+ case ARG_STR:
+ case ARG_BSTR:
+ TRACE_(vbscript_disas)("\t%s", debugstr_w(arg->str));
+ break;
+ case ARG_INT:
+ TRACE_(vbscript_disas)("\t%d", arg->uint);
+ break;
+ case ARG_UINT:
+ case ARG_ADDR:
+ TRACE_(vbscript_disas)("\t%u", arg->uint);
+ break;
+ case ARG_DOUBLE:
+ TRACE_(vbscript_disas)("\t%lf", *arg->dbl);
+ break;
+ case ARG_NONE:
+ break;
+ default:
+ assert(0);
+ }
+}
+
+static void dump_code(compile_ctx_t *ctx)
+{
+ instr_t *instr;
+
+ for(instr = ctx->code->instrs; instr < ctx->code->instrs+ctx->instr_cnt; instr++) {
+ TRACE_(vbscript_disas)("%d:\t%s", instr-ctx->code->instrs, instr_info[instr->op].op_str);
+ dump_instr_arg(instr_info[instr->op].arg1_type, &instr->arg1);
+ dump_instr_arg(instr_info[instr->op].arg2_type, &instr->arg2);
+ TRACE_(vbscript_disas)("\n");
+ }
+}
+
static inline void *compiler_alloc(vbscode_t *vbscode, size_t size)
{
return vbsheap_alloc(&vbscode->heap, size);
@@ -670,6 +708,9 @@ HRESULT compile_script(script_ctx_t *script, const WCHAR *src, vbscode_t **ret)
parser_release(&ctx.parser);
+ if(TRACE_ON(vbscript_disas))
+ dump_code(&ctx);
+
list_add_tail(&script->code_list, &ctx.code->entry);
*ret = ctx.code;
return S_OK;
More information about the wine-cvs
mailing list