mirror of
https://github.com/reactos/reactos.git
synced 2024-12-31 19:42:51 +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;
|
||||
source_elements_t *source;
|
||||
BOOL nl;
|
||||
BOOL is_html;
|
||||
HRESULT hres;
|
||||
|
||||
jsheap_t heap;
|
||||
|
@ -65,7 +66,7 @@ typedef struct _parser_ctx_t {
|
|||
struct _parser_ctx_t *next;
|
||||
} 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*);
|
||||
|
||||
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)));
|
||||
hres = script_parse(dispex->ctx, V_BSTR(arg), &parser_ctx);
|
||||
hres = script_parse(dispex->ctx, V_BSTR(arg), NULL, &parser_ctx);
|
||||
if(FAILED(hres)) {
|
||||
WARN("parse (%s) failed: %08x\n", debugstr_w(V_BSTR(arg)), hres);
|
||||
return hres;
|
||||
|
|
|
@ -596,7 +596,7 @@ static HRESULT WINAPI JScriptParse_ParseScriptText(IActiveScriptParse *iface,
|
|||
if(This->thread_id != GetCurrentThreadId() || This->ctx->state == SCRIPTSTATE_CLOSED)
|
||||
return E_UNEXPECTED;
|
||||
|
||||
hres = script_parse(This->ctx, pstrCode, &parser_ctx);
|
||||
hres = script_parse(This->ctx, pstrCode, pstrDelimiter, &parser_ctx);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
|
@ -662,7 +662,7 @@ static HRESULT WINAPI JScriptParseProcedure_ParseProcedureText(IActiveScriptPars
|
|||
if(This->thread_id != GetCurrentThreadId() || This->ctx->state == SCRIPTSTATE_CLOSED)
|
||||
return E_UNEXPECTED;
|
||||
|
||||
hres = script_parse(This->ctx, pstrCode, &parser_ctx);
|
||||
hres = script_parse(This->ctx, pstrCode, pstrDelimiter, &parser_ctx);
|
||||
if(FAILED(hres)) {
|
||||
WARN("Parse failed %08x\n", 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)
|
||||
{
|
||||
if(ctx->ptr+1 >= ctx->end || *ctx->ptr != '/')
|
||||
|
@ -466,13 +480,13 @@ int parser_lex(void *lval, parser_ctx_t *ctx)
|
|||
{
|
||||
int ret;
|
||||
|
||||
ctx->nl = FALSE;
|
||||
ctx->nl = ctx->ptr == ctx->begin;
|
||||
|
||||
do {
|
||||
skip_spaces(ctx);
|
||||
if(ctx->ptr == ctx->end)
|
||||
return 0;
|
||||
}while(skip_comment(ctx));
|
||||
}while(skip_comment(ctx) || skip_html_comment(ctx));
|
||||
|
||||
if(isalphaW(*ctx->ptr)) {
|
||||
ret = check_keywords(ctx, lval);
|
||||
|
@ -585,8 +599,12 @@ int parser_lex(void *lval, parser_ctx_t *ctx)
|
|||
ctx->ptr++;
|
||||
if(ctx->ptr < ctx->end) {
|
||||
switch(*ctx->ptr) {
|
||||
case '-': /* -- */
|
||||
case '-': /* -- or --> */
|
||||
ctx->ptr++;
|
||||
if(ctx->is_html && ctx->nl && ctx->ptr < ctx->end && *ctx->ptr == '>') {
|
||||
ctx->ptr++;
|
||||
return tHTMLCOMMENT;
|
||||
}
|
||||
return tDEC;
|
||||
case '=': /* -= */
|
||||
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,
|
||||
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
|
||||
{
|
||||
FIXME("\n");
|
||||
return E_NOTIMPL;
|
||||
TRACE("\n");
|
||||
return math_constant(M_LN2, flags, retv);
|
||||
}
|
||||
|
||||
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,
|
||||
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
|
||||
{
|
||||
FIXME("\n");
|
||||
return E_NOTIMPL;
|
||||
VARIANT v;
|
||||
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,
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,27 +1,37 @@
|
|||
/* A Bison parser, made by GNU Bison 2.1. */
|
||||
|
||||
/* Skeleton parser for Yacc-like parsing with Bison,
|
||||
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
/* A Bison parser, made by GNU Bison 2.4.1. */
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA. */
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* 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. */
|
||||
#ifndef YYTOKENTYPE
|
||||
|
@ -61,66 +71,28 @@
|
|||
tOROR = 287,
|
||||
tINC = 288,
|
||||
tDEC = 289,
|
||||
kFUNCTION = 290,
|
||||
tIdentifier = 291,
|
||||
tAssignOper = 292,
|
||||
tEqOper = 293,
|
||||
tShiftOper = 294,
|
||||
tRelOper = 295,
|
||||
tNumericLiteral = 296,
|
||||
tStringLiteral = 297,
|
||||
LOWER_THAN_ELSE = 298
|
||||
tHTMLCOMMENT = 290,
|
||||
kFUNCTION = 291,
|
||||
tIdentifier = 292,
|
||||
tAssignOper = 293,
|
||||
tEqOper = 294,
|
||||
tShiftOper = 295,
|
||||
tRelOper = 296,
|
||||
tNumericLiteral = 297,
|
||||
tStringLiteral = 298,
|
||||
LOWER_THAN_ELSE = 299
|
||||
};
|
||||
#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"
|
||||
typedef union YYSTYPE {
|
||||
|
||||
int ival;
|
||||
const WCHAR *srcptr;
|
||||
LPCWSTR wstr;
|
||||
|
@ -139,15 +111,17 @@ typedef union YYSTYPE {
|
|||
struct _statement_list_t *statement_list;
|
||||
struct _variable_list_t *variable_list;
|
||||
variable_declaration_t *variable_declaration;
|
||||
|
||||
|
||||
|
||||
/* Line 1676 of yacc.c */
|
||||
#line 119 "parser.tab.h"
|
||||
} YYSTYPE;
|
||||
/* Line 1447 of yacc.c. */
|
||||
#line 145 "parser.tab.h"
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||
# define YYSTYPE_IS_DECLARED 1
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -170,7 +170,7 @@ static source_elements_t *source_elements_add_statement(source_elements_t*,state
|
|||
/* keywords */
|
||||
%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 tANDAND tOROR tINC tDEC
|
||||
%token tANDAND tOROR tINC tDEC tHTMLCOMMENT
|
||||
|
||||
%token <srcptr> kFUNCTION '}'
|
||||
|
||||
|
@ -251,7 +251,12 @@ static source_elements_t *source_elements_add_statement(source_elements_t*,state
|
|||
|
||||
/* ECMA-262 3rd Edition 14 */
|
||||
Program
|
||||
: SourceElements { program_parsed(ctx, $1); }
|
||||
: SourceElements HtmlComment
|
||||
{ program_parsed(ctx, $1); }
|
||||
|
||||
HtmlComment
|
||||
: tHTMLCOMMENT {}
|
||||
| /* empty */ {}
|
||||
|
||||
/* ECMA-262 3rd Edition 14 */
|
||||
SourceElements
|
||||
|
@ -1549,18 +1554,22 @@ void parser_release(parser_ctx_t *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;
|
||||
jsheap_t *mark;
|
||||
HRESULT hres;
|
||||
|
||||
const WCHAR html_tagW[] = {'<','/','s','c','r','i','p','t','>',0};
|
||||
|
||||
parser_ctx = heap_alloc_zero(sizeof(parser_ctx_t));
|
||||
if(!parser_ctx)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
parser_ctx->ref = 1;
|
||||
parser_ctx->hres = E_FAIL;
|
||||
parser_ctx->is_html = delimiter && !strcmpiW(delimiter, html_tagW);
|
||||
|
||||
parser_ctx->begin = parser_ctx->ptr = code;
|
||||
parser_ctx->end = code + strlenW(code);
|
||||
|
|
|
@ -2386,7 +2386,7 @@ SimpleMatch(REGlobalData *gData, REMatchState *x, REOp op,
|
|||
|
||||
const char *opname = reop_names[op];
|
||||
TRACE("\n%06d: %*s%s\n", pc - gData->regexp->program,
|
||||
gData->stateStackTop * 2, "", opname);
|
||||
(int)gData->stateStackTop * 2, "", opname);
|
||||
|
||||
switch (op) {
|
||||
case REOP_EMPTY:
|
||||
|
@ -2625,7 +2625,7 @@ ExecuteREBytecode(REGlobalData *gData, REMatchState *x)
|
|||
for (;;) {
|
||||
const char *opname = reop_names[op];
|
||||
TRACE("\n%06d: %*s%s\n", pc - gData->regexp->program,
|
||||
gData->stateStackTop * 2, "", opname);
|
||||
(int)gData->stateStackTop * 2, "", opname);
|
||||
|
||||
if (REOP_IS_SIMPLE(op)) {
|
||||
result = SimpleMatch(gData, x, op, &pc, TRUE);
|
||||
|
|
Loading…
Reference in a new issue