Module: wine Branch: master Commit: 0c0b252c247e022673bfba7afa39e389947a62ec URL: http://source.winehq.org/git/wine.git/?a=commit;h=0c0b252c247e022673bfba7afa...
Author: Jacek Caban jacek@codeweavers.com Date: Wed Sep 14 13:55:57 2011 +0200
vbscript: Added function arguments compiler implementation.
---
dlls/vbscript/compile.c | 23 +++++++++++++++++++++-- dlls/vbscript/vbscript.h | 7 +++++++ 2 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index 651bf7c..386caf7 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -658,9 +658,26 @@ static HRESULT create_function(compile_ctx_t *ctx, function_decl_t *decl, functi func->code_ctx = ctx->code; func->type = decl->type;
+ func->arg_cnt = 0; if(decl->args) { - FIXME("arguments not implemented\n"); - return E_NOTIMPL; + arg_decl_t *arg; + unsigned i; + + for(arg = decl->args; arg; arg = arg->next) + func->arg_cnt++; + + func->args = compiler_alloc(ctx->code, func->arg_cnt * sizeof(arg_desc_t)); + if(!func->args) + return E_OUTOFMEMORY; + + for(i = 0, arg = decl->args; arg; arg = arg->next, i++) { + func->args[i].name = compiler_alloc_string(ctx->code, arg->name); + if(!func->args[i].name) + return E_OUTOFMEMORY; + func->args[i].by_ref = arg->by_ref; + } + }else { + func->args = NULL; }
hres = compile_func(ctx, decl->body, func); @@ -761,6 +778,8 @@ static vbscode_t *alloc_vbscode(compile_ctx_t *ctx, const WCHAR *source) ret->global_code.type = FUNC_GLOBAL; ret->global_code.name = NULL; ret->global_code.code_ctx = ret; + ret->global_code.arg_cnt = 0; + ret->global_code.args = NULL;
list_init(&ret->entry); return ret; diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index d541e9d..0e6d57e 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -152,6 +152,11 @@ typedef struct { instr_arg_t arg2; } instr_t;
+typedef struct { + const WCHAR *name; + BOOL by_ref; +} arg_desc_t; + typedef enum { FUNC_GLOBAL, FUNC_SUB @@ -160,6 +165,8 @@ typedef enum { struct _function_t { function_type_t type; const WCHAR *name; + arg_desc_t *args; + unsigned arg_cnt; unsigned code_off; vbscode_t *code_ctx; function_t *next;