winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
September 2011
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
2 participants
996 discussions
Start a n
N
ew thread
Jacek Caban : vbscript: Added function arguments compiler implementation.
by Alexandre Julliard
14 Sep '11
14 Sep '11
Module: wine Branch: master Commit: 0c0b252c247e022673bfba7afa39e389947a62ec URL:
http://source.winehq.org/git/wine.git/?a=commit;h=0c0b252c247e022673bfba7af…
Author: Jacek Caban <jacek(a)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;
1
0
0
0
Jacek Caban : vbscript: Added function invocation supprot to do_icall.
by Alexandre Julliard
14 Sep '11
14 Sep '11
Module: wine Branch: master Commit: 48d04b220b0e150f796dc47c3812cc72863574b7 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=48d04b220b0e150f796dc47c3…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Wed Sep 14 12:56:01 2011 +0200 vbscript: Added function invocation supprot to do_icall. --- dlls/vbscript/interp.c | 18 +++++++++++++++--- dlls/vbscript/tests/lang.vbs | 4 ++++ dlls/vbscript/vbscript.c | 2 +- dlls/vbscript/vbscript.h | 7 ++++++- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index adec28f..b697988 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -266,8 +266,10 @@ static HRESULT do_icall(exec_ctx_t *ctx, VARIANT *res) return hres; break; case REF_FUNC: - FIXME("functions not implemented\n"); - return E_NOTIMPL; + hres = exec_script(ctx->script, ref.u.f, &dp, res); + if(FAILED(hres)) + return hres; + break; case REF_NONE: FIXME("%s not found\n", debugstr_w(identifier)); return DISP_E_UNKNOWNNAME; @@ -812,12 +814,22 @@ OP_LIST #undef X }; -HRESULT exec_script(script_ctx_t *ctx, function_t *func) +HRESULT exec_script(script_ctx_t *ctx, function_t *func, DISPPARAMS *dp, VARIANT *res) { exec_ctx_t exec; vbsop_t op; HRESULT hres = S_OK; + if(res) { + FIXME("returning value is not implemented\n"); + return E_NOTIMPL; + } + + if(dp && arg_cnt(dp)) { + FIXME("arguments not implemented\n"); + return E_NOTIMPL; + } + exec.stack_size = 16; exec.top = 0; exec.stack = heap_alloc(exec.stack_size * sizeof(VARIANT)); diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index 60ca988..0c4c10f 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -175,4 +175,8 @@ Sub testsub End Sub end if +x = false +Call testsub +Call ok(x, "x is false, testsub not called?") + reportSuccess() diff --git a/dlls/vbscript/vbscript.c b/dlls/vbscript/vbscript.c index f6891c7..cb28a9a 100644 --- a/dlls/vbscript/vbscript.c +++ b/dlls/vbscript/vbscript.c @@ -77,7 +77,7 @@ static HRESULT exec_global_code(script_ctx_t *ctx, vbscode_t *code) code->global_executed = TRUE; IActiveScriptSite_OnEnterScript(ctx->site); - hres = exec_script(ctx, &code->global_code); + hres = exec_script(ctx, &code->global_code, NULL, NULL); IActiveScriptSite_OnLeaveScript(ctx->site); return hres; diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index 32b19ab..d541e9d 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -65,6 +65,11 @@ HRESULT disp_get_id(IDispatch*,BSTR,DISPID*); HRESULT disp_call(script_ctx_t*,IDispatch*,DISPID,DISPPARAMS*,VARIANT*); HRESULT disp_propput(script_ctx_t*,IDispatch*,DISPID,VARIANT*); +static inline unsigned arg_cnt(const DISPPARAMS *dp) +{ + return dp->cArgs - dp->cNamedArgs; +} + typedef struct _dynamic_var_t { struct _dynamic_var_t *next; VARIANT v; @@ -179,7 +184,7 @@ struct _vbscode_t { void release_vbscode(vbscode_t*) DECLSPEC_HIDDEN; HRESULT compile_script(script_ctx_t*,const WCHAR*,vbscode_t**) DECLSPEC_HIDDEN; -HRESULT exec_script(script_ctx_t*,function_t*) DECLSPEC_HIDDEN; +HRESULT exec_script(script_ctx_t*,function_t*,DISPPARAMS*,VARIANT*) DECLSPEC_HIDDEN; HRESULT WINAPI VBScriptFactory_CreateInstance(IClassFactory*,IUnknown*,REFIID,void**);
1
0
0
0
Jacek Caban : vbscript: Added functions lookup implementation.
by Alexandre Julliard
14 Sep '11
14 Sep '11
Module: wine Branch: master Commit: f00a8ec04dd5f3e30a6527390875aa73d8379f81 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=f00a8ec04dd5f3e30a6527390…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Wed Sep 14 12:55:42 2011 +0200 vbscript: Added functions lookup implementation. --- dlls/vbscript/interp.c | 19 ++++++++++++++++++- 1 files changed, 18 insertions(+), 1 deletions(-) diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index 66c2cf1..adec28f 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -41,7 +41,8 @@ typedef HRESULT (*instr_func_t)(exec_ctx_t*); typedef enum { REF_NONE, REF_DISP, - REF_VAR + REF_VAR, + REF_FUNC } ref_type_t; typedef struct { @@ -52,6 +53,7 @@ typedef struct { DISPID id; } d; VARIANT *v; + function_t *f; } u; } ref_t; @@ -79,12 +81,21 @@ static BOOL lookup_dynamic_vars(dynamic_var_t *var, const WCHAR *name, ref_t *re static HRESULT lookup_identifier(exec_ctx_t *ctx, BSTR name, ref_t *ref) { named_item_t *item; + function_t *func; DISPID id; HRESULT hres; if(lookup_dynamic_vars(ctx->script->global_vars, name, ref)) return S_OK; + for(func = ctx->script->global_funcs; func; func = func->next) { + if(!strcmpiW(func->name, name)) { + ref->type = REF_FUNC; + ref->u.f = func; + return S_OK; + } + } + LIST_FOR_EACH_ENTRY(item, &ctx->script->named_items, named_item_t, entry) { if(item->flags & SCRIPTITEM_GLOBALMEMBERS) { hres = disp_get_id(item->disp, name, &id); @@ -254,6 +265,9 @@ static HRESULT do_icall(exec_ctx_t *ctx, VARIANT *res) if(FAILED(hres)) return hres; break; + case REF_FUNC: + FIXME("functions not implemented\n"); + return E_NOTIMPL; case REF_NONE: FIXME("%s not found\n", debugstr_w(identifier)); return DISP_E_UNKNOWNNAME; @@ -313,6 +327,9 @@ static HRESULT assign_ident(exec_ctx_t *ctx, BSTR name, VARIANT *val, BOOL own_v if(own_val) VariantClear(val); break; + case REF_FUNC: + FIXME("functions not implemented\n"); + return E_NOTIMPL; case REF_NONE: FIXME("%s not found\n", debugstr_w(name)); if(own_val)
1
0
0
0
Jacek Caban : vbscript: Store global functions in script_ctx_t.
by Alexandre Julliard
14 Sep '11
14 Sep '11
Module: wine Branch: master Commit: 190ea000104758726de93f91419e183fa8f10039 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=190ea000104758726de93f914…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Wed Sep 14 12:55:32 2011 +0200 vbscript: Store global functions in script_ctx_t. --- dlls/vbscript/compile.c | 21 +++++++++++++++++++++ dlls/vbscript/vbscript.h | 1 + 2 files changed, 22 insertions(+), 0 deletions(-) diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index 4e8cd06..651bf7c 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -674,18 +674,25 @@ static HRESULT create_function(compile_ctx_t *ctx, function_decl_t *decl, functi static BOOL lookup_script_identifier(script_ctx_t *script, const WCHAR *identifier) { dynamic_var_t *var; + function_t *func; for(var = script->global_vars; var; var = var->next) { if(!strcmpiW(var->name, identifier)) return TRUE; } + for(func = script->global_funcs; func; func = func->next) { + if(!strcmpiW(func->name, identifier)) + return TRUE; + } + return FALSE; } static HRESULT check_script_collisions(compile_ctx_t *ctx, script_ctx_t *script) { dynamic_var_t *var; + function_t *func; for(var = ctx->global_vars; var; var = var->next) { if(lookup_script_identifier(script, var->name)) { @@ -694,6 +701,13 @@ static HRESULT check_script_collisions(compile_ctx_t *ctx, script_ctx_t *script) } } + for(func = ctx->funcs; func; func = func->next) { + if(lookup_script_identifier(script, func->name)) { + FIXME("%s: redefined\n", debugstr_w(func->name)); + return E_FAIL; + } + } + return S_OK; } @@ -815,6 +829,13 @@ HRESULT compile_script(script_ctx_t *script, const WCHAR *src, vbscode_t **ret) script->global_vars = ctx.global_vars; } + if(ctx.funcs) { + for(new_func = ctx.funcs; new_func->next; new_func = new_func->next); + + new_func->next = script->global_funcs; + script->global_funcs = ctx.funcs; + } + if(TRACE_ON(vbscript_disas)) dump_code(&ctx); diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index 41dea38..32b19ab 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -80,6 +80,7 @@ struct _script_ctx_t { vbdisp_t *script_obj; dynamic_var_t *global_vars; + function_t *global_funcs; struct list code_list; struct list named_items;
1
0
0
0
Jacek Caban : vbscript: Added function compiler implementation.
by Alexandre Julliard
14 Sep '11
14 Sep '11
Module: wine Branch: master Commit: 413bc99044e75a9cd9aafcfd14f259627aaca3a4 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=413bc99044e75a9cd9aafcfd1…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Wed Sep 14 12:55:07 2011 +0200 vbscript: Added function compiler implementation. --- dlls/vbscript/compile.c | 142 +++++++++++++++++++++++++++++++++++------ dlls/vbscript/tests/lang.vbs | 6 ++ dlls/vbscript/vbscript.h | 3 + 3 files changed, 130 insertions(+), 21 deletions(-) diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index d39b94e..4e8cd06 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -40,6 +40,10 @@ typedef struct { dim_decl_t *dim_decls; dynamic_var_t *global_vars; + + function_t *func; + function_t *funcs; + function_decl_t *func_decls; } compile_ctx_t; static HRESULT compile_expression(compile_ctx_t*,expression_t*); @@ -514,6 +518,18 @@ static HRESULT compile_dim_statement(compile_ctx_t *ctx, dim_statement_t *stat) return S_OK; } +static HRESULT compile_function_statement(compile_ctx_t *ctx, function_statement_t *stat) +{ + if(ctx->func != &ctx->code->global_code) { + FIXME("Function is not in the global code\n"); + return E_FAIL; + } + + stat->func_decl->next = ctx->func_decls; + ctx->func_decls = stat->func_decl; + return S_OK; +} + static HRESULT compile_statement(compile_ctx_t *ctx, statement_t *stat) { HRESULT hres; @@ -529,6 +545,9 @@ static HRESULT compile_statement(compile_ctx_t *ctx, statement_t *stat) case STAT_DIM: hres = compile_dim_statement(ctx, (dim_statement_t*)stat); break; + case STAT_FUNC: + hres = compile_function_statement(ctx, (function_statement_t*)stat); + break; case STAT_IF: hres = compile_if_statement(ctx, (if_statement_t*)stat); break; @@ -545,11 +564,11 @@ static HRESULT compile_statement(compile_ctx_t *ctx, statement_t *stat) return S_OK; } -static void resolve_labels(compile_ctx_t *ctx) +static void resolve_labels(compile_ctx_t *ctx, unsigned off) { instr_t *instr; - for(instr = ctx->code->instrs; instr < ctx->code->instrs+ctx->instr_cnt; instr++) { + for(instr = ctx->code->instrs+off; instr < ctx->code->instrs+ctx->instr_cnt; instr++) { if(instr_info[instr->op].arg1_type == ARG_ADDR && (instr->arg1.uint & LABEL_FLAG)) { assert((instr->arg1.uint & ~LABEL_FLAG) < ctx->labels_cnt); instr->arg1.uint = ctx->labels[instr->arg1.uint & ~LABEL_FLAG]; @@ -566,38 +585,92 @@ static HRESULT compile_func(compile_ctx_t *ctx, statement_t *stat, function_t *f func->code_off = ctx->instr_cnt; + ctx->func = func; + ctx->dim_decls = NULL; hres = compile_statement(ctx, stat); + ctx->func = NULL; if(FAILED(hres)) return hres; if(push_instr(ctx, OP_ret) == -1) return E_OUTOFMEMORY; - resolve_labels(ctx); + resolve_labels(ctx, func->code_off); if(ctx->dim_decls) { dim_decl_t *dim_decl; - dynamic_var_t *new_var; - for(dim_decl = ctx->dim_decls; dim_decl; dim_decl = dim_decl->next) { - new_var = compiler_alloc(ctx->code, sizeof(*new_var)); - if(!new_var) - return E_OUTOFMEMORY; + if(func->type == FUNC_GLOBAL) { + dynamic_var_t *new_var; - new_var->name = compiler_alloc_string(ctx->code, dim_decl->name); - if(!new_var->name) - return E_OUTOFMEMORY; + for(dim_decl = ctx->dim_decls; dim_decl; dim_decl = dim_decl->next) { + new_var = compiler_alloc(ctx->code, sizeof(*new_var)); + if(!new_var) + return E_OUTOFMEMORY; - V_VT(&new_var->v) = VT_EMPTY; + new_var->name = compiler_alloc_string(ctx->code, dim_decl->name); + if(!new_var->name) + return E_OUTOFMEMORY; - new_var->next = ctx->global_vars; - ctx->global_vars = new_var; + V_VT(&new_var->v) = VT_EMPTY; + + new_var->next = ctx->global_vars; + ctx->global_vars = new_var; + } + }else { + FIXME("var not implemented for functions\n"); } } return S_OK; } +static BOOL lookup_funcs_name(compile_ctx_t *ctx, const WCHAR *name) +{ + function_t *iter; + + for(iter = ctx->funcs; iter; iter = iter->next) { + if(!strcmpiW(iter->name, name)) + return TRUE; + } + + return FALSE; +} + +static HRESULT create_function(compile_ctx_t *ctx, function_decl_t *decl, function_t **ret) +{ + function_t *func; + HRESULT hres; + + if(lookup_dim_decls(ctx, decl->name) || lookup_funcs_name(ctx, decl->name)) { + FIXME("%s: redefinition\n", debugstr_w(decl->name)); + return E_FAIL; + } + + func = compiler_alloc(ctx->code, sizeof(*func)); + if(!func) + return E_OUTOFMEMORY; + + func->name = compiler_alloc_string(ctx->code, decl->name); + if(!func->name) + return E_OUTOFMEMORY; + + func->code_ctx = ctx->code; + func->type = decl->type; + + if(decl->args) { + FIXME("arguments not implemented\n"); + return E_NOTIMPL; + } + + hres = compile_func(ctx, decl->body, func); + if(FAILED(hres)) + return hres; + + *ret = func; + return S_OK; +} + static BOOL lookup_script_identifier(script_ctx_t *script, const WCHAR *identifier) { dynamic_var_t *var; @@ -671,25 +744,40 @@ static vbscode_t *alloc_vbscode(compile_ctx_t *ctx, const WCHAR *source) ret->bstr_pool_size = 0; ret->bstr_cnt = 0; + ret->global_code.type = FUNC_GLOBAL; + ret->global_code.name = NULL; ret->global_code.code_ctx = ret; list_init(&ret->entry); return ret; } +static void release_compiler(compile_ctx_t *ctx) +{ + parser_release(&ctx->parser); + heap_free(ctx->labels); + if(ctx->code) + release_vbscode(ctx->code); +} + HRESULT compile_script(script_ctx_t *script, const WCHAR *src, vbscode_t **ret) { + function_t *new_func; + function_decl_t *func_decl; compile_ctx_t ctx; + vbscode_t *code; HRESULT hres; hres = parse_script(&ctx.parser, src); if(FAILED(hres)) return hres; - ctx.code = alloc_vbscode(&ctx, src); + code = ctx.code = alloc_vbscode(&ctx, src); if(!ctx.code) return E_OUTOFMEMORY; + ctx.funcs = NULL; + ctx.func_decls = NULL; ctx.global_vars = NULL; ctx.dim_decls = NULL; ctx.labels = NULL; @@ -697,13 +785,24 @@ HRESULT compile_script(script_ctx_t *script, const WCHAR *src, vbscode_t **ret) hres = compile_func(&ctx, ctx.parser.stats, &ctx.code->global_code); if(FAILED(hres)) { - release_vbscode(ctx.code); + release_compiler(&ctx); return hres; } + for(func_decl = ctx.func_decls; func_decl; func_decl = func_decl->next) { + hres = create_function(&ctx, func_decl, &new_func); + if(FAILED(hres)) { + release_compiler(&ctx); + return hres; + } + + new_func->next = ctx.funcs; + ctx.funcs = new_func; + } + hres = check_script_collisions(&ctx, script); if(FAILED(hres)) { - release_vbscode(ctx.code); + release_compiler(&ctx); return hres; } @@ -716,12 +815,13 @@ HRESULT compile_script(script_ctx_t *script, const WCHAR *src, vbscode_t **ret) script->global_vars = ctx.global_vars; } - parser_release(&ctx.parser); - if(TRACE_ON(vbscript_disas)) dump_code(&ctx); - list_add_tail(&script->code_list, &ctx.code->entry); - *ret = ctx.code; + ctx.code = NULL; + release_compiler(&ctx); + + list_add_tail(&script->code_list, &code->entry); + *ret = code; return S_OK; } diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index 12bdaf5..60ca988 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -169,4 +169,10 @@ ElseIf not False Then End If Call ok(x, "elseif not called?") +if false then +Sub testsub + x = true +End Sub +end if + reportSuccess() diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index b52aa09..41dea38 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -152,8 +152,11 @@ typedef enum { } function_type_t; struct _function_t { + function_type_t type; + const WCHAR *name; unsigned code_off; vbscode_t *code_ctx; + function_t *next; }; struct _vbscode_t {
1
0
0
0
Jacek Caban : vbscript: Added sub statement parser implementation.
by Alexandre Julliard
14 Sep '11
14 Sep '11
Module: wine Branch: master Commit: d220dd291e4488649a05ca25afd8545b5f6b7fed URL:
http://source.winehq.org/git/wine.git/?a=commit;h=d220dd291e4488649a05ca25a…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Wed Sep 14 12:54:50 2011 +0200 vbscript: Added sub statement parser implementation. --- dlls/vbscript/parse.h | 24 +++++++++++++- dlls/vbscript/parser.y | 75 ++++++++++++++++++++++++++++++++++++++++++++- dlls/vbscript/vbscript.h | 5 +++ 3 files changed, 100 insertions(+), 4 deletions(-) diff --git a/dlls/vbscript/parse.h b/dlls/vbscript/parse.h index cfeb8c0..9b837c2 100644 --- a/dlls/vbscript/parse.h +++ b/dlls/vbscript/parse.h @@ -85,8 +85,9 @@ typedef struct { typedef enum { STAT_ASSIGN, STAT_CALL, - STAT_IF, - STAT_DIM + STAT_DIM, + STAT_FUNC, + STAT_IF } statement_type_t; typedef struct _statement_t { @@ -115,6 +116,25 @@ typedef struct _dim_statement_t { dim_decl_t *dim_decls; } dim_statement_t; +typedef struct _arg_decl_t { + const WCHAR *name; + BOOL by_ref; + struct _arg_decl_t *next; +} arg_decl_t; + +typedef struct _function_decl_t { + const WCHAR *name; + function_type_t type; + arg_decl_t *args; + statement_t *body; + struct _function_decl_t *next; +} function_decl_t; + +typedef struct _function_statement_t { + statement_t stat; + function_decl_t *func_decl; +} function_statement_t; + typedef struct _elseif_decl_t { expression_t *expr; statement_t *stat; diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index c9f9c76..4964d71 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -48,10 +48,13 @@ static member_expression_t *new_member_expression(parser_ctx_t*,expression_t*,co static statement_t *new_call_statement(parser_ctx_t*,member_expression_t*); static statement_t *new_assign_statement(parser_ctx_t*,member_expression_t*,expression_t*); static statement_t *new_dim_statement(parser_ctx_t*,dim_decl_t*); - static statement_t *new_if_statement(parser_ctx_t*,expression_t*,statement_t*,elseif_decl_t*,statement_t*); +static statement_t *new_if_statement(parser_ctx_t*,expression_t*,statement_t*,elseif_decl_t*,statement_t*); +static statement_t *new_function_statement(parser_ctx_t*,function_decl_t*); static dim_decl_t *new_dim_decl(parser_ctx_t*,const WCHAR*,dim_decl_t*); static elseif_decl_t *new_elseif_decl(parser_ctx_t*,expression_t*,statement_t*); +static function_decl_t *new_function_decl(parser_ctx_t*,const WCHAR*,function_type_t,arg_decl_t*,statement_t*); +static arg_decl_t *new_argument_decl(parser_ctx_t*,const WCHAR*,BOOL); #define CHECK_ERROR if(((parser_ctx_t*)ctx)->hres != S_OK) YYABORT @@ -67,6 +70,8 @@ static elseif_decl_t *new_elseif_decl(parser_ctx_t*,expression_t*,statement_t*); member_expression_t *member; elseif_decl_t *elseif; dim_decl_t *dim_decl; + function_decl_t *func_decl; + arg_decl_t *arg_decl; LONG lng; BOOL bool; double dbl; @@ -89,13 +94,15 @@ static elseif_decl_t *new_elseif_decl(parser_ctx_t*,expression_t*,statement_t*); %token <lng> tLong tShort %token <dbl> tDouble -%type <statement> Statement StatementNl StatementsNl IfStatement Else_opt +%type <statement> Statement StatementNl StatementsNl StatementsNl_opt IfStatement Else_opt %type <expression> Expression LiteralExpression PrimaryExpression EqualityExpression CallExpression %type <expression> ConcatExpression AdditiveExpression ModExpression IntdivExpression MultiplicativeExpression ExpExpression %type <expression> NotExpression UnaryExpression %type <member> MemberExpression %type <expression> Arguments_opt ArgumentList_opt ArgumentList %type <bool> OptionExplicit_opt +%type <arg_decl> ArgumentsDecl_opt ArgumentDeclList ArgumentDecl +%type <func_decl> FunctionDecl %type <elseif> ElseIfs_opt ElseIfs ElseIf %type <dim_decl> DimDeclList @@ -112,6 +119,10 @@ SourceElements : /* empty */ | SourceElements StatementNl { source_add_statement(ctx, $2); } +StatementsNl_opt + : /* empty */ { $$ = NULL; } + | StatementsNl { $$ = $1; } + StatementsNl : StatementNl { $$ = $1; } | StatementNl StatementsNl { $1->next = $2; $$ = $1; } @@ -126,6 +137,7 @@ Statement { $1->args = $2; $$ = new_assign_statement(ctx, $1, $4); CHECK_ERROR; } | tDIM DimDeclList { $$ = new_dim_statement(ctx, $2); CHECK_ERROR; } | IfStatement { $$ = $1; } + | FunctionDecl { $$ = new_function_statement(ctx, $1); CHECK_ERROR; } MemberExpression : tIdentifier { $$ = new_member_expression(ctx, NULL, $1); CHECK_ERROR; } @@ -236,6 +248,23 @@ LiteralExpression PrimaryExpression : '(' Expression ')' { $$ = $2; } +FunctionDecl + : /* Storage_opt */ tSUB tIdentifier ArgumentsDecl_opt tNL StatementsNl_opt tEND tSUB + { $$ = new_function_decl(ctx, $2, FUNC_SUB, $3, $5); CHECK_ERROR; } + +ArgumentsDecl_opt + : EmptyBrackets_opt { $$ = NULL; } + | '(' ArgumentDeclList ')' { $$ = $2; } + +ArgumentDeclList + : ArgumentDecl { $$ = $1; } + | ArgumentDecl ',' ArgumentDeclList { $1->next = $3; $$ = $1; } + +ArgumentDecl + : tIdentifier { $$ = new_argument_decl(ctx, $1, TRUE); } + | tBYREF tIdentifier { $$ = new_argument_decl(ctx, $2, TRUE); } + | tBYVAL tIdentifier { $$ = new_argument_decl(ctx, $2, FALSE); } + %% static int parser_error(const char *str) @@ -452,6 +481,48 @@ static statement_t *new_if_statement(parser_ctx_t *ctx, expression_t *expr, stat return &stat->stat; } +static arg_decl_t *new_argument_decl(parser_ctx_t *ctx, const WCHAR *name, BOOL by_ref) +{ + arg_decl_t *arg_decl; + + arg_decl = parser_alloc(ctx, sizeof(*arg_decl)); + if(!arg_decl) + return NULL; + + arg_decl->name = name; + arg_decl->by_ref = by_ref; + arg_decl->next = NULL; + return arg_decl; +} + +static function_decl_t *new_function_decl(parser_ctx_t *ctx, const WCHAR *name, function_type_t type, + arg_decl_t *arg_decl, statement_t *body) +{ + function_decl_t *decl; + + decl = parser_alloc(ctx, sizeof(*decl)); + if(!decl) + return NULL; + + decl->name = name; + decl->type = type; + decl->args = arg_decl; + decl->body = body; + return decl; +} + +static statement_t *new_function_statement(parser_ctx_t *ctx, function_decl_t *decl) +{ + function_statement_t *stat; + + stat = new_statement(ctx, STAT_FUNC, sizeof(*stat)); + if(!stat) + return NULL; + + stat->func_decl = decl; + return &stat->stat; +} + void *parser_alloc(parser_ctx_t *ctx, size_t size) { void *ret; diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index afa9d83..b52aa09 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -146,6 +146,11 @@ typedef struct { instr_arg_t arg2; } instr_t; +typedef enum { + FUNC_GLOBAL, + FUNC_SUB +} function_type_t; + struct _function_t { unsigned code_off; vbscode_t *code_ctx;
1
0
0
0
Hans Leidekker : ws2_32: Avoid a crash in WS2_recv_base.
by Alexandre Julliard
14 Sep '11
14 Sep '11
Module: wine Branch: master Commit: 94f431e3eebe44a88752be72a795baf33e55a213 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=94f431e3eebe44a88752be72a…
Author: Hans Leidekker <hans(a)codeweavers.com> Date: Wed Sep 14 12:04:39 2011 +0200 ws2_32: Avoid a crash in WS2_recv_base. --- dlls/ws2_32/socket.c | 3 +- dlls/ws2_32/tests/sock.c | 65 +++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 62 insertions(+), 6 deletions(-) diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index b6d17ff..f0313fc 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -5720,8 +5720,7 @@ static int WS2_recv_base( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount, goto error; } } - else - *lpNumberOfBytesRecvd = n; + else if (lpNumberOfBytesRecvd) *lpNumberOfBytesRecvd = n; if ((lpOverlapped || lpCompletionRoutine) && !(options & (FILE_SYNCHRONOUS_IO_ALERT | FILE_SYNCHRONOUS_IO_NONALERT))) diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index 326b77d..b358250 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -4031,18 +4031,37 @@ static void test_WSASendTo(void) "a successful call to WSASendTo()\n"); } +static DWORD WINAPI recv_thread(LPVOID arg) +{ + SOCKET sock = *(SOCKET *)arg; + char buffer[32]; + WSABUF wsa; + WSAOVERLAPPED ov; + DWORD flags = 0; + + wsa.buf = buffer; + wsa.len = sizeof(buffer); + ov.hEvent = WSACreateEvent(); + WSARecv(sock, &wsa, 1, NULL, &flags, &ov, NULL); + + WaitForSingleObject(ov.hEvent, 1000); + WSACloseEvent(ov.hEvent); + return 0; +} + static void test_WSARecv(void) { - SOCKET src, dest; + SOCKET src, dest, server = INVALID_SOCKET; char buf[20]; WSABUF bufs; WSAOVERLAPPED ov; - DWORD bytesReturned; - DWORD flags; + DWORD bytesReturned, flags, id; struct linger ling; - int iret; + struct sockaddr_in addr; + int iret, len; DWORD dwret; BOOL bret; + HANDLE thread; memset(&ov, 0, sizeof(ov)); @@ -4067,6 +4086,9 @@ static void test_WSARecv(void) iret = setsockopt (src, SOL_SOCKET, SO_LINGER, (char *) &ling, sizeof(ling)); ok(!iret, "Failed to set linger %d\n", GetLastError()); + iret = WSARecv(dest, &bufs, 1, NULL, &flags, &ov, NULL); + ok(iret == SOCKET_ERROR && GetLastError() == ERROR_IO_PENDING, "WSARecv failed - %d error %d\n", iret, GetLastError()); + iret = WSARecv(dest, &bufs, 1, &bytesReturned, &flags, &ov, NULL); ok(iret == SOCKET_ERROR && GetLastError() == ERROR_IO_PENDING, "WSARecv failed - %d error %d\n", iret, GetLastError()); @@ -4081,7 +4103,42 @@ static void test_WSARecv(void) "Did not get disconnect event: %d, error %d\n", bret, GetLastError()); ok(bytesReturned == 0, "Bytes received is %d\n", bytesReturned); + src = WSASocketW(AF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, 0, 0); + ok(src != INVALID_SOCKET, "failed to create socket %d\n", WSAGetLastError()); + if (src == INVALID_SOCKET) goto end; + + server = WSASocketW(AF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, 0, WSA_FLAG_OVERLAPPED); + ok(server != INVALID_SOCKET, "failed to create socket %d\n", WSAGetLastError()); + if (server == INVALID_SOCKET) goto end; + + memset(&addr, 0, sizeof(addr)); + addr.sin_family = AF_INET; + addr.sin_addr.s_addr = inet_addr("127.0.0.1"); + iret = bind(server, (struct sockaddr *)&addr, sizeof(addr)); + if (iret) goto end; + + len = sizeof(addr); + iret = getsockname(server, (struct sockaddr *)&addr, &len); + if (iret) goto end; + + iret = listen(server, 1); + if (iret) goto end; + + iret = connect(src, (struct sockaddr *)&addr, sizeof(addr)); + if (iret) goto end; + + len = sizeof(addr); + dest = accept(server, (struct sockaddr *)&addr, &len); + ok(dest != INVALID_SOCKET, "failed to create socket %d\n", WSAGetLastError()); + if (dest == INVALID_SOCKET) goto end; + + send(src, "test message", sizeof("test message"), 0); + thread = CreateThread(NULL, 0, recv_thread, &dest, 0, &id); + CloseHandle(thread); + end: + if (server != INVALID_SOCKET) + closesocket(server); if (dest != INVALID_SOCKET) closesocket(dest); if (src != INVALID_SOCKET)
1
0
0
0
Hans Leidekker : msi: Ignore files if their path cannot be resolved in the RemoveFiles action.
by Alexandre Julliard
14 Sep '11
14 Sep '11
Module: wine Branch: master Commit: f13cafad4ac92836a7db3283cc2707983dfc0151 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=f13cafad4ac92836a7db3283c…
Author: Hans Leidekker <hans(a)codeweavers.com> Date: Wed Sep 14 12:04:15 2011 +0200 msi: Ignore files if their path cannot be resolved in the RemoveFiles action. --- dlls/msi/files.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dlls/msi/files.c b/dlls/msi/files.c index 1f12fe2..9aa2098 100644 --- a/dlls/msi/files.c +++ b/dlls/msi/files.c @@ -1164,8 +1164,10 @@ static UINT ITERATE_RemoveFiles(MSIRECORD *row, LPVOID param) dir = msi_dup_property(package->db, dirprop); if (!dir) - return ERROR_OUTOFMEMORY; - + { + WARN("directory property has no value\n"); + return ERROR_SUCCESS; + } size = 0; if ((filename = strdupW( MSI_RecordGetString(row, 3) ))) {
1
0
0
0
Hans Leidekker : msi: Free the message string in ACTION_ResolveSource.
by Alexandre Julliard
14 Sep '11
14 Sep '11
Module: wine Branch: master Commit: eede401d038598a09c068fb588b05ea5d3f9357d URL:
http://source.winehq.org/git/wine.git/?a=commit;h=eede401d038598a09c068fb58…
Author: Hans Leidekker <hans(a)codeweavers.com> Date: Wed Sep 14 12:03:54 2011 +0200 msi: Free the message string in ACTION_ResolveSource. --- dlls/msi/action.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dlls/msi/action.c b/dlls/msi/action.c index 62d857a..478addd 100644 --- a/dlls/msi/action.c +++ b/dlls/msi/action.c @@ -5128,8 +5128,7 @@ static UINT ACTION_ResolveSource(MSIPACKAGE* package) attrib = GetFileAttributesW(package->db->path); if (attrib == INVALID_FILE_ATTRIBUTES) { - LPWSTR prompt; - LPWSTR msg; + LPWSTR prompt, msg; DWORD size = 0; rc = MsiSourceListGetInfoW(package->ProductCode, NULL, @@ -5146,17 +5145,18 @@ static UINT ACTION_ResolveSource(MSIPACKAGE* package) prompt = strdupW(package->db->path); msg = msi_build_error_string(package, 1302, 1, prompt); + msi_free(prompt); while(attrib == INVALID_FILE_ATTRIBUTES) { rc = MessageBoxW(NULL, msg, NULL, MB_OKCANCEL); if (rc == IDCANCEL) { - msi_free(prompt); + msi_free(msg); return ERROR_INSTALL_USEREXIT; } attrib = GetFileAttributesW(package->db->path); } - msi_free(prompt); + msi_free(msg); rc = ERROR_SUCCESS; } else
1
0
0
0
Alexandre Julliard : winex11: Make sure the cursor bitmaps are owned by x11drv.
by Alexandre Julliard
14 Sep '11
14 Sep '11
Module: wine Branch: master Commit: dc1056284fa1fc4c50c707987761c05834747e3a URL:
http://source.winehq.org/git/wine.git/?a=commit;h=dc1056284fa1fc4c50c707987…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Wed Sep 14 14:53:59 2011 +0200 winex11: Make sure the cursor bitmaps are owned by x11drv. --- dlls/winex11.drv/mouse.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c index d70f152..0ba57d1 100644 --- a/dlls/winex11.drv/mouse.c +++ b/dlls/winex11.drv/mouse.c @@ -1081,6 +1081,11 @@ static Cursor create_xlib_cursor( HDC hdc, const ICONINFOEXW *icon, int width, i if (has_alpha) { + /* make sure the bitmaps are owned by x11drv */ + HBITMAP orig = SelectObject( hdc, icon->hbmMask ); + SelectObject( hdc, xor_bitmap ); + SelectObject( hdc, orig ); + memset( mask_bits, 0, width_bytes * height ); for (y = 0, ptr = color_bits; y < height; y++) for (x = 0; x < width; x++, ptr++)
1
0
0
0
← Newer
1
...
47
48
49
50
51
52
53
...
100
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
Results per page:
10
25
50
100
200