vbscript: Added function parser implementation.
This commit is contained in:
parent
0b9b021aa3
commit
78957118fb
|
@ -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;
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -164,6 +164,7 @@ typedef struct {
|
|||
|
||||
typedef enum {
|
||||
FUNC_GLOBAL,
|
||||
FUNC_FUNCTION,
|
||||
FUNC_SUB
|
||||
} function_type_t;
|
||||
|
||||
|
|
Loading…
Reference in New Issue