2 * Copyright 2011 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/debug.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(vbscript);
34 typedef HRESULT (*instr_func_t)(exec_ctx_t*);
51 static HRESULT lookup_identifier(exec_ctx_t *ctx, BSTR name, ref_t *ref)
57 LIST_FOR_EACH_ENTRY(item, &ctx->script->named_items, named_item_t, entry) {
58 if(item->flags & SCRIPTITEM_GLOBALMEMBERS) {
59 hres = disp_get_id(item->disp, name, &id);
62 ref->u.d.disp = item->disp;
69 FIXME("create if no option explicit\n");
75 static HRESULT interp_icallv(exec_ctx_t *ctx)
77 BSTR identifier = ctx->instr->arg1.bstr;
78 const unsigned arg_cnt = ctx->instr->arg2.uint;
86 FIXME("arguments not implemented\n");
90 hres = lookup_identifier(ctx, identifier, &ref);
96 hres = disp_call(ctx->script, ref.u.d.disp, ref.u.d.id, &dp, NULL);
101 FIXME("%s not found\n", debugstr_w(identifier));
102 return DISP_E_UNKNOWNNAME;
108 static HRESULT interp_ret(exec_ctx_t *ctx)
116 static HRESULT interp_bool(exec_ctx_t *ctx)
122 static const instr_func_t op_funcs[] = {
123 #define X(x,n,a,b) interp_ ## x,
128 static const unsigned op_move[] = {
129 #define X(x,n,a,b) n,
134 HRESULT exec_script(script_ctx_t *ctx, function_t *func)
140 exec.code = func->code_ctx;
141 exec.instr = exec.code->instrs + func->code_off;
146 hres = op_funcs[op](&exec);
148 FIXME("Failed %08x\n", hres);
152 exec.instr += op_move[op];