Module: wine Branch: master Commit: 78957118fb91c3fc4aecb6ec19f1225f796f9d2f URL: http://source.winehq.org/git/wine.git/?a=commit;h=78957118fb91c3fc4aecb6ec19...
Author: Jacek Caban jacek@codeweavers.com Date: Wed Sep 14 16:55:51 2011 +0200
vbscript: Added function parser implementation.
---
dlls/vbscript/compile.c | 2 + dlls/vbscript/parser.y | 2 + dlls/vbscript/tests/lang.vbs | 63 ++++++++++++++++++++++++++++++++++++++++ dlls/vbscript/tests/vbscript.c | 3 -- dlls/vbscript/vbscript.h | 1 + 5 files changed, 68 insertions(+), 3 deletions(-)
diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index dd756b3..a4608be 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -621,6 +621,7 @@ static HRESULT compile_func(compile_ctx_t *ctx, statement_t *stat, function_t *f if(ctx->sub_end_label == -1) return E_OUTOFMEMORY; break; + case FUNC_FUNCTION: /* FIXME */ case FUNC_GLOBAL: break; } @@ -833,6 +834,7 @@ static vbscode_t *alloc_vbscode(compile_ctx_t *ctx, const WCHAR *source) ret->bstr_pool = NULL; ret->bstr_pool_size = 0; ret->bstr_cnt = 0; + ret->global_executed = FALSE;
ret->global_code.type = FUNC_GLOBAL; ret->global_code.name = NULL; diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index f406f8e..36edc02 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -253,6 +253,8 @@ PrimaryExpression FunctionDecl : /* Storage_opt */ tSUB tIdentifier ArgumentsDecl_opt tNL StatementsNl_opt tEND tSUB { $$ = new_function_decl(ctx, $2, FUNC_SUB, $3, $5); CHECK_ERROR; } + | /* Storage_opt */ tFUNCTION tIdentifier ArgumentsDecl_opt tNL StatementsNl_opt tEND tFUNCTION + { $$ = new_function_decl(ctx, $2, FUNC_FUNCTION, $3, $5); CHECK_ERROR; }
ArgumentsDecl_opt : EmptyBrackets_opt { $$ = NULL; } diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index a46394b..5f47360 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -241,4 +241,67 @@ y = true Call TestSubLocalVal Call ok(x, "global x is not true?")
+if false then +Function testfunc + x = true +End Function +end if + +x = false +Call TestFunc +Call ok(x, "x is false, testfunc not called?") + +Function FuncSetTrue(v) + Call ok(not v, "v is not true") + v = true +End Function + +x = false +FuncSetTrue x +Call ok(x, "x was not set by FuncSetTrue") + +FuncSetTrue false +Call ok(not false, "false is no longer false?") + +Function FuncSetTrue2(ByRef v) + Call ok(not v, "v is not true") + v = true +End Function + +x = false +FuncSetTrue2 x +Call ok(x, "x was not set by FuncSetTrue") + +Function TestFuncArgVal(ByVal v) + Call ok(not v, "v is not false") + v = true + Call ok(v, "v is not true?") +End Function + +x = false +Call TestFuncArgVal(x) +Call ok(not x, "x is true after TestFuncArgVal call?") + +Function TestFuncMultiArgs(a,b,c,d,e) + Call ok(a=1, "a = " & a) + Call ok(b=2, "b = " & b) + Call ok(c=3, "c = " & c) + Call ok(d=4, "d = " & d) + Call ok(e=5, "e = " & e) +End Function + +TestFuncMultiArgs 1, 2, 3, 4, 5 +Call TestFuncMultiArgs(1, 2, 3, 4, 5) + +Function TestFuncLocalVal + x = false + Call ok(not x, "local x is not false?") + Dim x +End Function + +x = true +y = true +Call TestFuncLocalVal +Call ok(x, "global x is not true?") + reportSuccess() diff --git a/dlls/vbscript/tests/vbscript.c b/dlls/vbscript/tests/vbscript.c index ab5c8af..6ead8f4 100644 --- a/dlls/vbscript/tests/vbscript.c +++ b/dlls/vbscript/tests/vbscript.c @@ -412,7 +412,6 @@ static void test_vbscript_uninitializing(void) test_state(script, SCRIPTSTATE_INITIALIZED);
hres = IActiveScriptParse64_ParseScriptText(parse, script_textW, NULL, NULL, NULL, 0, 1, 0x42, NULL, NULL); - todo_wine ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
hres = IActiveScript_SetScriptSite(script, &ActiveScriptSite); @@ -441,9 +440,7 @@ static void test_vbscript_uninitializing(void) hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_CONNECTED); ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_CONNECTED) failed: %08x\n", hres); CHECK_CALLED(OnStateChange_CONNECTED); - todo_wine CHECK_CALLED(OnEnterScript); - todo_wine CHECK_CALLED(OnLeaveScript);
test_state(script, SCRIPTSTATE_CONNECTED); diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index cf625cc..5e86176 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -164,6 +164,7 @@ typedef struct {
typedef enum { FUNC_GLOBAL, + FUNC_FUNCTION, FUNC_SUB } function_type_t;