Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
0fb086d5
Commit
0fb086d5
authored
Jan 23, 2020
by
Jacek Caban
Committed by
Alexandre Julliard
Jan 23, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Use parser location to calculate function body string.
Signed-off-by:
Jacek Caban
<
jacek@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
2296bd73
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
27 deletions
+31
-27
compile.c
dlls/jscript/compile.c
+9
-1
lex.c
dlls/jscript/lex.c
+8
-8
parser.h
dlls/jscript/parser.h
+1
-1
parser.y
dlls/jscript/parser.y
+13
-17
No files found.
dlls/jscript/compile.c
View file @
0fb086d5
...
...
@@ -2245,6 +2245,11 @@ void release_bytecode(bytecode_t *code)
static
HRESULT
init_code
(
compiler_ctx_t
*
compiler
,
const
WCHAR
*
source
)
{
size_t
len
=
source
?
lstrlenW
(
source
)
:
0
;
if
(
len
>
INT32_MAX
)
return
E_OUTOFMEMORY
;
compiler
->
code
=
heap_alloc_zero
(
sizeof
(
bytecode_t
));
if
(
!
compiler
->
code
)
return
E_OUTOFMEMORY
;
...
...
@@ -2252,11 +2257,14 @@ static HRESULT init_code(compiler_ctx_t *compiler, const WCHAR *source)
compiler
->
code
->
ref
=
1
;
heap_pool_init
(
&
compiler
->
code
->
heap
);
compiler
->
code
->
source
=
heap_
strdupW
(
source
);
compiler
->
code
->
source
=
heap_
alloc
((
len
+
1
)
*
sizeof
(
WCHAR
)
);
if
(
!
compiler
->
code
->
source
)
{
release_bytecode
(
compiler
->
code
);
return
E_OUTOFMEMORY
;
}
if
(
len
)
memcpy
(
compiler
->
code
->
source
,
source
,
len
*
sizeof
(
WCHAR
));
compiler
->
code
->
source
[
len
]
=
0
;
compiler
->
code
->
instrs
=
heap_alloc
(
64
*
sizeof
(
instr_t
));
if
(
!
compiler
->
code
->
instrs
)
{
...
...
dlls/jscript/lex.c
View file @
0fb086d5
...
...
@@ -543,12 +543,15 @@ static BOOL parse_numeric_literal(parser_ctx_t *ctx, double *ret)
return
TRUE
;
}
static
int
next_token
(
parser_ctx_t
*
ctx
,
void
*
lval
)
static
int
next_token
(
parser_ctx_t
*
ctx
,
unsigned
*
loc
,
void
*
lval
)
{
do
{
if
(
!
skip_spaces
(
ctx
))
if
(
!
skip_spaces
(
ctx
))
{
*
loc
=
ctx
->
ptr
-
ctx
->
begin
;
return
tEOF
;
}
}
while
(
skip_comment
(
ctx
)
||
skip_html_comment
(
ctx
));
*
loc
=
ctx
->
ptr
-
ctx
->
begin
;
if
(
ctx
->
implicit_nl_semicolon
)
{
if
(
ctx
->
nl
)
...
...
@@ -576,6 +579,7 @@ static int next_token(parser_ctx_t *ctx, void *lval)
switch
(
*
ctx
->
ptr
)
{
case
'{'
:
case
'}'
:
case
'('
:
case
')'
:
case
'['
:
...
...
@@ -586,10 +590,6 @@ static int next_token(parser_ctx_t *ctx, void *lval)
case
'?'
:
return
*
ctx
->
ptr
++
;
case
'}'
:
*
(
const
WCHAR
**
)
lval
=
ctx
->
ptr
++
;
return
'}'
;
case
'.'
:
if
(
ctx
->
ptr
+
1
<
ctx
->
end
&&
is_digit
(
ctx
->
ptr
[
1
]))
{
double
n
;
...
...
@@ -1099,14 +1099,14 @@ static int cc_token(parser_ctx_t *ctx, void *lval)
return
tBooleanLiteral
;
}
int
parser_lex
(
void
*
lval
,
parser_ctx_t
*
ctx
)
int
parser_lex
(
void
*
lval
,
unsigned
*
loc
,
parser_ctx_t
*
ctx
)
{
int
ret
;
ctx
->
nl
=
ctx
->
ptr
==
ctx
->
begin
;
do
{
ret
=
next_token
(
ctx
,
lval
);
ret
=
next_token
(
ctx
,
l
oc
,
l
val
);
}
while
(
ret
==
'@'
&&
!
(
ret
=
cc_token
(
ctx
,
lval
)));
return
ret
;
...
...
dlls/jscript/parser.h
View file @
0fb086d5
...
...
@@ -51,7 +51,7 @@ typedef struct _parser_ctx_t {
HRESULT
script_parse
(
script_ctx_t
*
,
struct
_compiler_ctx_t
*
,
const
WCHAR
*
,
const
WCHAR
*
,
BOOL
,
parser_ctx_t
**
)
DECLSPEC_HIDDEN
;
void
parser_release
(
parser_ctx_t
*
)
DECLSPEC_HIDDEN
;
int
parser_lex
(
void
*
,
parser_ctx_t
*
)
DECLSPEC_HIDDEN
;
int
parser_lex
(
void
*
,
unsigned
*
,
parser_ctx_t
*
)
DECLSPEC_HIDDEN
;
static
inline
void
*
parser_alloc
(
parser_ctx_t
*
ctx
,
DWORD
size
)
{
...
...
dlls/jscript/parser.y
View file @
0fb086d5
...
...
@@ -26,7 +26,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(jscript);
static int parser_error(parser_ctx_t*,const char*);
static int parser_error(
unsigned*,
parser_ctx_t*,const char*);
static void set_error(parser_ctx_t*,UINT);
static BOOL explicit_error(parser_ctx_t*,void*,WCHAR);
static BOOL allow_auto_semicolon(parser_ctx_t*);
...
...
@@ -137,6 +137,9 @@ 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)
%}
%lex-param { parser_ctx_t *ctx }
...
...
@@ -146,7 +149,6 @@ static source_elements_t *source_elements_add_statement(source_elements_t*,state
%union {
int ival;
const WCHAR *srcptr;
jsstr_t *str;
literal_t *literal;
struct _argument_list_t *argument_list;
...
...
@@ -171,8 +173,6 @@ static source_elements_t *source_elements_add_statement(source_elements_t*,state
%token <identifier> kINSTANCEOF kNEW kNULL kRETURN kSWITCH kTHIS kTHROW kTRUE kFALSE kTRY kTYPEOF kVAR kVOID kWHILE kWITH
%token tANDAND tOROR tINC tDEC tHTMLCOMMENT kDIVEQ kDCOL
%token <srcptr> '}'
/* tokens */
%token <identifier> tIdentifier
%token <ival> tAssignOper tEqOper tShiftOper tRelOper
...
...
@@ -244,7 +244,6 @@ static source_elements_t *source_elements_add_statement(source_elements_t*,state
%type <property_definition> PropertyDefinition
%type <literal> PropertyName
%type <literal> BooleanLiteral
%type <srcptr> KFunction left_bracket
%type <ival> AssignOper
%type <identifier> IdentifierName ReservedAsIdentifier
...
...
@@ -270,15 +269,12 @@ SourceElements
/* ECMA-262 3rd Edition 13 */
FunctionExpression
: KFunction left_bracket FormalParameterList_opt right_bracket '{' FunctionBody '}'
{ $$ = 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 { $$ = ctx->ptr - 8; }
: kFUNCTION left_bracket FormalParameterList_opt right_bracket '{' FunctionBody '}'
{ $$ = new_function_expression(ctx, NULL, $3, $6, NULL, ctx->begin + @1, @7 - @1 + 1); }
| kFUNCTION tIdentifier left_bracket FormalParameterList_opt right_bracket '{' FunctionBody '}'
{ $$ = new_function_expression(ctx, $2, $4, $7, NULL, ctx->begin + @1, @8 - @1 + 1); }
| 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 */
FunctionBody
...
...
@@ -809,7 +805,7 @@ PropertyDefinition
GetterSetterMethod
: left_bracket FormalParameterList_opt right_bracket '{' FunctionBody '}'
{ $$ = new_function_expression(ctx, NULL, $2, $5, NULL,
$1, $6-$
1); }
{ $$ = new_function_expression(ctx, NULL, $2, $5, NULL,
ctx->begin + @1, @6 - @1 +
1); }
/* Ecma-262 3rd Edition 11.1.5 */
PropertyName
...
...
@@ -889,7 +885,7 @@ semicolon_opt
| error { if(!allow_auto_semicolon(ctx)) {YYABORT;} }
left_bracket
: '('
{ $$ = ctx->ptr; }
: '('
| error { set_error(ctx, JS_E_MISSING_LBRACKET); YYABORT; }
right_bracket
...
...
@@ -1461,7 +1457,7 @@ static expression_t *new_call_expression(parser_ctx_t *ctx, expression_t *expres
return &ret->expr;
}
static int parser_error(parser_ctx_t *ctx, const char *str)
static int parser_error(
unsigned *loc,
parser_ctx_t *ctx, const char *str)
{
return 0;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment