mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 12:23:14 +00:00
sync jscript with wine 1.1.21
svn path=/trunk/; revision=41019
This commit is contained in:
parent
9f6cf09ab7
commit
3e68821bfc
9 changed files with 1980 additions and 1408 deletions
|
@ -55,6 +55,7 @@ typedef struct _parser_ctx_t {
|
||||||
script_ctx_t *script;
|
script_ctx_t *script;
|
||||||
source_elements_t *source;
|
source_elements_t *source;
|
||||||
BOOL nl;
|
BOOL nl;
|
||||||
|
BOOL is_html;
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
|
|
||||||
jsheap_t heap;
|
jsheap_t heap;
|
||||||
|
@ -65,7 +66,7 @@ typedef struct _parser_ctx_t {
|
||||||
struct _parser_ctx_t *next;
|
struct _parser_ctx_t *next;
|
||||||
} parser_ctx_t;
|
} parser_ctx_t;
|
||||||
|
|
||||||
HRESULT script_parse(script_ctx_t*,const WCHAR*,parser_ctx_t**);
|
HRESULT script_parse(script_ctx_t*,const WCHAR*,const WCHAR*,parser_ctx_t**);
|
||||||
void parser_release(parser_ctx_t*);
|
void parser_release(parser_ctx_t*);
|
||||||
|
|
||||||
int parser_lex(void*,parser_ctx_t*);
|
int parser_lex(void*,parser_ctx_t*);
|
||||||
|
|
|
@ -264,7 +264,7 @@ static HRESULT JSGlobal_eval(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARA
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE("parsing %s\n", debugstr_w(V_BSTR(arg)));
|
TRACE("parsing %s\n", debugstr_w(V_BSTR(arg)));
|
||||||
hres = script_parse(dispex->ctx, V_BSTR(arg), &parser_ctx);
|
hres = script_parse(dispex->ctx, V_BSTR(arg), NULL, &parser_ctx);
|
||||||
if(FAILED(hres)) {
|
if(FAILED(hres)) {
|
||||||
WARN("parse (%s) failed: %08x\n", debugstr_w(V_BSTR(arg)), hres);
|
WARN("parse (%s) failed: %08x\n", debugstr_w(V_BSTR(arg)), hres);
|
||||||
return hres;
|
return hres;
|
||||||
|
|
|
@ -596,7 +596,7 @@ static HRESULT WINAPI JScriptParse_ParseScriptText(IActiveScriptParse *iface,
|
||||||
if(This->thread_id != GetCurrentThreadId() || This->ctx->state == SCRIPTSTATE_CLOSED)
|
if(This->thread_id != GetCurrentThreadId() || This->ctx->state == SCRIPTSTATE_CLOSED)
|
||||||
return E_UNEXPECTED;
|
return E_UNEXPECTED;
|
||||||
|
|
||||||
hres = script_parse(This->ctx, pstrCode, &parser_ctx);
|
hres = script_parse(This->ctx, pstrCode, pstrDelimiter, &parser_ctx);
|
||||||
if(FAILED(hres))
|
if(FAILED(hres))
|
||||||
return hres;
|
return hres;
|
||||||
|
|
||||||
|
@ -662,7 +662,7 @@ static HRESULT WINAPI JScriptParseProcedure_ParseProcedureText(IActiveScriptPars
|
||||||
if(This->thread_id != GetCurrentThreadId() || This->ctx->state == SCRIPTSTATE_CLOSED)
|
if(This->thread_id != GetCurrentThreadId() || This->ctx->state == SCRIPTSTATE_CLOSED)
|
||||||
return E_UNEXPECTED;
|
return E_UNEXPECTED;
|
||||||
|
|
||||||
hres = script_parse(This->ctx, pstrCode, &parser_ctx);
|
hres = script_parse(This->ctx, pstrCode, pstrDelimiter, &parser_ctx);
|
||||||
if(FAILED(hres)) {
|
if(FAILED(hres)) {
|
||||||
WARN("Parse failed %08x\n", hres);
|
WARN("Parse failed %08x\n", hres);
|
||||||
return hres;
|
return hres;
|
||||||
|
|
|
@ -174,6 +174,20 @@ static void skip_spaces(parser_ctx_t *ctx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static BOOL skip_html_comment(parser_ctx_t *ctx)
|
||||||
|
{
|
||||||
|
const WCHAR html_commentW[] = {'<','!','-','-',0};
|
||||||
|
|
||||||
|
if(!ctx->is_html || ctx->ptr+3 >= ctx->end ||
|
||||||
|
memcmp(ctx->ptr, html_commentW, sizeof(WCHAR)*4))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
ctx->nl = TRUE;
|
||||||
|
while(ctx->ptr < ctx->end && !is_endline(*ctx->ptr++));
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static BOOL skip_comment(parser_ctx_t *ctx)
|
static BOOL skip_comment(parser_ctx_t *ctx)
|
||||||
{
|
{
|
||||||
if(ctx->ptr+1 >= ctx->end || *ctx->ptr != '/')
|
if(ctx->ptr+1 >= ctx->end || *ctx->ptr != '/')
|
||||||
|
@ -466,13 +480,13 @@ int parser_lex(void *lval, parser_ctx_t *ctx)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ctx->nl = FALSE;
|
ctx->nl = ctx->ptr == ctx->begin;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
skip_spaces(ctx);
|
skip_spaces(ctx);
|
||||||
if(ctx->ptr == ctx->end)
|
if(ctx->ptr == ctx->end)
|
||||||
return 0;
|
return 0;
|
||||||
}while(skip_comment(ctx));
|
}while(skip_comment(ctx) || skip_html_comment(ctx));
|
||||||
|
|
||||||
if(isalphaW(*ctx->ptr)) {
|
if(isalphaW(*ctx->ptr)) {
|
||||||
ret = check_keywords(ctx, lval);
|
ret = check_keywords(ctx, lval);
|
||||||
|
@ -585,8 +599,12 @@ int parser_lex(void *lval, parser_ctx_t *ctx)
|
||||||
ctx->ptr++;
|
ctx->ptr++;
|
||||||
if(ctx->ptr < ctx->end) {
|
if(ctx->ptr < ctx->end) {
|
||||||
switch(*ctx->ptr) {
|
switch(*ctx->ptr) {
|
||||||
case '-': /* -- */
|
case '-': /* -- or --> */
|
||||||
ctx->ptr++;
|
ctx->ptr++;
|
||||||
|
if(ctx->is_html && ctx->nl && ctx->ptr < ctx->end && *ctx->ptr == '>') {
|
||||||
|
ctx->ptr++;
|
||||||
|
return tHTMLCOMMENT;
|
||||||
|
}
|
||||||
return tDEC;
|
return tDEC;
|
||||||
case '=': /* -= */
|
case '=': /* -= */
|
||||||
ctx->ptr++;
|
ctx->ptr++;
|
||||||
|
|
|
@ -98,8 +98,8 @@ static HRESULT Math_LOG10E(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS
|
||||||
static HRESULT Math_LN2(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
|
static HRESULT Math_LN2(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
|
||||||
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
|
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
|
||||||
{
|
{
|
||||||
FIXME("\n");
|
TRACE("\n");
|
||||||
return E_NOTIMPL;
|
return math_constant(M_LN2, flags, retv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT Math_LN10(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
|
static HRESULT Math_LN10(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
|
||||||
|
@ -212,8 +212,22 @@ static HRESULT Math_ceil(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *
|
||||||
static HRESULT Math_cos(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
|
static HRESULT Math_cos(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
|
||||||
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
|
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
|
||||||
{
|
{
|
||||||
FIXME("\n");
|
VARIANT v;
|
||||||
return E_NOTIMPL;
|
HRESULT hres;
|
||||||
|
|
||||||
|
TRACE("\n");
|
||||||
|
|
||||||
|
if(!arg_cnt(dp)) {
|
||||||
|
if(retv) num_set_nan(retv);
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
hres = to_number(dispex->ctx, get_arg(dp, 0), ei, &v);
|
||||||
|
if(FAILED(hres))
|
||||||
|
return hres;
|
||||||
|
|
||||||
|
if(retv) num_set_val(retv, cos(num_val(&v)));
|
||||||
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT Math_exp(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
|
static HRESULT Math_exp(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,12 +1,15 @@
|
||||||
/* A Bison parser, made by GNU Bison 2.1. */
|
|
||||||
|
|
||||||
/* Skeleton parser for Yacc-like parsing with Bison,
|
/* A Bison parser, made by GNU Bison 2.4.1. */
|
||||||
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
/* Skeleton interface for Bison's Yacc-like parsers in C
|
||||||
|
|
||||||
|
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
||||||
|
Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation; either version 2, or (at your option)
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
@ -14,14 +17,21 @@
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA. */
|
/* As a special exception, you may create a larger work that contains
|
||||||
|
part or all of the Bison parser skeleton and distribute that work
|
||||||
|
under terms of your choice, so long as that work isn't itself a
|
||||||
|
parser generator using the skeleton or a modified version thereof
|
||||||
|
as a parser skeleton. Alternatively, if you modify or redistribute
|
||||||
|
the parser skeleton itself, you may (at your option) remove this
|
||||||
|
special exception, which will cause the skeleton and the resulting
|
||||||
|
Bison output files to be licensed under the GNU General Public
|
||||||
|
License without this special exception.
|
||||||
|
|
||||||
|
This special exception was added by the Free Software Foundation in
|
||||||
|
version 2.2 of Bison. */
|
||||||
|
|
||||||
/* As a special exception, when this file is copied by Bison into a
|
|
||||||
Bison output file, you may use that output file without restriction.
|
|
||||||
This special exception was added by the Free Software Foundation
|
|
||||||
in version 1.24 of Bison. */
|
|
||||||
|
|
||||||
/* Tokens. */
|
/* Tokens. */
|
||||||
#ifndef YYTOKENTYPE
|
#ifndef YYTOKENTYPE
|
||||||
|
@ -61,66 +71,28 @@
|
||||||
tOROR = 287,
|
tOROR = 287,
|
||||||
tINC = 288,
|
tINC = 288,
|
||||||
tDEC = 289,
|
tDEC = 289,
|
||||||
kFUNCTION = 290,
|
tHTMLCOMMENT = 290,
|
||||||
tIdentifier = 291,
|
kFUNCTION = 291,
|
||||||
tAssignOper = 292,
|
tIdentifier = 292,
|
||||||
tEqOper = 293,
|
tAssignOper = 293,
|
||||||
tShiftOper = 294,
|
tEqOper = 294,
|
||||||
tRelOper = 295,
|
tShiftOper = 295,
|
||||||
tNumericLiteral = 296,
|
tRelOper = 296,
|
||||||
tStringLiteral = 297,
|
tNumericLiteral = 297,
|
||||||
LOWER_THAN_ELSE = 298
|
tStringLiteral = 298,
|
||||||
|
LOWER_THAN_ELSE = 299
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
/* Tokens. */
|
|
||||||
#define kBREAK 258
|
|
||||||
#define kCASE 259
|
|
||||||
#define kCATCH 260
|
|
||||||
#define kCONTINUE 261
|
|
||||||
#define kDEFAULT 262
|
|
||||||
#define kDELETE 263
|
|
||||||
#define kDO 264
|
|
||||||
#define kELSE 265
|
|
||||||
#define kIF 266
|
|
||||||
#define kFINALLY 267
|
|
||||||
#define kFOR 268
|
|
||||||
#define kIN 269
|
|
||||||
#define kINSTANCEOF 270
|
|
||||||
#define kNEW 271
|
|
||||||
#define kNULL 272
|
|
||||||
#define kUNDEFINED 273
|
|
||||||
#define kRETURN 274
|
|
||||||
#define kSWITCH 275
|
|
||||||
#define kTHIS 276
|
|
||||||
#define kTHROW 277
|
|
||||||
#define kTRUE 278
|
|
||||||
#define kFALSE 279
|
|
||||||
#define kTRY 280
|
|
||||||
#define kTYPEOF 281
|
|
||||||
#define kVAR 282
|
|
||||||
#define kVOID 283
|
|
||||||
#define kWHILE 284
|
|
||||||
#define kWITH 285
|
|
||||||
#define tANDAND 286
|
|
||||||
#define tOROR 287
|
|
||||||
#define tINC 288
|
|
||||||
#define tDEC 289
|
|
||||||
#define kFUNCTION 290
|
|
||||||
#define tIdentifier 291
|
|
||||||
#define tAssignOper 292
|
|
||||||
#define tEqOper 293
|
|
||||||
#define tShiftOper 294
|
|
||||||
#define tRelOper 295
|
|
||||||
#define tNumericLiteral 296
|
|
||||||
#define tStringLiteral 297
|
|
||||||
#define LOWER_THAN_ELSE 298
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
||||||
|
typedef union YYSTYPE
|
||||||
|
{
|
||||||
|
|
||||||
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
|
/* Line 1676 of yacc.c */
|
||||||
#line 149 "parser.y"
|
#line 149 "parser.y"
|
||||||
typedef union YYSTYPE {
|
|
||||||
int ival;
|
int ival;
|
||||||
const WCHAR *srcptr;
|
const WCHAR *srcptr;
|
||||||
LPCWSTR wstr;
|
LPCWSTR wstr;
|
||||||
|
@ -139,15 +111,17 @@ typedef union YYSTYPE {
|
||||||
struct _statement_list_t *statement_list;
|
struct _statement_list_t *statement_list;
|
||||||
struct _variable_list_t *variable_list;
|
struct _variable_list_t *variable_list;
|
||||||
variable_declaration_t *variable_declaration;
|
variable_declaration_t *variable_declaration;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Line 1676 of yacc.c */
|
||||||
|
#line 119 "parser.tab.h"
|
||||||
} YYSTYPE;
|
} YYSTYPE;
|
||||||
/* Line 1447 of yacc.c. */
|
# define YYSTYPE_IS_TRIVIAL 1
|
||||||
#line 145 "parser.tab.h"
|
|
||||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||||
# define YYSTYPE_IS_DECLARED 1
|
# define YYSTYPE_IS_DECLARED 1
|
||||||
# define YYSTYPE_IS_TRIVIAL 1
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -170,7 +170,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 kUNDEFINED kRETURN kSWITCH kTHIS kTHROW kTRUE kFALSE kTRY kTYPEOF kVAR kVOID kWHILE kWITH
|
%token kINSTANCEOF kNEW kNULL kUNDEFINED kRETURN kSWITCH kTHIS kTHROW kTRUE kFALSE kTRY kTYPEOF kVAR kVOID kWHILE kWITH
|
||||||
%token tANDAND tOROR tINC tDEC
|
%token tANDAND tOROR tINC tDEC tHTMLCOMMENT
|
||||||
|
|
||||||
%token <srcptr> kFUNCTION '}'
|
%token <srcptr> kFUNCTION '}'
|
||||||
|
|
||||||
|
@ -251,7 +251,12 @@ static source_elements_t *source_elements_add_statement(source_elements_t*,state
|
||||||
|
|
||||||
/* ECMA-262 3rd Edition 14 */
|
/* ECMA-262 3rd Edition 14 */
|
||||||
Program
|
Program
|
||||||
: SourceElements { program_parsed(ctx, $1); }
|
: SourceElements HtmlComment
|
||||||
|
{ program_parsed(ctx, $1); }
|
||||||
|
|
||||||
|
HtmlComment
|
||||||
|
: tHTMLCOMMENT {}
|
||||||
|
| /* empty */ {}
|
||||||
|
|
||||||
/* ECMA-262 3rd Edition 14 */
|
/* ECMA-262 3rd Edition 14 */
|
||||||
SourceElements
|
SourceElements
|
||||||
|
@ -1549,18 +1554,22 @@ void parser_release(parser_ctx_t *ctx)
|
||||||
heap_free(ctx);
|
heap_free(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT script_parse(script_ctx_t *ctx, const WCHAR *code, parser_ctx_t **ret)
|
HRESULT script_parse(script_ctx_t *ctx, const WCHAR *code, const WCHAR *delimiter,
|
||||||
|
parser_ctx_t **ret)
|
||||||
{
|
{
|
||||||
parser_ctx_t *parser_ctx;
|
parser_ctx_t *parser_ctx;
|
||||||
jsheap_t *mark;
|
jsheap_t *mark;
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
|
|
||||||
|
const WCHAR html_tagW[] = {'<','/','s','c','r','i','p','t','>',0};
|
||||||
|
|
||||||
parser_ctx = heap_alloc_zero(sizeof(parser_ctx_t));
|
parser_ctx = heap_alloc_zero(sizeof(parser_ctx_t));
|
||||||
if(!parser_ctx)
|
if(!parser_ctx)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
parser_ctx->ref = 1;
|
parser_ctx->ref = 1;
|
||||||
parser_ctx->hres = E_FAIL;
|
parser_ctx->hres = E_FAIL;
|
||||||
|
parser_ctx->is_html = delimiter && !strcmpiW(delimiter, html_tagW);
|
||||||
|
|
||||||
parser_ctx->begin = parser_ctx->ptr = code;
|
parser_ctx->begin = parser_ctx->ptr = code;
|
||||||
parser_ctx->end = code + strlenW(code);
|
parser_ctx->end = code + strlenW(code);
|
||||||
|
|
|
@ -2386,7 +2386,7 @@ SimpleMatch(REGlobalData *gData, REMatchState *x, REOp op,
|
||||||
|
|
||||||
const char *opname = reop_names[op];
|
const char *opname = reop_names[op];
|
||||||
TRACE("\n%06d: %*s%s\n", pc - gData->regexp->program,
|
TRACE("\n%06d: %*s%s\n", pc - gData->regexp->program,
|
||||||
gData->stateStackTop * 2, "", opname);
|
(int)gData->stateStackTop * 2, "", opname);
|
||||||
|
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case REOP_EMPTY:
|
case REOP_EMPTY:
|
||||||
|
@ -2625,7 +2625,7 @@ ExecuteREBytecode(REGlobalData *gData, REMatchState *x)
|
||||||
for (;;) {
|
for (;;) {
|
||||||
const char *opname = reop_names[op];
|
const char *opname = reop_names[op];
|
||||||
TRACE("\n%06d: %*s%s\n", pc - gData->regexp->program,
|
TRACE("\n%06d: %*s%s\n", pc - gData->regexp->program,
|
||||||
gData->stateStackTop * 2, "", opname);
|
(int)gData->stateStackTop * 2, "", opname);
|
||||||
|
|
||||||
if (REOP_IS_SIMPLE(op)) {
|
if (REOP_IS_SIMPLE(op)) {
|
||||||
result = SimpleMatch(gData, x, op, &pc, TRUE);
|
result = SimpleMatch(gData, x, op, &pc, TRUE);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue