Signed-off-by: Paul Gofman pgofman@codeweavers.com --- dlls/jscript/compile.c | 8 ++-- dlls/jscript/parser.h | 16 ++++---- dlls/jscript/parser.y | 81 ++++++++++++++++------------------------ dlls/mshtml/tests/es5.js | 12 ++++++ 4 files changed, 57 insertions(+), 60 deletions(-)
diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c index 0862ba39b62..1c4085dc64a 100644 --- a/dlls/jscript/compile.c +++ b/dlls/jscript/compile.c @@ -2448,7 +2448,7 @@ static HRESULT init_code(compiler_ctx_t *compiler, const WCHAR *source, UINT64 s return S_OK; }
-static HRESULT compile_function(compiler_ctx_t *ctx, source_elements_t *source, function_expression_t *func_expr, +static HRESULT compile_function(compiler_ctx_t *ctx, statement_list_t *source, function_expression_t *func_expr, BOOL from_eval, function_code_t *func) { function_expression_t *iter; @@ -2506,7 +2506,7 @@ static HRESULT compile_function(compiler_ctx_t *ctx, source_elements_t *source, return E_OUTOFMEMORY; }
- hres = visit_block_statement(ctx, NULL, source->statement); + hres = visit_block_statement(ctx, NULL, source ? source->head : NULL); if(FAILED(hres)) return hres;
@@ -2547,7 +2547,7 @@ static HRESULT compile_function(compiler_ctx_t *ctx, source_elements_t *source,
ctx->current_function_expr = ctx->func_head; off = ctx->code_off; - hres = compile_block_statement(ctx, NULL, source->statement); + hres = compile_block_statement(ctx, NULL, source ? source->head : NULL); if(FAILED(hres)) return hres;
@@ -2563,7 +2563,7 @@ static HRESULT compile_function(compiler_ctx_t *ctx, source_elements_t *source, func->instr_off = off;
for(iter = ctx->func_head, i=0; iter; iter = iter->next, i++) { - hres = compile_function(ctx, iter->source_elements, iter, FALSE, func->funcs+i); + hres = compile_function(ctx, iter->statement_list, iter, FALSE, func->funcs+i); if(FAILED(hres)) return hres;
diff --git a/dlls/jscript/parser.h b/dlls/jscript/parser.h index c92a3f8bdbd..4553280517c 100644 --- a/dlls/jscript/parser.h +++ b/dlls/jscript/parser.h @@ -16,9 +16,14 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
-typedef struct _source_elements_t source_elements_t; typedef struct _expression_t expression_t; typedef struct _statement_t statement_t; + +typedef struct _statement_list_t { + statement_t *head; + statement_t *tail; +} statement_list_t; + struct _bytecode_t;
typedef struct { @@ -36,7 +41,7 @@ typedef struct _parser_ctx_t {
script_ctx_t *script; struct _compiler_ctx_t *compiler; - source_elements_t *source; + statement_list_t *source; BOOL nl; BOOL implicit_nl_semicolon; BOOL is_html; @@ -290,17 +295,12 @@ typedef struct _parameter_t { struct _parameter_t *next; } parameter_t;
-struct _source_elements_t { - statement_t *statement; - statement_t *statement_tail; -}; - typedef struct _function_expression_t { expression_t expr; const WCHAR *identifier; const WCHAR *event_target; parameter_t *parameter_list; - source_elements_t *source_elements; + statement_list_t *statement_list; const WCHAR *src_str; DWORD src_len; unsigned func_id; diff --git a/dlls/jscript/parser.y b/dlls/jscript/parser.y index 4bac8c65d0c..5cc088d017e 100644 --- a/dlls/jscript/parser.y +++ b/dlls/jscript/parser.y @@ -31,11 +31,6 @@ static void set_error(parser_ctx_t*,unsigned,HRESULT); static BOOL explicit_error(parser_ctx_t*,void*,WCHAR); static BOOL allow_auto_semicolon(parser_ctx_t*);
-typedef struct _statement_list_t { - statement_t *head; - statement_t *tail; -} statement_list_t; - static literal_t *new_string_literal(parser_ctx_t*,jsstr_t*); static literal_t *new_null_literal(parser_ctx_t*);
@@ -121,7 +116,7 @@ static parameter_list_t *parameter_list_add(parser_ctx_t*,parameter_list_t*,cons
static void *new_expression(parser_ctx_t *ctx,expression_type_t,size_t); static expression_t *new_function_expression(parser_ctx_t*,const WCHAR*,parameter_list_t*, - source_elements_t*,const WCHAR*,const WCHAR*,DWORD); + statement_list_t*,const WCHAR*,const WCHAR*,DWORD); static expression_t *new_binary_expression(parser_ctx_t*,expression_type_t,expression_t*,expression_t*); static expression_t *new_unary_expression(parser_ctx_t*,expression_type_t,expression_t*); static expression_t *new_conditional_expression(parser_ctx_t*,expression_t*,expression_t*,expression_t*); @@ -133,9 +128,6 @@ static expression_t *new_literal_expression(parser_ctx_t*,literal_t*); static expression_t *new_array_literal_expression(parser_ctx_t*,element_list_t*,int); static expression_t *new_prop_and_value_expression(parser_ctx_t*,property_list_t*);
-static source_elements_t *new_source_elements(parser_ctx_t*); -static source_elements_t *source_elements_add_statement(source_elements_t*,statement_t*); - #define YYLTYPE unsigned #define YYLLOC_DEFAULT(Cur, Rhs, N) Cur = YYRHSLOC((Rhs), (N) ? 1 : 0)
@@ -144,7 +136,7 @@ static source_elements_t *source_elements_add_statement(source_elements_t*,state %lex-param { parser_ctx_t *ctx } %parse-param { parser_ctx_t *ctx } %define api.pure -%start Program +%start Script
%union { int ival; @@ -160,7 +152,6 @@ static source_elements_t *source_elements_add_statement(source_elements_t*,state struct _parameter_list_t *parameter_list; struct _property_list_t *property_list; property_definition_t *property_definition; - source_elements_t *source_elements; statement_t *statement; struct _statement_list_t *statement_list; struct _variable_list_t *variable_list; @@ -179,9 +170,11 @@ static source_elements_t *source_elements_add_statement(source_elements_t*,state %token <literal> tNumericLiteral tBooleanLiteral %token <str> tStringLiteral
-%type <source_elements> SourceElements -%type <source_elements> FunctionBody +%type <statement_list> FunctionBody +%type <statement_list> ScriptBody +%type <statement_list> FunctionStatementList %type <statement> Statement +%type <statement> Declaration %type <statement> Block %type <statement> LexicalDeclaration %type <statement> VariableStatement @@ -198,6 +191,7 @@ static source_elements_t *source_elements_add_statement(source_elements_t*,state %type <statement> ThrowStatement %type <statement> TryStatement %type <statement> Finally +%type <statement> StatementListItem %type <statement_list> StatementList StatementList_opt %type <parameter_list> FormalParameterList FormalParameterList_opt %type <expr> Expression Expression_opt Expression_err @@ -252,19 +246,21 @@ static source_elements_t *source_elements_add_statement(source_elements_t*,state
%%
-/* ECMA-262 3rd Edition 14 */ -Program - : SourceElements HtmlComment { ctx->source = $1; } +/* ECMA-262 10th Edition 15.1 */ +Script + : ScriptBody HtmlComment { ctx->source = $1; } + +/* ECMA-262 10th Edition 15.1 */ +ScriptBody + : StatementList_opt { $$ = $1; }
HtmlComment : tHTMLCOMMENT | /* empty */
-/* ECMA-262 3rd Edition 14 */ -SourceElements - : /* empty */ { $$ = new_source_elements(ctx); } - | SourceElements Statement - { $$ = source_elements_add_statement($1, $2); } +/* ECMA-262 10th Edition 14.1 */ +FunctionStatementList + : StatementList_opt { $$ = $1; }
/* ECMA-262 3rd Edition 13 */ FunctionExpression @@ -275,9 +271,9 @@ FunctionExpression | kFUNCTION tIdentifier kDCOL tIdentifier left_bracket FormalParameterList_opt right_bracket '{' FunctionBody '}' { $$ = new_function_expression(ctx, $4, $6, $9, $2, ctx->begin + @1, @10 - @1 + 1); }
-/* ECMA-262 3rd Edition 13 */ +/* ECMA-262 10th Edition 14.1 */ FunctionBody - : SourceElements { $$ = $1; } + : FunctionStatementList { $$ = $1; }
/* ECMA-262 3rd Edition 13 */ FormalParameterList @@ -293,7 +289,6 @@ FormalParameterList_opt /* ECMA-262 3rd Edition 12 */ Statement : Block { $$ = $1; } - | LexicalDeclaration { $$ = $1; } | VariableStatement { $$ = $1; } | EmptyStatement { $$ = $1; } | FunctionExpression { $$ = new_expression_statement(ctx, @$, $1); } @@ -309,10 +304,19 @@ Statement | ThrowStatement { $$ = $1; } | TryStatement { $$ = $1; }
-/* ECMA-262 3rd Edition 12.2 */ +/* ECMA-262 10th Edition 13. TODO: HoistableDeclaration, ClassDeclaration */ +Declaration + : LexicalDeclaration { $$ = $1; } + +/* ECMA-262 10th Edition 13.2 */ +StatementListItem + : Statement { $$ = $1; } + | Declaration { $$ = $1; } + +/* ECMA-262 10th Edition 13.2 */ StatementList - : Statement { $$ = new_statement_list(ctx, $1); } - | StatementList Statement + : StatementListItem { $$ = new_statement_list(ctx, $1); } + | StatementList StatementListItem { $$ = statement_list_add($1, $2); }
/* ECMA-262 3rd Edition 12.2 */ @@ -1404,13 +1408,13 @@ static parameter_list_t *parameter_list_add(parser_ctx_t *ctx, parameter_list_t }
static expression_t *new_function_expression(parser_ctx_t *ctx, const WCHAR *identifier, parameter_list_t *parameter_list, - source_elements_t *source_elements, const WCHAR *event_target, const WCHAR *src_str, DWORD src_len) + statement_list_t *statement_list, const WCHAR *event_target, const WCHAR *src_str, DWORD src_len) { function_expression_t *ret = new_expression(ctx, EXPR_FUNC, sizeof(*ret));
ret->identifier = identifier; ret->parameter_list = parameter_list ? parameter_list->head : NULL; - ret->source_elements = source_elements; + ret->statement_list = statement_list; ret->event_target = event_target; ret->src_str = src_str; ret->src_len = src_len; @@ -1553,25 +1557,6 @@ static expression_t *new_literal_expression(parser_ctx_t *ctx, literal_t *litera return &ret->expr; }
-static source_elements_t *new_source_elements(parser_ctx_t *ctx) -{ - source_elements_t *ret = parser_alloc(ctx, sizeof(source_elements_t)); - - memset(ret, 0, sizeof(*ret)); - - return ret; -} - -static source_elements_t *source_elements_add_statement(source_elements_t *source_elements, statement_t *statement) -{ - if(source_elements->statement_tail) - source_elements->statement_tail = source_elements->statement_tail->next = statement; - else - source_elements->statement = source_elements->statement_tail = statement; - - return source_elements; -} - static statement_list_t *new_statement_list(parser_ctx_t *ctx, statement_t *statement) { statement_list_t *ret = parser_alloc_tmp(ctx, sizeof(statement_list_t)); diff --git a/dlls/mshtml/tests/es5.js b/dlls/mshtml/tests/es5.js index 03663917177..3467698e159 100644 --- a/dlls/mshtml/tests/es5.js +++ b/dlls/mshtml/tests/es5.js @@ -1318,6 +1318,18 @@ sync_test("declaration_let", function() { }
ok(a == 3, "a != 3"); + + var except = false + + try + { + eval('with({w:9}) let a = 3'); + } + catch (e) + { + except = true; + } + ok(except, "with({w:9}) let a = 3: expected exception."); });
sync_test("let scope instances", function() {
Signed-off-by: Paul Gofman pgofman@codeweavers.com --- dlls/jscript/parser.y | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/dlls/jscript/parser.y b/dlls/jscript/parser.y index 5cc088d017e..5c7f48fa23f 100644 --- a/dlls/jscript/parser.y +++ b/dlls/jscript/parser.y @@ -1149,6 +1149,8 @@ static variable_declaration_t *new_variable_declaration(parser_ctx_t *ctx, const ret->expr = expr; ret->next = NULL; ret->global_next = NULL; + ret->block_scope = FALSE; + ret->constant = FALSE;
return ret; }
Signed-off-by: Paul Gofman pgofman@codeweavers.com --- dlls/jscript/compile.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-)
diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c index 1c4085dc64a..f14392b166f 100644 --- a/dlls/jscript/compile.c +++ b/dlls/jscript/compile.c @@ -568,6 +568,24 @@ static HRESULT emit_member_expression(compiler_ctx_t *ctx, expression_t *expr) return S_OK; }
+static void push_compiler_statement_ctx(compiler_ctx_t *ctx, statement_ctx_t *stat_ctx) +{ + if (stat_ctx) + { + stat_ctx->next = ctx->stat_ctx; + ctx->stat_ctx = stat_ctx; + } +} + +static void pop_compiler_statement_ctx(compiler_ctx_t *ctx, statement_ctx_t *stat_ctx) +{ + if (stat_ctx) + { + assert(ctx->stat_ctx == stat_ctx); + ctx->stat_ctx = stat_ctx->next; + } +} + static HRESULT compile_memberid_expression(compiler_ctx_t *ctx, expression_t *expr, unsigned flags) { HRESULT hres; @@ -1866,10 +1884,7 @@ static HRESULT compile_statement(compiler_ctx_t *ctx, statement_ctx_t *stat_ctx, { HRESULT hres;
- if(stat_ctx) { - stat_ctx->next = ctx->stat_ctx; - ctx->stat_ctx = stat_ctx; - } + push_compiler_statement_ctx(ctx, stat_ctx);
set_compiler_loc(ctx, stat->loc);
@@ -1926,10 +1941,7 @@ static HRESULT compile_statement(compiler_ctx_t *ctx, statement_ctx_t *stat_ctx, DEFAULT_UNREACHABLE; }
- if(stat_ctx) { - assert(ctx->stat_ctx == stat_ctx); - ctx->stat_ctx = stat_ctx->next; - } + pop_compiler_statement_ctx(ctx, stat_ctx);
return hres; } @@ -2186,11 +2198,7 @@ static HRESULT visit_statement(compiler_ctx_t *ctx, statement_ctx_t *stat_ctx, s { HRESULT hres = S_OK;
- if(stat_ctx) - { - stat_ctx->next = ctx->stat_ctx; - ctx->stat_ctx = stat_ctx; - } + push_compiler_statement_ctx(ctx, stat_ctx);
switch(stat->type) { case STAT_BLOCK: @@ -2352,11 +2360,7 @@ static HRESULT visit_statement(compiler_ctx_t *ctx, statement_ctx_t *stat_ctx, s DEFAULT_UNREACHABLE; }
- if(stat_ctx) - { - assert(ctx->stat_ctx == stat_ctx); - ctx->stat_ctx = stat_ctx->next; - } + pop_compiler_statement_ctx(ctx, stat_ctx);
return hres; }
Signed-off-by: Paul Gofman pgofman@codeweavers.com --- dlls/jscript/compile.c | 84 +++++++++++++++++++++++++++++++++------- dlls/jscript/parser.h | 1 + dlls/jscript/parser.y | 34 +++++++++++++--- dlls/mshtml/tests/es5.js | 12 ++++++ 4 files changed, 113 insertions(+), 18 deletions(-)
diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c index f14392b166f..4672a8c31f1 100644 --- a/dlls/jscript/compile.c +++ b/dlls/jscript/compile.c @@ -1377,47 +1377,63 @@ static HRESULT compile_while_statement(compiler_ctx_t *ctx, while_statement_t *s return S_OK; }
-/* ECMA-262 3rd Edition 12.6.3 */ +/* ECMA-262 10th Edition 13.7.4 */ static HRESULT compile_for_statement(compiler_ctx_t *ctx, for_statement_t *stat) { statement_ctx_t stat_ctx = {0, FALSE, FALSE}; + statement_ctx_t scope_stat_ctx = {0, TRUE}; unsigned expr_off; HRESULT hres;
+ if (stat->scope_index) + { + if(FAILED(hres = push_instr_uint(ctx, OP_push_block_scope, stat->scope_index))) + return hres; + + scope_stat_ctx.scope_index = stat->scope_index; + scope_stat_ctx.block_scope = TRUE; + push_compiler_statement_ctx(ctx, &scope_stat_ctx); + } + if(stat->variable_list) { hres = compile_variable_list(ctx, stat->variable_list); if(FAILED(hres)) - return hres; + goto done; }else if(stat->begin_expr) { hres = compile_expression(ctx, stat->begin_expr, FALSE); if(FAILED(hres)) - return hres; + goto done; }
stat_ctx.break_label = alloc_label(ctx); if(!stat_ctx.break_label) - return E_OUTOFMEMORY; + { + hres = E_OUTOFMEMORY; + goto done; + }
stat_ctx.continue_label = alloc_label(ctx); if(!stat_ctx.continue_label) - return E_OUTOFMEMORY; - + { + hres = E_OUTOFMEMORY; + goto done; + } expr_off = ctx->code_off;
if(stat->expr) { set_compiler_loc(ctx, stat->expr_loc); hres = compile_expression(ctx, stat->expr, TRUE); if(FAILED(hres)) - return hres; + goto done;
hres = push_instr_uint(ctx, OP_jmp_z, stat_ctx.break_label); if(FAILED(hres)) - return hres; + goto done; }
hres = compile_statement(ctx, &stat_ctx, stat->statement); if(FAILED(hres)) - return hres; + goto done;
label_set_addr(ctx, stat_ctx.continue_label);
@@ -1425,15 +1441,23 @@ static HRESULT compile_for_statement(compiler_ctx_t *ctx, for_statement_t *stat) set_compiler_loc(ctx, stat->end_loc); hres = compile_expression(ctx, stat->end_expr, FALSE); if(FAILED(hres)) - return hres; + goto done; }
hres = push_instr_uint(ctx, OP_jmp, expr_off); if(FAILED(hres)) - return hres; + goto done;
label_set_addr(ctx, stat_ctx.break_label); - return S_OK; + hres = S_OK; +done: + if (stat->scope_index) + { + pop_compiler_statement_ctx(ctx, &scope_stat_ctx); + if(SUCCEEDED(hres) && !push_instr(ctx, OP_pop_scope)) + return E_OUTOFMEMORY; + } + return hres; }
/* ECMA-262 3rd Edition 12.6.4 */ @@ -2225,27 +2249,61 @@ static HRESULT visit_statement(compiler_ctx_t *ctx, statement_ctx_t *stat_ctx, s break; } case STAT_FOR: { + statement_ctx_t stat_ctx_data = {0, TRUE}, *stat_ctx = NULL; for_statement_t *for_stat = (for_statement_t*)stat;
if(for_stat->variable_list) + { + variable_declaration_t *var; + + for(var = for_stat->variable_list; var; var = var->next) + { + if (var->block_scope) + { + stat_ctx = &stat_ctx_data; + break; + } + } + + if (stat_ctx) + { + if (!alloc_local_scope(ctx, &for_stat->scope_index)) + { + hres = E_OUTOFMEMORY; + break; + } + stat_ctx->scope_index = for_stat->scope_index; + stat_ctx->block_scope = TRUE; + push_compiler_statement_ctx(ctx, stat_ctx); + } hres = visit_variable_list(ctx, for_stat->variable_list); + } else if(for_stat->begin_expr) hres = visit_expression(ctx, for_stat->begin_expr); if(FAILED(hres)) + { + pop_compiler_statement_ctx(ctx, stat_ctx); break; + }
if(for_stat->expr) { hres = visit_expression(ctx, for_stat->expr); if(FAILED(hres)) + { + pop_compiler_statement_ctx(ctx, stat_ctx); break; + } }
hres = visit_statement(ctx, NULL, for_stat->statement); if(FAILED(hres)) + { + pop_compiler_statement_ctx(ctx, stat_ctx); break; - + } if(for_stat->end_expr) hres = visit_expression(ctx, for_stat->end_expr); + pop_compiler_statement_ctx(ctx, stat_ctx); break; } case STAT_FORIN: { diff --git a/dlls/jscript/parser.h b/dlls/jscript/parser.h index 4553280517c..fde0b540d63 100644 --- a/dlls/jscript/parser.h +++ b/dlls/jscript/parser.h @@ -171,6 +171,7 @@ typedef struct { expression_t *end_expr; unsigned end_loc; statement_t *statement; + unsigned int scope_index; } for_statement_t;
typedef struct { diff --git a/dlls/jscript/parser.y b/dlls/jscript/parser.y index 5c7f48fa23f..ce5d7fb2d10 100644 --- a/dlls/jscript/parser.y +++ b/dlls/jscript/parser.y @@ -86,7 +86,7 @@ static statement_t *new_var_statement(parser_ctx_t*,BOOL,BOOL,unsigned,variable_ static statement_t *new_expression_statement(parser_ctx_t*,unsigned,expression_t*); static statement_t *new_if_statement(parser_ctx_t*,unsigned,expression_t*,statement_t*,statement_t*); static statement_t *new_while_statement(parser_ctx_t*,unsigned,BOOL,expression_t*,statement_t*); -static statement_t *new_for_statement(parser_ctx_t*,unsigned,variable_list_t*,expression_t*,expression_t*,unsigned, +static statement_t *new_for_statement(parser_ctx_t*,unsigned,variable_declaration_t*,expression_t*,expression_t*,unsigned, expression_t*,unsigned,statement_t*); static statement_t *new_forin_statement(parser_ctx_t*,unsigned,variable_declaration_t*,expression_t*,expression_t*,statement_t*); static statement_t *new_continue_statement(parser_ctx_t*,unsigned,const WCHAR*); @@ -177,6 +177,7 @@ static expression_t *new_prop_and_value_expression(parser_ctx_t*,property_list_t %type <statement> Declaration %type <statement> Block %type <statement> LexicalDeclaration +%type <statement> LexicalDeclarationNoIn %type <statement> VariableStatement %type <statement> EmptyStatement %type <statement> ExpressionStatement @@ -344,6 +345,21 @@ LexicalDeclaration $$ = new_var_statement(ctx, TRUE, TRUE, @$, $2); }
+/* ECMA-262 10th Edition 13.3.1, TODO: BindingList*/ +LexicalDeclarationNoIn + : kLET VariableDeclarationListNoIn semicolon_opt + { $$ = new_var_statement(ctx, TRUE, FALSE, @$, $2); } + | kCONST VariableDeclarationListNoIn semicolon_opt + { + if(ctx->script->version < SCRIPTLANGUAGEVERSION_ES5) { + WARN("const var declaration %s in legacy mode.\n", + debugstr_w($1)); + set_error(ctx, @$, JS_E_SYNTAX); + YYABORT; + } + $$ = new_var_statement(ctx, TRUE, TRUE, @$, $2); + } + /* ECMA-262 3rd Edition 12.2 */ VariableStatement : kVAR VariableDeclarationList semicolon_opt @@ -408,7 +424,7 @@ IfStatement | kIF left_bracket Expression_err right_bracket Statement %prec LOWER_THAN_ELSE { $$ = new_if_statement(ctx, @$, $3, $5, NULL); }
-/* ECMA-262 3rd Edition 12.6 */ +/* ECMA-262 10th Edition 13.7 */ IterationStatement : kDO Statement kWHILE left_bracket Expression_err right_bracket semicolon_opt { $$ = new_while_statement(ctx, @3, TRUE, $5, $2); } @@ -425,11 +441,18 @@ IterationStatement semicolon Expression_opt { if(!explicit_error(ctx, $7, ';')) YYABORT; } semicolon Expression_opt right_bracket Statement - { $$ = new_for_statement(ctx, @3, $4, NULL, $7, @7, $10, @10, $12); } + { $$ = new_for_statement(ctx, @3, $4 ? $4->head : NULL, NULL, $7, @7, $10, @10, $12); } | kFOR left_bracket LeftHandSideExpression kIN Expression_err right_bracket Statement { $$ = new_forin_statement(ctx, @$, NULL, $3, $5, $7); } | kFOR left_bracket kVAR VariableDeclarationNoIn kIN Expression_err right_bracket Statement { $$ = new_forin_statement(ctx, @$, $4, NULL, $6, $8); } + | kFOR left_bracket LexicalDeclarationNoIn + { if(!explicit_error(ctx, $3, ';')) YYABORT; } + Expression_opt + { if(!explicit_error(ctx, $5, ';')) YYABORT; } + semicolon Expression_opt right_bracket Statement + { $$ = new_for_statement(ctx, @3, ((var_statement_t *)$3)->variable_list, + NULL, $5, @5, $8, @8, $10); }
/* ECMA-262 3rd Edition 12.7 */ ContinueStatement @@ -1235,7 +1258,7 @@ static statement_t *new_while_statement(parser_ctx_t *ctx, unsigned loc, BOOL do return &ret->stat; }
-static statement_t *new_for_statement(parser_ctx_t *ctx, unsigned loc, variable_list_t *variable_list, expression_t *begin_expr, +static statement_t *new_for_statement(parser_ctx_t *ctx, unsigned loc, variable_declaration_t *variable_list, expression_t *begin_expr, expression_t *expr, unsigned expr_loc, expression_t *end_expr, unsigned end_loc, statement_t *statement) { for_statement_t *ret; @@ -1244,13 +1267,14 @@ static statement_t *new_for_statement(parser_ctx_t *ctx, unsigned loc, variable_ if(!ret) return NULL;
- ret->variable_list = variable_list ? variable_list->head : NULL; + ret->variable_list = variable_list; ret->begin_expr = begin_expr; ret->expr = expr; ret->expr_loc = expr_loc; ret->end_expr = end_expr; ret->end_loc = end_loc; ret->statement = statement; + ret->scope_index = 0;
return &ret->stat; } diff --git a/dlls/mshtml/tests/es5.js b/dlls/mshtml/tests/es5.js index 3467698e159..a357083de52 100644 --- a/dlls/mshtml/tests/es5.js +++ b/dlls/mshtml/tests/es5.js @@ -1330,6 +1330,18 @@ sync_test("declaration_let", function() { except = true; } ok(except, "with({w:9}) let a = 3: expected exception."); + + let for_count = 0; + for (let for_i1 = 0, for_i2 = 1; for_i1 < 3; ++for_i1, ++for_i2, ++for_count) + { + let for_i2 = 10; + + ok(for_i2 == 10, "for_i2 != 10"); + } + + ok(typeof for_i1 == 'undefined', "for_i1 is defined"); + ok(typeof for_i2 == 'undefined', "for_i2 is defined"); + ok(for_count == 3, "for_count != 3"); });
sync_test("let scope instances", function() {
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=92862
Your paranoid android.
=== w8adm (32 bit report) ===
mshtml: events.c:1089: Test failed: unexpected call img_onerror events: Timeout
=== w8adm (32 bit report) ===
mshtml: htmldoc.c:3084: Test failed: Incorrect error code: -2146697211 htmldoc.c:3089: Test failed: Page address: L"http://test.winehq.org/tests/winehq_snapshot/" htmldoc.c:5861: Test failed: expected OnChanged_1012 htmldoc.c:5862: Test failed: expected Exec_HTTPEQUIV htmldoc.c:5864: Test failed: expected Exec_SETTITLE htmldoc.c:5905: Test failed: expected FireNavigateComplete2
=== w1064_tsign (32 bit report) ===
mshtml: htmldoc.c:2541: Test failed: unexpected call UpdateUI htmldoc.c:2853: Test failed: unexpected call Exec_UPDATECOMMANDS
=== w10pro64_zh_CN (64 bit report) ===
mshtml: htmldoc.c:2541: Test failed: unexpected call UpdateUI htmldoc.c:2853: Test failed: unexpected call Exec_UPDATECOMMANDS htmldoc.c:350: Test failed: expected Exec_SETTITLE htmldoc.c:2859: Test failed: unexpected call Exec_SETTITLE
=== w7u_el (32 bit report) ===
mshtml: script.c:624: Test failed: L"/index.html?es5.js:date_now: unexpected Date.now() result 1624280817417 expected 1624280817480"
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=92859
Your paranoid android.
=== w8adm (32 bit report) ===
mshtml: htmldoc.c:3084: Test failed: Incorrect error code: -2146697211 htmldoc.c:3089: Test failed: Page address: L"http://test.winehq.org/tests/winehq_snapshot/" htmldoc.c:5861: Test failed: expected OnChanged_1012 htmldoc.c:5862: Test failed: expected Exec_HTTPEQUIV htmldoc.c:5864: Test failed: expected Exec_SETTITLE htmldoc.c:5905: Test failed: expected FireNavigateComplete2
=== w1064_tsign (64 bit report) ===
mshtml: htmldoc.c:2541: Test failed: unexpected call UpdateUI htmldoc.c:2853: Test failed: unexpected call Exec_UPDATECOMMANDS htmldoc.c:350: Test failed: expected Exec_SETTITLE htmldoc.c:2859: Test failed: unexpected call Exec_SETTITLE
Hi Paul,
Patches look generally good, just minor comments bellow.
On 6/21/21 2:11 PM, Paul Gofman wrote:
-/* ECMA-262 3rd Edition 12.2 */ +/* ECMA-262 10th Edition 13. TODO: HoistableDeclaration, ClassDeclaration */
None of IE versions supports class declarations, see browser compatibility:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes
diff --git a/dlls/mshtml/tests/es5.js b/dlls/mshtml/tests/es5.js index 03663917177..3467698e159 100644 --- a/dlls/mshtml/tests/es5.js +++ b/dlls/mshtml/tests/es5.js @@ -1318,6 +1318,18 @@ sync_test("declaration_let", function() { }
ok(a == 3, "a != 3");
- var except = false
- try
- {
eval('with({w:9}) let a = 3');
That's generally right, but I would suggest some less invasive statement than 'with' to make it cleaner what you're testing, say 'if (true)'.
Thanks,
Jacek