Module: wine Branch: master Commit: 8108b4040ca140dd7567adf698943de56edaa616 URL: http://source.winehq.org/git/wine.git/?a=commit;h=8108b4040ca140dd7567adf698...
Author: Jacek Caban jacek@codeweavers.com Date: Fri Sep 9 14:47:00 2011 +0200
vbscript: Added parser/compiler support for |option explicit|.
---
dlls/vbscript/compile.c | 2 ++ dlls/vbscript/interp.c | 5 ++++- dlls/vbscript/parse.h | 1 + dlls/vbscript/parser.y | 14 +++++++++++--- dlls/vbscript/tests/lang.vbs | 2 ++ dlls/vbscript/vbscript.h | 2 ++ 6 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index 7e8fe3b..ea55177 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -256,6 +256,8 @@ static vbscode_t *alloc_vbscode(compile_ctx_t *ctx, const WCHAR *source) ctx->instr_cnt = 0; ctx->instr_size = 32;
+ ret->option_explicit = ctx->parser.option_explicit; + ret->bstr_pool = NULL; ret->bstr_pool_size = 0; ret->bstr_cnt = 0; diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index f5254c4..a33ff90 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -29,6 +29,7 @@ typedef struct { vbscode_t *code; instr_t *instr; script_ctx_t *script; + function_t *func;
unsigned stack_size; unsigned top; @@ -70,7 +71,8 @@ static HRESULT lookup_identifier(exec_ctx_t *ctx, BSTR name, ref_t *ref) } }
- FIXME("create if no option explicit\n"); + if(!ctx->func->code_ctx->option_explicit) + FIXME("create an attempt to set\n");
ref->type = REF_NONE; return S_OK; @@ -223,6 +225,7 @@ HRESULT exec_script(script_ctx_t *ctx, function_t *func) exec.code = func->code_ctx; exec.instr = exec.code->instrs + func->code_off; exec.script = ctx; + exec.func = func;
while(exec.instr) { op = exec.instr->op; diff --git a/dlls/vbscript/parse.h b/dlls/vbscript/parse.h index a0c7f2c..5f7fba2 100644 --- a/dlls/vbscript/parse.h +++ b/dlls/vbscript/parse.h @@ -63,6 +63,7 @@ typedef struct { const WCHAR *ptr; const WCHAR *end;
+ BOOL option_explicit; BOOL parse_complete; HRESULT hres;
diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index 72790fa..258420d 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -31,7 +31,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(vbscript);
static int parser_error(const char*);
-static void parse_complete(parser_ctx_t*); + static void parse_complete(parser_ctx_t*,BOOL);
static void source_add_statement(parser_ctx_t*,statement_t*);
@@ -54,6 +54,7 @@ static statement_t *new_call_statement(parser_ctx_t*,member_expression_t*); statement_t *statement; expression_t *expression; member_expression_t *member; + BOOL bool; }
%token tEOF tNL tREM tEMPTYBRACKETS @@ -75,11 +76,16 @@ static statement_t *new_call_statement(parser_ctx_t*,member_expression_t*); %type <expression> Expression LiteralExpression %type <member> MemberExpression %type <expression> Arguments_opt ArgumentList_opt ArgumentList +%type <bool> OptionExplicit_opt
%%
Program - : SourceElements tEOF { parse_complete(ctx); } + : OptionExplicit_opt SourceElements tEOF { parse_complete(ctx, $1); } + +OptionExplicit_opt + : /* empty */ { $$ = FALSE; } + | tOPTION tEXPLICIT tNL { $$ = TRUE; }
SourceElements : /* empty */ @@ -137,9 +143,10 @@ static void source_add_statement(parser_ctx_t *ctx, statement_t *stat) } }
-static void parse_complete(parser_ctx_t *ctx) +static void parse_complete(parser_ctx_t *ctx, BOOL option_explicit) { ctx->parse_complete = TRUE; + ctx->option_explicit = option_explicit; }
static void *new_expression(parser_ctx_t *ctx, expression_type_t type, unsigned size) @@ -240,6 +247,7 @@ HRESULT parse_script(parser_ctx_t *ctx, const WCHAR *code) ctx->last_token = tNL; ctx->last_nl = 0; ctx->stats = ctx->stats_tail = NULL; + ctx->option_explicit = FALSE;
parser_parse(ctx);
diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index 55a8cad..07585fa 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -16,6 +16,8 @@ ' Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA '
+Option Explicit + call ok(true, "true is not true?") ok true, "true is not true?"
diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index a1428bb..54d7da5 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -109,6 +109,8 @@ struct _vbscode_t { instr_t *instrs; WCHAR *source;
+ BOOL option_explicit; + BOOL global_executed; function_t global_code;