mirror of
https://github.com/reactos/reactos.git
synced 2025-05-23 02:56:09 +00:00
[JSCRIPT] Sync with Wine Staging 1.7.47. CORE-9924
svn path=/trunk/; revision=68446
This commit is contained in:
parent
b4eaf61627
commit
b76ad047da
13 changed files with 1113 additions and 1011 deletions
|
@ -854,7 +854,7 @@ static HRESULT compile_function_expression(compiler_ctx_t *ctx, function_express
|
||||||
ctx->func_tail = ctx->func_tail ? (ctx->func_tail->next = expr) : (ctx->func_head = expr);
|
ctx->func_tail = ctx->func_tail ? (ctx->func_tail->next = expr) : (ctx->func_head = expr);
|
||||||
|
|
||||||
/* FIXME: not exactly right */
|
/* FIXME: not exactly right */
|
||||||
if(expr->identifier) {
|
if(expr->identifier && !expr->event_target) {
|
||||||
ctx->func->func_cnt++;
|
ctx->func->func_cnt++;
|
||||||
return push_instr_bstr(ctx, OP_ident, expr->identifier);
|
return push_instr_bstr(ctx, OP_ident, expr->identifier);
|
||||||
}
|
}
|
||||||
|
@ -1857,10 +1857,18 @@ static HRESULT compile_function(compiler_ctx_t *ctx, source_elements_t *source,
|
||||||
|
|
||||||
func->instr_off = off;
|
func->instr_off = off;
|
||||||
|
|
||||||
if(func_expr && func_expr->identifier) {
|
if(func_expr) {
|
||||||
func->name = compiler_alloc_bstr(ctx, func_expr->identifier);
|
if(func_expr->identifier) {
|
||||||
if(!func->name)
|
func->name = compiler_alloc_bstr(ctx, func_expr->identifier);
|
||||||
return E_OUTOFMEMORY;
|
if(!func->name)
|
||||||
|
return E_OUTOFMEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(func_expr->event_target) {
|
||||||
|
func->event_target = compiler_alloc_bstr(ctx, func_expr->event_target);
|
||||||
|
if(!func->event_target)
|
||||||
|
return E_OUTOFMEMORY;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(func_expr) {
|
if(func_expr) {
|
||||||
|
|
|
@ -2121,7 +2121,7 @@ static inline HRESULT date_parse(jsstr_t *input_str, double *ret) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(parse[i]=='-' || parse[i]=='/') {
|
else if(parse[i]=='-' || parse[i]=='/') {
|
||||||
/* Short date */
|
/* Short or long date */
|
||||||
if(set_day || set_month || set_year) break;
|
if(set_day || set_month || set_year) break;
|
||||||
set_day = TRUE;
|
set_day = TRUE;
|
||||||
set_month = TRUE;
|
set_month = TRUE;
|
||||||
|
@ -2141,6 +2141,13 @@ static inline HRESULT date_parse(jsstr_t *input_str, double *ret) {
|
||||||
if(parse[i]<'0' || parse[i]>'9') break;
|
if(parse[i]<'0' || parse[i]>'9') break;
|
||||||
year = atoiW(&parse[i]);
|
year = atoiW(&parse[i]);
|
||||||
while(parse[i]>='0' && parse[i]<='9') i++;
|
while(parse[i]>='0' && parse[i]<='9') i++;
|
||||||
|
|
||||||
|
if(tmp >= 70){
|
||||||
|
/* long date */
|
||||||
|
month = day - 1;
|
||||||
|
day = year;
|
||||||
|
year = tmp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(tmp<0) break;
|
else if(tmp<0) break;
|
||||||
else if(tmp<70) {
|
else if(tmp<70) {
|
||||||
|
|
|
@ -500,14 +500,16 @@ static HRESULT identifier_eval(script_ctx_t *ctx, BSTR identifier, exprval_t *re
|
||||||
|
|
||||||
TRACE("%s\n", debugstr_w(identifier));
|
TRACE("%s\n", debugstr_w(identifier));
|
||||||
|
|
||||||
for(scope = ctx->exec_ctx->scope_chain; scope; scope = scope->next) {
|
if(ctx->exec_ctx) {
|
||||||
if(scope->jsobj)
|
for(scope = ctx->exec_ctx->scope_chain; scope; scope = scope->next) {
|
||||||
hres = jsdisp_get_id(scope->jsobj, identifier, fdexNameImplicit, &id);
|
if(scope->jsobj)
|
||||||
else
|
hres = jsdisp_get_id(scope->jsobj, identifier, fdexNameImplicit, &id);
|
||||||
hres = disp_get_id(ctx, scope->obj, identifier, identifier, fdexNameImplicit, &id);
|
else
|
||||||
if(SUCCEEDED(hres)) {
|
hres = disp_get_id(ctx, scope->obj, identifier, identifier, fdexNameImplicit, &id);
|
||||||
exprval_set_idref(ret, scope->obj, id);
|
if(SUCCEEDED(hres)) {
|
||||||
return S_OK;
|
exprval_set_idref(ret, scope->obj, id);
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2493,6 +2495,43 @@ static HRESULT enter_bytecode(script_ctx_t *ctx, bytecode_t *code, function_code
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static HRESULT bind_event_target(script_ctx_t *ctx, function_code_t *func, jsdisp_t *func_obj)
|
||||||
|
{
|
||||||
|
IBindEventHandler *target;
|
||||||
|
exprval_t exprval;
|
||||||
|
IDispatch *disp;
|
||||||
|
jsval_t v;
|
||||||
|
HRESULT hres;
|
||||||
|
|
||||||
|
hres = identifier_eval(ctx, func->event_target, &exprval);
|
||||||
|
if(FAILED(hres))
|
||||||
|
return hres;
|
||||||
|
|
||||||
|
hres = exprval_to_value(ctx, &exprval, &v);
|
||||||
|
exprval_release(&exprval);
|
||||||
|
if(FAILED(hres))
|
||||||
|
return hres;
|
||||||
|
|
||||||
|
if(!is_object_instance(v)) {
|
||||||
|
FIXME("Can't bind to %s\n", debugstr_jsval(v));
|
||||||
|
jsval_release(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
disp = get_object(v);
|
||||||
|
hres = IDispatch_QueryInterface(disp, &IID_IBindEventHandler, (void**)&target);
|
||||||
|
if(SUCCEEDED(hres)) {
|
||||||
|
hres = IBindEventHandler_BindHandler(target, func->name, (IDispatch*)&func_obj->IDispatchEx_iface);
|
||||||
|
IBindEventHandler_Release(target);
|
||||||
|
if(FAILED(hres))
|
||||||
|
WARN("BindEvent failed: %08x\n", hres);
|
||||||
|
}else {
|
||||||
|
FIXME("No IBindEventHandler, not yet supported binding\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
IDispatch_Release(disp);
|
||||||
|
return hres;
|
||||||
|
}
|
||||||
|
|
||||||
HRESULT exec_source(exec_ctx_t *ctx, bytecode_t *code, function_code_t *func, BOOL from_eval, jsval_t *ret)
|
HRESULT exec_source(exec_ctx_t *ctx, bytecode_t *code, function_code_t *func, BOOL from_eval, jsval_t *ret)
|
||||||
{
|
{
|
||||||
exec_ctx_t *prev_ctx;
|
exec_ctx_t *prev_ctx;
|
||||||
|
@ -2510,7 +2549,10 @@ HRESULT exec_source(exec_ctx_t *ctx, bytecode_t *code, function_code_t *func, BO
|
||||||
if(FAILED(hres))
|
if(FAILED(hres))
|
||||||
return hres;
|
return hres;
|
||||||
|
|
||||||
hres = jsdisp_propput_name(ctx->var_disp, func->funcs[i].name, jsval_obj(func_obj));
|
if(func->funcs[i].event_target)
|
||||||
|
hres = bind_event_target(ctx->script, func->funcs+i, func_obj);
|
||||||
|
else
|
||||||
|
hres = jsdisp_propput_name(ctx->var_disp, func->funcs[i].name, jsval_obj(func_obj));
|
||||||
jsdisp_release(func_obj);
|
jsdisp_release(func_obj);
|
||||||
if(FAILED(hres))
|
if(FAILED(hres))
|
||||||
return hres;
|
return hres;
|
||||||
|
|
|
@ -129,6 +129,7 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct _function_code_t {
|
typedef struct _function_code_t {
|
||||||
BSTR name;
|
BSTR name;
|
||||||
|
BSTR event_target;
|
||||||
unsigned instr_off;
|
unsigned instr_off;
|
||||||
|
|
||||||
const WCHAR *source;
|
const WCHAR *source;
|
||||||
|
|
|
@ -787,7 +787,11 @@ static HRESULT WINAPI JScriptParse_ParseScriptText(IActiveScriptParse *iface,
|
||||||
return hres;
|
return hres;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!is_started(This->ctx)) {
|
/*
|
||||||
|
* Although pvarResult is not really used without SCRIPTTEXT_ISEXPRESSION flag, if it's not NULL,
|
||||||
|
* script is executed immediately, even if it's not in started state yet.
|
||||||
|
*/
|
||||||
|
if(!pvarResult && !is_started(This->ctx)) {
|
||||||
if(This->queue_tail)
|
if(This->queue_tail)
|
||||||
This->queue_tail = This->queue_tail->next = code;
|
This->queue_tail = This->queue_tail->next = code;
|
||||||
else
|
else
|
||||||
|
@ -796,9 +800,13 @@ static HRESULT WINAPI JScriptParse_ParseScriptText(IActiveScriptParse *iface,
|
||||||
}
|
}
|
||||||
|
|
||||||
hres = exec_global_code(This, code);
|
hres = exec_global_code(This, code);
|
||||||
|
|
||||||
release_bytecode(code);
|
release_bytecode(code);
|
||||||
return hres;
|
if(FAILED(hres))
|
||||||
|
return hres;
|
||||||
|
|
||||||
|
if(pvarResult)
|
||||||
|
V_VT(pvarResult) = VT_EMPTY;
|
||||||
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const IActiveScriptParseVtbl JScriptParseVtbl = {
|
static const IActiveScriptParseVtbl JScriptParseVtbl = {
|
||||||
|
|
|
@ -298,7 +298,7 @@ HRESULT jsdisp_propget_name(jsdisp_t*,LPCWSTR,jsval_t*) DECLSPEC_HIDDEN;
|
||||||
HRESULT jsdisp_get_idx(jsdisp_t*,DWORD,jsval_t*) DECLSPEC_HIDDEN;
|
HRESULT jsdisp_get_idx(jsdisp_t*,DWORD,jsval_t*) DECLSPEC_HIDDEN;
|
||||||
HRESULT jsdisp_get_id(jsdisp_t*,const WCHAR*,DWORD,DISPID*) DECLSPEC_HIDDEN;
|
HRESULT jsdisp_get_id(jsdisp_t*,const WCHAR*,DWORD,DISPID*) DECLSPEC_HIDDEN;
|
||||||
HRESULT disp_delete(IDispatch*,DISPID,BOOL*) DECLSPEC_HIDDEN;
|
HRESULT disp_delete(IDispatch*,DISPID,BOOL*) DECLSPEC_HIDDEN;
|
||||||
HRESULT disp_delete_name(script_ctx_t*,IDispatch*,jsstr_t*,BOOL*);
|
HRESULT disp_delete_name(script_ctx_t*,IDispatch*,jsstr_t*,BOOL*) DECLSPEC_HIDDEN;
|
||||||
HRESULT jsdisp_delete_idx(jsdisp_t*,DWORD) DECLSPEC_HIDDEN;
|
HRESULT jsdisp_delete_idx(jsdisp_t*,DWORD) DECLSPEC_HIDDEN;
|
||||||
HRESULT jsdisp_is_own_prop(jsdisp_t*,const WCHAR*,BOOL*) DECLSPEC_HIDDEN;
|
HRESULT jsdisp_is_own_prop(jsdisp_t*,const WCHAR*,BOOL*) DECLSPEC_HIDDEN;
|
||||||
HRESULT jsdisp_is_enumerable(jsdisp_t*,const WCHAR*,BOOL*) DECLSPEC_HIDDEN;
|
HRESULT jsdisp_is_enumerable(jsdisp_t*,const WCHAR*,BOOL*) DECLSPEC_HIDDEN;
|
||||||
|
|
|
@ -578,7 +578,6 @@ static int next_token(parser_ctx_t *ctx, void *lval)
|
||||||
case ',':
|
case ',':
|
||||||
case '~':
|
case '~':
|
||||||
case '?':
|
case '?':
|
||||||
case ':':
|
|
||||||
return *ctx->ptr++;
|
return *ctx->ptr++;
|
||||||
|
|
||||||
case '}':
|
case '}':
|
||||||
|
@ -774,6 +773,13 @@ static int next_token(parser_ctx_t *ctx, void *lval)
|
||||||
}
|
}
|
||||||
return '/';
|
return '/';
|
||||||
|
|
||||||
|
case ':':
|
||||||
|
if(++ctx->ptr < ctx->end && *ctx->ptr == ':') {
|
||||||
|
ctx->ptr++;
|
||||||
|
return kDCOL;
|
||||||
|
}
|
||||||
|
return ':';
|
||||||
|
|
||||||
case '\"':
|
case '\"':
|
||||||
case '\'':
|
case '\'':
|
||||||
return parse_string_literal(ctx, lval, *ctx->ptr);
|
return parse_string_literal(ctx, lval, *ctx->ptr);
|
||||||
|
|
|
@ -287,6 +287,7 @@ struct _source_elements_t {
|
||||||
typedef struct _function_expression_t {
|
typedef struct _function_expression_t {
|
||||||
expression_t expr;
|
expression_t expr;
|
||||||
const WCHAR *identifier;
|
const WCHAR *identifier;
|
||||||
|
const WCHAR *event_target;
|
||||||
parameter_t *parameter_list;
|
parameter_t *parameter_list;
|
||||||
source_elements_t *source_elements;
|
source_elements_t *source_elements;
|
||||||
const WCHAR *src_str;
|
const WCHAR *src_str;
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -78,17 +78,18 @@ extern int parser_debug;
|
||||||
tDEC = 288,
|
tDEC = 288,
|
||||||
tHTMLCOMMENT = 289,
|
tHTMLCOMMENT = 289,
|
||||||
kDIVEQ = 290,
|
kDIVEQ = 290,
|
||||||
kFUNCTION = 291,
|
kDCOL = 291,
|
||||||
tIdentifier = 292,
|
kFUNCTION = 292,
|
||||||
tAssignOper = 293,
|
tIdentifier = 293,
|
||||||
tEqOper = 294,
|
tAssignOper = 294,
|
||||||
tShiftOper = 295,
|
tEqOper = 295,
|
||||||
tRelOper = 296,
|
tShiftOper = 296,
|
||||||
tNumericLiteral = 297,
|
tRelOper = 297,
|
||||||
tBooleanLiteral = 298,
|
tNumericLiteral = 298,
|
||||||
tStringLiteral = 299,
|
tBooleanLiteral = 299,
|
||||||
tEOF = 300,
|
tStringLiteral = 300,
|
||||||
LOWER_THAN_ELSE = 301
|
tEOF = 301,
|
||||||
|
LOWER_THAN_ELSE = 302
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -118,7 +119,7 @@ union YYSTYPE
|
||||||
struct _variable_list_t *variable_list;
|
struct _variable_list_t *variable_list;
|
||||||
variable_declaration_t *variable_declaration;
|
variable_declaration_t *variable_declaration;
|
||||||
|
|
||||||
#line 122 "parser.tab.h" /* yacc.c:1909 */
|
#line 123 "parser.tab.h" /* yacc.c:1909 */
|
||||||
};
|
};
|
||||||
# define YYSTYPE_IS_TRIVIAL 1
|
# define YYSTYPE_IS_TRIVIAL 1
|
||||||
# define YYSTYPE_IS_DECLARED 1
|
# define YYSTYPE_IS_DECLARED 1
|
||||||
|
|
|
@ -114,7 +114,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 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*,
|
static expression_t *new_function_expression(parser_ctx_t*,const WCHAR*,parameter_list_t*,
|
||||||
source_elements_t*,const WCHAR*,DWORD);
|
source_elements_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_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_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*);
|
static expression_t *new_conditional_expression(parser_ctx_t*,expression_t*,expression_t*,expression_t*);
|
||||||
|
@ -160,7 +160,7 @@ static source_elements_t *source_elements_add_statement(source_elements_t*,state
|
||||||
/* keywords */
|
/* keywords */
|
||||||
%token kBREAK kCASE kCATCH kCONTINUE kDEFAULT kDELETE kDO kELSE kIF kFINALLY kFOR kIN
|
%token kBREAK kCASE kCATCH kCONTINUE kDEFAULT kDELETE kDO kELSE kIF kFINALLY kFOR kIN
|
||||||
%token kINSTANCEOF kNEW kNULL kRETURN kSWITCH kTHIS kTHROW kTRUE kFALSE kTRY kTYPEOF kVAR kVOID kWHILE kWITH
|
%token kINSTANCEOF kNEW kNULL kRETURN kSWITCH kTHIS kTHROW kTRUE kFALSE kTRY kTYPEOF kVAR kVOID kWHILE kWITH
|
||||||
%token tANDAND tOROR tINC tDEC tHTMLCOMMENT kDIVEQ
|
%token tANDAND tOROR tINC tDEC tHTMLCOMMENT kDIVEQ kDCOL
|
||||||
|
|
||||||
%token <srcptr> kFUNCTION '}'
|
%token <srcptr> kFUNCTION '}'
|
||||||
|
|
||||||
|
@ -258,8 +258,12 @@ SourceElements
|
||||||
|
|
||||||
/* ECMA-262 3rd Edition 13 */
|
/* ECMA-262 3rd Edition 13 */
|
||||||
FunctionExpression
|
FunctionExpression
|
||||||
: KFunction Identifier_opt left_bracket FormalParameterList_opt right_bracket '{' FunctionBody '}'
|
: KFunction left_bracket FormalParameterList_opt right_bracket '{' FunctionBody '}'
|
||||||
{ $$ = new_function_expression(ctx, $2, $4, $7, $1, $8-$1+1); }
|
{ $$ = new_function_expression(ctx, NULL, $3, $6, NULL, $1, $7-$1+1); }
|
||||||
|
| KFunction tIdentifier left_bracket FormalParameterList_opt right_bracket '{' FunctionBody '}'
|
||||||
|
{ $$ = new_function_expression(ctx, $2, $4, $7, NULL, $1, $8-$1+1); }
|
||||||
|
| KFunction tIdentifier kDCOL tIdentifier left_bracket FormalParameterList_opt right_bracket '{' FunctionBody '}'
|
||||||
|
{ $$ = new_function_expression(ctx, $4, $6, $9, $2, $1, $10-$1+1); }
|
||||||
|
|
||||||
KFunction
|
KFunction
|
||||||
: kFUNCTION { $$ = $1; }
|
: kFUNCTION { $$ = $1; }
|
||||||
|
@ -1294,14 +1298,15 @@ static parameter_list_t *parameter_list_add(parser_ctx_t *ctx, parameter_list_t
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
static expression_t *new_function_expression(parser_ctx_t *ctx, const WCHAR *identifier,
|
static expression_t *new_function_expression(parser_ctx_t *ctx, const WCHAR *identifier, parameter_list_t *parameter_list,
|
||||||
parameter_list_t *parameter_list, source_elements_t *source_elements, const WCHAR *src_str, DWORD src_len)
|
source_elements_t *source_elements, const WCHAR *event_target, const WCHAR *src_str, DWORD src_len)
|
||||||
{
|
{
|
||||||
function_expression_t *ret = new_expression(ctx, EXPR_FUNC, sizeof(*ret));
|
function_expression_t *ret = new_expression(ctx, EXPR_FUNC, sizeof(*ret));
|
||||||
|
|
||||||
ret->identifier = identifier;
|
ret->identifier = identifier;
|
||||||
ret->parameter_list = parameter_list ? parameter_list->head : NULL;
|
ret->parameter_list = parameter_list ? parameter_list->head : NULL;
|
||||||
ret->source_elements = source_elements;
|
ret->source_elements = source_elements;
|
||||||
|
ret->event_target = event_target;
|
||||||
ret->src_str = src_str;
|
ret->src_str = src_str;
|
||||||
ret->src_len = src_len;
|
ret->src_len = src_len;
|
||||||
ret->next = NULL;
|
ret->next = NULL;
|
||||||
|
|
|
@ -1128,7 +1128,7 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi
|
||||||
match_state_t match_result, *match_ptr = &match_result;
|
match_state_t match_result, *match_ptr = &match_result;
|
||||||
DWORD length, i, match_len = 0;
|
DWORD length, i, match_len = 0;
|
||||||
const WCHAR *ptr, *ptr2, *str, *match_str = NULL;
|
const WCHAR *ptr, *ptr2, *str, *match_str = NULL;
|
||||||
unsigned limit = UINT32_MAX;
|
unsigned limit = ~0u;
|
||||||
jsdisp_t *array, *regexp = NULL;
|
jsdisp_t *array, *regexp = NULL;
|
||||||
jsstr_t *jsstr, *match_jsstr, *tmp_str;
|
jsstr_t *jsstr, *match_jsstr, *tmp_str;
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
|
|
|
@ -88,7 +88,7 @@ reactos/dll/win32/inseng # Synced to WineStaging-1.7.47
|
||||||
reactos/dll/win32/iphlpapi # Out of sync
|
reactos/dll/win32/iphlpapi # Out of sync
|
||||||
reactos/dll/win32/itircl # Synced to WineStaging-1.7.37
|
reactos/dll/win32/itircl # Synced to WineStaging-1.7.37
|
||||||
reactos/dll/win32/itss # Synced to WineStaging-1.7.37
|
reactos/dll/win32/itss # Synced to WineStaging-1.7.37
|
||||||
reactos/dll/win32/jscript # Synced to WineStaging-1.7.37
|
reactos/dll/win32/jscript # Synced to WineStaging-1.7.47
|
||||||
reactos/dll/win32/jsproxy # Synced to WineStaging-1.7.37
|
reactos/dll/win32/jsproxy # Synced to WineStaging-1.7.37
|
||||||
reactos/dll/win32/loadperf # Synced to WineStaging-1.7.37
|
reactos/dll/win32/loadperf # Synced to WineStaging-1.7.37
|
||||||
reactos/dll/win32/localspl # Synced to WineStaging-1.7.37
|
reactos/dll/win32/localspl # Synced to WineStaging-1.7.37
|
||||||
|
|
Loading…
Reference in a new issue