From 3c85122e05eb668a7faa63ba6003a9339f48c6ea Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Mon, 12 Sep 2011 12:32:50 +0200 Subject: [PATCH] vbscript: Added assign statement compiler implementation. --- dlls/vbscript/compile.c | 43 ++++++++++++++++++++++++++++++++++++++++ dlls/vbscript/interp.c | 6 ++++++ dlls/vbscript/vbscript.h | 1 + 3 files changed, 50 insertions(+) diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index a91cb5df324..8cc55c7538e 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -150,6 +150,23 @@ static BSTR alloc_bstr_arg(compile_ctx_t *ctx, const WCHAR *str) 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.bstr = bstr; + return S_OK; +} + static HRESULT push_instr_bstr_uint(compile_ctx_t *ctx, vbsop_t op, const WCHAR *arg1, unsigned arg2) { unsigned instr; @@ -272,12 +289,38 @@ static HRESULT compile_expression(compile_ctx_t *ctx, expression_t *expr) return S_OK; } +static HRESULT compile_assign_statement(compile_ctx_t *ctx, assign_statement_t *stat) +{ + HRESULT hres; + + hres = compile_expression(ctx, stat->value_expr); + if(FAILED(hres)) + return hres; + + if(stat->member_expr->args) { + FIXME("arguments support not implemented\n"); + return E_NOTIMPL; + } + + if(stat->member_expr->obj_expr) { + FIXME("obj_expr not implemented\n"); + hres = E_NOTIMPL; + }else { + hres = push_instr_bstr(ctx, OP_assign_ident, stat->member_expr->identifier); + } + + return hres; +} + static HRESULT compile_statement(compile_ctx_t *ctx, statement_t *stat) { HRESULT hres; while(stat) { switch(stat->type) { + case STAT_ASSIGN: + hres = compile_assign_statement(ctx, (assign_statement_t*)stat); + break; case STAT_CALL: hres = compile_member_expression(ctx, ((call_statement_t*)stat)->expr, FALSE); break; diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index 51ec8e72ea2..1e84afa39d6 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -217,6 +217,12 @@ static HRESULT interp_icallv(exec_ctx_t *ctx) return do_icall(ctx, NULL); } +static HRESULT interp_assign_ident(exec_ctx_t *ctx) +{ + FIXME("\n"); + return E_NOTIMPL; +} + static HRESULT interp_ret(exec_ctx_t *ctx) { TRACE("\n"); diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index e2cfdeaeb8c..070fdbb2970 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -89,6 +89,7 @@ typedef enum { #define OP_LIST \ X(add, 1, 0, 0) \ + X(assign_ident, 1, ARG_BSTR, 0) \ X(bool, 1, ARG_INT, 0) \ X(concat, 1, 0, 0) \ X(double, 1, ARG_DOUBLE, 0) \