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
e52115d6
Commit
e52115d6
authored
Oct 14, 2009
by
Jacek Caban
Committed by
Alexandre Julliard
Oct 14, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Create regexp object when evaluating regexp literal.
parent
98b5a1c6
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
39 deletions
+37
-39
engine.c
dlls/jscript/engine.c
+21
-8
engine.h
dlls/jscript/engine.h
+7
-8
lex.c
dlls/jscript/lex.c
+4
-18
parser.y
dlls/jscript/parser.y
+0
-5
lang.js
dlls/jscript/tests/lang.js
+5
-0
No files found.
dlls/jscript/engine.c
View file @
e52115d6
...
...
@@ -347,7 +347,7 @@ static HRESULT equal2_values(VARIANT *lval, VARIANT *rval, BOOL *ret)
return
S_OK
;
}
static
HRESULT
literal_to_var
(
literal_t
*
literal
,
VARIANT
*
v
)
static
HRESULT
literal_to_var
(
script_ctx_t
*
ctx
,
literal_t
*
literal
,
VARIANT
*
v
)
{
switch
(
literal
->
type
)
{
case
LT_UNDEFINED
:
...
...
@@ -364,18 +364,31 @@ static HRESULT literal_to_var(literal_t *literal, VARIANT *v)
V_VT
(
v
)
=
VT_R8
;
V_R8
(
v
)
=
literal
->
u
.
dval
;
break
;
case
LT_STRING
:
case
LT_STRING
:
{
BSTR
str
=
SysAllocString
(
literal
->
u
.
wstr
);
if
(
!
str
)
return
E_OUTOFMEMORY
;
V_VT
(
v
)
=
VT_BSTR
;
V_BSTR
(
v
)
=
SysAllocString
(
literal
->
u
.
wstr
)
;
V_BSTR
(
v
)
=
str
;
break
;
}
case
LT_BOOL
:
V_VT
(
v
)
=
VT_BOOL
;
V_BOOL
(
v
)
=
literal
->
u
.
bval
;
break
;
case
LT_DISPATCH
:
case
LT_REGEXP
:
{
DispatchEx
*
regexp
;
HRESULT
hres
;
hres
=
create_regexp
(
ctx
,
literal
->
u
.
regexp
.
str
,
literal
->
u
.
regexp
.
str_len
,
literal
->
u
.
regexp
.
flags
,
&
regexp
);
if
(
FAILED
(
hres
))
return
hres
;
V_VT
(
v
)
=
VT_DISPATCH
;
IDispatch_AddRef
(
literal
->
u
.
dis
p
);
V_DISPATCH
(
v
)
=
literal
->
u
.
disp
;
V_DISPATCH
(
v
)
=
(
IDispatch
*
)
_IDispatchEx_
(
regex
p
);
}
}
return
S_OK
;
...
...
@@ -1656,7 +1669,7 @@ HRESULT literal_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flag
TRACE
(
"
\n
"
);
hres
=
literal_to_var
(
expr
->
literal
,
&
var
);
hres
=
literal_to_var
(
ctx
->
parser
->
script
,
expr
->
literal
,
&
var
);
if
(
FAILED
(
hres
))
return
hres
;
...
...
@@ -1735,7 +1748,7 @@ HRESULT property_value_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWO
return
hres
;
for
(
iter
=
expr
->
property_list
;
iter
;
iter
=
iter
->
next
)
{
hres
=
literal_to_var
(
iter
->
name
,
&
tmp
);
hres
=
literal_to_var
(
ctx
->
parser
->
script
,
iter
->
name
,
&
tmp
);
if
(
FAILED
(
hres
))
break
;
...
...
dlls/jscript/engine.h
View file @
e52115d6
...
...
@@ -19,11 +19,6 @@
typedef
struct
_source_elements_t
source_elements_t
;
typedef
struct
_function_expression_t
function_expression_t
;
typedef
struct
_obj_literal_t
{
DispatchEx
*
obj
;
struct
_obj_literal_t
*
next
;
}
obj_literal_t
;
typedef
struct
_function_declaration_t
{
function_expression_t
*
expr
;
...
...
@@ -61,7 +56,6 @@ typedef struct _parser_ctx_t {
jsheap_t
heap
;
obj_literal_t
*
obj_literals
;
func_stack_t
*
func_stack
;
struct
_parser_ctx_t
*
next
;
...
...
@@ -131,9 +125,9 @@ typedef enum {
LT_DOUBLE
,
LT_STRING
,
LT_BOOL
,
LT_DISPATCH
,
LT_UNDEFINED
,
LT_NULL
LT_NULL
,
LT_REGEXP
}
literal_type_t
;
typedef
struct
{
...
...
@@ -144,6 +138,11 @@ typedef struct {
const
WCHAR
*
wstr
;
VARIANT_BOOL
bval
;
IDispatch
*
disp
;
struct
{
const
WCHAR
*
str
;
DWORD
str_len
;
DWORD
flags
;
}
regexp
;
}
u
;
}
literal_t
;
...
...
dlls/jscript/lex.c
View file @
e52115d6
...
...
@@ -755,20 +755,10 @@ int parser_lex(void *lval, parser_ctx_t *ctx)
return
0
;
}
static
void
add_object_literal
(
parser_ctx_t
*
ctx
,
DispatchEx
*
obj
)
{
obj_literal_t
*
literal
=
parser_alloc
(
ctx
,
sizeof
(
obj_literal_t
));
literal
->
obj
=
obj
;
literal
->
next
=
ctx
->
obj_literals
;
ctx
->
obj_literals
=
literal
;
}
literal_t
*
parse_regexp
(
parser_ctx_t
*
ctx
)
{
const
WCHAR
*
re
,
*
flags_ptr
;
DWORD
re_len
,
flags
;
DispatchEx
*
regexp
;
literal_t
*
ret
;
HRESULT
hres
;
...
...
@@ -798,14 +788,10 @@ literal_t *parse_regexp(parser_ctx_t *ctx)
if
(
FAILED
(
hres
))
return
NULL
;
hres
=
create_regexp
(
ctx
->
script
,
re
,
re_len
,
flags
,
&
regexp
);
if
(
FAILED
(
hres
))
return
NULL
;
add_object_literal
(
ctx
,
regexp
);
ret
=
parser_alloc
(
ctx
,
sizeof
(
literal_t
));
ret
->
type
=
LT_DISPATCH
;
ret
->
u
.
disp
=
(
IDispatch
*
)
_IDispatchEx_
(
regexp
);
ret
->
type
=
LT_REGEXP
;
ret
->
u
.
regexp
.
str
=
re
;
ret
->
u
.
regexp
.
str_len
=
re_len
;
ret
->
u
.
regexp
.
flags
=
flags
;
return
ret
;
}
dlls/jscript/parser.y
View file @
e52115d6
...
...
@@ -1591,14 +1591,9 @@ static void program_parsed(parser_ctx_t *ctx, source_elements_t *source)
void parser_release(parser_ctx_t *ctx)
{
obj_literal_t *iter;
if(--ctx->ref)
return;
for(iter = ctx->obj_literals; iter; iter = iter->next)
jsdisp_release(iter->obj);
jsheap_free(&ctx->heap);
heap_free(ctx);
}
...
...
dlls/jscript/tests/lang.js
View file @
e52115d6
...
...
@@ -934,6 +934,11 @@ ok((function (){return 1;})() === 1, "(function (){return 1;})() = " + (function
var
re
=
/=
(\?
|%3F
)
/g
;
ok
(
re
.
source
===
"=(
\\
?|%3F)"
,
"re.source = "
+
re
.
source
);
tmp
=
new
Array
();
for
(
var
i
=
0
;
i
<
2
;
i
++
)
tmp
[
i
]
=
/b/
;
ok
(
tmp
[
0
]
!=
tmp
[
1
],
"tmp[0] == tmp [1]"
);
ok
(
createNullBSTR
()
===
''
,
"createNullBSTR() !== ''"
);
ok
(
getVT
(
nullDisp
)
===
"VT_DISPATCH"
,
"getVT(nullDisp) = "
+
getVT
(
nullDisp
));
...
...
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