Jacek Caban : vbscript: Added call statement compilation implementation.
Alexandre Julliard
julliard at winehq.org
Wed Sep 7 12:35:30 CDT 2011
Module: wine
Branch: master
Commit: 5ecf4364493623054f9c7ea524e3a36157f17479
URL: http://source.winehq.org/git/wine.git/?a=commit;h=5ecf4364493623054f9c7ea524e3a36157f17479
Author: Jacek Caban <jacek at codeweavers.com>
Date: Wed Sep 7 14:08:47 2011 +0200
vbscript: Added call statement compilation implementation.
---
dlls/vbscript/compile.c | 70 ++++++++++++++++++++++++++++++++++++++++++---
dlls/vbscript/interp.c | 10 +++++-
dlls/vbscript/vbscript.h | 18 ++++++++++--
3 files changed, 88 insertions(+), 10 deletions(-)
diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c
index 4ac760b..d57abcf 100644
--- a/dlls/vbscript/compile.c
+++ b/dlls/vbscript/compile.c
@@ -34,6 +34,12 @@ typedef struct {
vbscode_t *code;
} compile_ctx_t;
+static inline instr_t *instr_ptr(compile_ctx_t *ctx, unsigned id)
+{
+ assert(id < ctx->instr_cnt);
+ return ctx->code->instrs + id;
+}
+
static unsigned push_instr(compile_ctx_t *ctx, vbsop_t op)
{
assert(ctx->instr_size && ctx->instr_size >= ctx->instr_cnt);
@@ -53,18 +59,72 @@ static unsigned push_instr(compile_ctx_t *ctx, vbsop_t op)
return ctx->instr_cnt++;
}
-static HRESULT compile_func(compile_ctx_t *ctx, statement_t *stat, function_t *func)
+static HRESULT push_instr_str(compile_ctx_t *ctx, vbsop_t op, const WCHAR *arg)
{
- func->code_off = ctx->instr_cnt;
+ unsigned instr;
- if(push_instr(ctx, OP_ret) == -1)
+ instr = push_instr(ctx, op);
+ if(instr == -1)
return E_OUTOFMEMORY;
- if(stat) {
- FIXME("statements compilation not implemented\n");
+ instr_ptr(ctx, instr)->arg1.str = arg;
+ return S_OK;
+}
+
+static HRESULT compile_member_expression(compile_ctx_t *ctx, member_expression_t *expr)
+{
+ HRESULT hres;
+
+ if(expr->args) {
+ FIXME("arguments not implemented\n");
return E_NOTIMPL;
}
+ if(expr->obj_expr) {
+ FIXME("obj_expr not implemented\n");
+ hres = E_NOTIMPL;
+ }else {
+ hres = push_instr_str(ctx, OP_icallv, expr->identifier);
+ }
+
+ return hres;
+}
+
+static HRESULT compile_statement(compile_ctx_t *ctx, statement_t *stat)
+{
+ HRESULT hres;
+
+ while(stat) {
+ switch(stat->type) {
+ case STAT_CALL:
+ hres = compile_member_expression(ctx, ((call_statement_t*)stat)->expr);
+ break;
+ default:
+ FIXME("Unimplemented statement type %d\n", stat->type);
+ hres = E_NOTIMPL;
+ }
+
+ if(FAILED(hres))
+ return hres;
+ stat = stat->next;
+ }
+
+ return S_OK;
+}
+
+static HRESULT compile_func(compile_ctx_t *ctx, statement_t *stat, function_t *func)
+{
+ HRESULT hres;
+
+ func->code_off = ctx->instr_cnt;
+
+ hres = compile_statement(ctx, stat);
+ if(FAILED(hres))
+ return hres;
+
+ if(push_instr(ctx, OP_ret) == -1)
+ return E_OUTOFMEMORY;
+
return S_OK;
}
diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c
index 7cee9c7..3ff6bbd 100644
--- a/dlls/vbscript/interp.c
+++ b/dlls/vbscript/interp.c
@@ -33,6 +33,12 @@ typedef struct {
typedef HRESULT (*instr_func_t)(exec_ctx_t*);
+static HRESULT interp_icallv(exec_ctx_t *ctx)
+{
+ FIXME("\n");
+ return E_NOTIMPL;
+}
+
static HRESULT interp_ret(exec_ctx_t *ctx)
{
TRACE("\n");
@@ -42,13 +48,13 @@ static HRESULT interp_ret(exec_ctx_t *ctx)
}
static const instr_func_t op_funcs[] = {
-#define X(x,n) interp_ ## x,
+#define X(x,n,a,b) interp_ ## x,
OP_LIST
#undef X
};
static const unsigned op_move[] = {
-#define X(x,n) n,
+#define X(x,n,a,b) n,
OP_LIST
#undef X
};
diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h
index 99ed4ba..bca630a 100644
--- a/dlls/vbscript/vbscript.h
+++ b/dlls/vbscript/vbscript.h
@@ -62,18 +62,30 @@ typedef struct {
HRESULT init_global(script_ctx_t*);
-#define OP_LIST \
- X(ret, 0)
+typedef enum {
+ ARG_NONE = 0,
+ ARG_STR
+} instr_arg_type_t;
+
+#define OP_LIST \
+ X(icallv, 1, ARG_STR, 0) \
+ X(ret, 0, 0, 0)
typedef enum {
-#define X(x,n) OP_##x,
+#define X(x,n,a,b) OP_##x,
OP_LIST
#undef X
OP_LAST
} vbsop_t;
+typedef union {
+ const WCHAR *str;
+} instr_arg_t;
+
typedef struct {
vbsop_t op;
+ instr_arg_t arg1;
+ instr_arg_t arg2;
} instr_t;
struct _function_t {
More information about the wine-cvs
mailing list