jscript: Implicitly turn CC on for @set instruction.

This commit is contained in:
Jacek Caban 2014-10-01 10:45:30 +02:00 committed by Alexandre Julliard
parent 68c61d17e0
commit 8b36388797
2 changed files with 15 additions and 7 deletions

View File

@ -852,7 +852,7 @@ static cc_var_t *find_cc_var(cc_ctx_t *cc, const WCHAR *name, unsigned name_len)
return NULL; return NULL;
} }
static int init_cc(parser_ctx_t *ctx) static BOOL init_cc(parser_ctx_t *ctx)
{ {
cc_ctx_t *cc; cc_ctx_t *cc;
@ -865,11 +865,13 @@ static int init_cc(parser_ctx_t *ctx)
static const WCHAR _jscript_versionW[] = {'_','j','s','c','r','i','p','t','_','v','e','r','s','i','o','n',0}; static const WCHAR _jscript_versionW[] = {'_','j','s','c','r','i','p','t','_','v','e','r','s','i','o','n',0};
if(ctx->script->cc) if(ctx->script->cc)
return 0; return TRUE;
cc = heap_alloc(sizeof(cc_ctx_t)); cc = heap_alloc(sizeof(cc_ctx_t));
if(!cc) if(!cc) {
return lex_error(ctx, E_OUTOFMEMORY); lex_error(ctx, E_OUTOFMEMORY);
return FALSE;
}
cc->vars = NULL; cc->vars = NULL;
@ -879,11 +881,12 @@ static int init_cc(parser_ctx_t *ctx)
|| !new_cc_var(cc, _jscript_versionW, -1, ccval_num(JSCRIPT_MAJOR_VERSION + (DOUBLE)JSCRIPT_MINOR_VERSION/10.0)) || !new_cc_var(cc, _jscript_versionW, -1, ccval_num(JSCRIPT_MAJOR_VERSION + (DOUBLE)JSCRIPT_MINOR_VERSION/10.0))
|| !new_cc_var(cc, _jscript_buildW, -1, ccval_num(JSCRIPT_BUILD_VERSION))) { || !new_cc_var(cc, _jscript_buildW, -1, ccval_num(JSCRIPT_BUILD_VERSION))) {
release_cc(cc); release_cc(cc);
return lex_error(ctx, E_OUTOFMEMORY); lex_error(ctx, E_OUTOFMEMORY);
return FALSE;
} }
ctx->script->cc = cc; ctx->script->cc = cc;
return 0; return TRUE;
} }
static BOOL parse_cc_identifier(parser_ctx_t *ctx, const WCHAR **ret, unsigned *ret_len) static BOOL parse_cc_identifier(parser_ctx_t *ctx, const WCHAR **ret, unsigned *ret_len)
@ -1011,13 +1014,16 @@ static int cc_token(parser_ctx_t *ctx, void *lval)
ctx->ptr++; ctx->ptr++;
if(!check_keyword(ctx, cc_onW, NULL)) if(!check_keyword(ctx, cc_onW, NULL))
return init_cc(ctx); return init_cc(ctx) ? 0 : -1;
if(!check_keyword(ctx, setW, NULL)) { if(!check_keyword(ctx, setW, NULL)) {
const WCHAR *ident; const WCHAR *ident;
unsigned ident_len; unsigned ident_len;
cc_var_t *var; cc_var_t *var;
if(!init_cc(ctx))
return -1;
if(!skip_spaces(ctx)) if(!skip_spaces(ctx))
return lex_error(ctx, JS_E_EXPECTED_AT); return lex_error(ctx, JS_E_EXPECTED_AT);

View File

@ -2183,6 +2183,8 @@ static BOOL run_tests(void)
CHECK_CALLED(testobj_withprop_d); CHECK_CALLED(testobj_withprop_d);
CHECK_CALLED(testobj_withprop_i); CHECK_CALLED(testobj_withprop_i);
parse_script_a("@set @t=2\nok(@t === 2, '@t = ' + @t);");
run_from_res("lang.js"); run_from_res("lang.js");
run_from_res("api.js"); run_from_res("api.js");
run_from_res("regexp.js"); run_from_res("regexp.js");