Commit graph

1784 commits

Author SHA1 Message Date
Gabriel Ivăncescu 2e4721ac8f jscript: Pass correct 'this' to host objects in ES5 mode.
For some reason, only pure js objects are passed in mshtml's jscript engine.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
2022-11-30 20:48:20 +01:00
Gabriel Ivăncescu 534b977c62 jscript: Throw proper error when calling Set constructor as method.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
2022-11-23 17:59:47 +01:00
Gabriel Ivăncescu 84f7f60192 jscript: Throw proper error when calling Map constructor as method.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
2022-11-23 17:59:47 +01:00
Gabriel Ivăncescu 8cb5d74125 jscript: Pass correct 'this' to callbacks called by builtins.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
2022-11-23 17:59:47 +01:00
Gabriel Ivăncescu da842966ff jscript: Pass a jsval as the 'this' to disp_call_value.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
2022-11-23 17:59:47 +01:00
Gabriel Ivăncescu 9d4e93cfde jscript: Pass a jsval as the 'this' to jsdisp_call_value.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
2022-11-23 17:59:47 +01:00
Gabriel Ivăncescu 3805eef49a jscript: Initialize source and lastIndex for RegExp.prototype.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
2022-11-23 17:59:47 +01:00
Gabriel Ivăncescu ae73e09a8d jscript: Use CRT allocation functions.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
2022-11-21 22:10:43 +01:00
Alex Henrie 81a432c356 jscript: Remove unused function heap_strdupW. 2022-11-18 18:52:12 +01:00
Alex Henrie 844f771b13 jscript: Use standard C functions for memory allocation in jscript.c. 2022-11-18 18:52:12 +01:00
Alex Henrie 7c26da1ae9 jscript: Use standard C functions for memory allocation in dispex.c. 2022-11-18 18:52:11 +01:00
Gabriel Ivăncescu 0c875dfa5f jscript: Convert filetime to date properly using unsigned division.
Also, the result has to be signed type before converting to double, since
it can be negative then (e.g. if system clock is set before 1970).

Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
2022-11-08 20:09:13 +01:00
Gabriel Ivăncescu d984fb14a5 jscript: Implement VariantChangeType for VT_DISPATCH and VT_UNKNOWN.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
2022-10-31 21:23:42 +01:00
Gabriel Ivăncescu 2dcc5a7026 jscript: Implement reviver argument for JSON.parse.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
2022-10-17 11:27:04 +02:00
Gabriel Ivăncescu a4697901cc jscript/tests: Fix copy paste mistake in JSON test.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
2022-10-17 11:27:04 +02:00
Gabriel Ivăncescu 35a6555929 jscript: Implement Function.prototype.bind's thisArg properly.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
2022-10-17 11:27:04 +02:00
Gabriel Ivăncescu 605819dcd9 jscript: Refill the props at end of enumeration in html mode and retry.
If properties were added during enumeration, for example on the prototype,
they are actually visited in mshtml scripts in any mode.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
2022-10-10 21:15:26 +02:00
Gabriel Ivăncescu 2a228918ef jscript: Fill the builtin props for enumeration on prototypes as well.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
2022-10-10 21:15:25 +02:00
Eric Pouech 4bdf92cb7f jscript: Fix GCC 12.2 warning.
When initializing a jsstr_inline_t with a len < 3, the size passed
for the allocation is smaller then the size of the structure
(as the later is rounded up to the alignment = 4 bytes).

GCC 12.2 complains about this when dereferencing the pointer to
the structure as the size passed for allocation is smaller than the
size of the structure.

The warning is fixed by using flexible array member in
jsstr_inline_t. Given the rounding behavior in memory allocation, this
should not change the size of allocated blocks.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2022-09-19 20:10:36 +02:00
Gabriel Ivăncescu 7be0cffa06 jscript: Implement fdexNameCaseInsensitive flag handling.
Despite common sense, native doesn't seem to look for exact match first;
it simply case-insensitively compares the props and returns as soon as it
finds one. This is also reliant on implementation details in case the object
has multiple props with same case-insensitive names, e.g. an object having
`Foo` prop, with `foo` prop on its prototype, can still find `Foo` even if
you look up `foo` instead (which matches exactly on the prototype). Which
is not always reliable, sometimes it finds the prototype first.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
2022-08-17 19:21:00 +02:00
Santino Mazza d93712feee jscript: Return ParseProcedureText when compile fails.
This prevents crashes when there is an invalid script
inside a tag property.

Because ParseProcedureText calls release_bytecode without
checking if compile_script failed, "code" is not set, and
this leads to a crash when release_bytecode tries to access it.

Signed-off-by: Santino Mazza <mazzasantino1206@gmail.com>
2022-07-20 22:33:44 +02:00
Jacek Caban 6010e6b8cb jscript: Correctly handle deleted entries in iterate_map.
Based on patch by Gabriel Ivăncescu.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2022-06-07 19:37:11 +02:00
Gabriel Ivăncescu bae77953ed jscript: Use LIST_FOR_EACH_ENTRY_SAFE to clear Map and Set objects.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2022-06-07 19:37:11 +02:00
Jacek Caban 34aeef628f jscript/tests: Add test for releasing script context objects.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2022-06-07 19:37:11 +02:00
Gabriel Ivăncescu 738e306bf7 jscript: Don't allow construction on builtin methods.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-03 21:55:17 +02:00
Gabriel Ivăncescu 79e51d6bc5 jscript: Release all globals when the script is uninitialized.
Most of these globals were leaking before as they were never freed at all.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-03 21:55:17 +02:00
Gabriel Ivăncescu c35e5274ed jscript: Forward actual error in to_primitive if it's not just missing prop.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-03 21:55:17 +02:00
Gabriel Ivăncescu 469219dcf7 jscript: Don't execute any functions if script state does not allow it.
Instead of only interpreted functions. Property retrievals or setters are
allowed though, as long as they are not accessors.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-03 21:55:17 +02:00
Gabriel Ivăncescu c8d7d504eb jscript: Setup builtin function when the dispid is retrieved.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-03 21:55:17 +02:00
Gabriel Ivăncescu 079b14b2e9 jscript: Don't allow starting script using state from uninitialized.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-03 21:55:17 +02:00
Gabriel Ivăncescu 2e9d086b04 jscript: Pass undefined 'this' instead of null in ES5 mode.
Based on the spec (ECMA-262 5.1 Edition 11.2.3.7), whereas the ES3 spec
says it gets replaced with null.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-16 22:10:15 +02:00
Gabriel Ivăncescu 5007c4d72f jscript: Handle detached scope objects 'this' in all calls.
Not just for interpreted functions.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-16 22:10:15 +02:00
Gabriel Ivăncescu 36d96b0fa0 jscript: Implement Array.prototype.lastIndexOf.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-03 20:25:25 +02:00
Gabriel Ivăncescu f0dd9748da jscript: Implement Array.prototype.some.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-03 20:25:11 +02:00
Gabriel Ivăncescu eb80db6f8a jscript: Implement Array.prototype.every.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-03 20:24:58 +02:00
Gabriel Ivăncescu c603fb490a jscript: Implement Array.prototype.filter.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-03 20:24:44 +02:00
Gabriel Ivăncescu a8057c2e14 jscript: Implement Array.prototype.toLocaleString.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-03 20:24:31 +02:00
Gabriel Ivăncescu 41782ec12e jscript: Return proper error in Number.toLocaleString with invalid 'this' in ES5 mode.
Note that, for example, Number.toFixed still returns JS_E_NUMBER_EXPECTED
even in ES5 mode (this is already tested).

Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-03 20:24:18 +02:00
Gabriel Ivăncescu 8aefdf48f9 jscript: Implement Number.prototype.toLocaleString.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-03 20:24:06 +02:00
Gabriel Ivăncescu e254680ed1 jscript: Initialize hres in String constructor.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-15 20:55:55 +02:00
Gabriel Ivăncescu 121851955e jscript: Use proper error description for invalid Set 'this'.
Map and Set share the same error code, but the description given is different,
so we need to throw it manually.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-14 23:45:30 +02:00
Gabriel Ivăncescu 58479eefea jscript: Implement Set on top of Map.
Because a Set is just a Map where key == value.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-14 23:45:29 +02:00
Gabriel Ivăncescu 15053a1d17 jscript: Compare numbers in a Map bitwise for equality.
Native treats -0 and 0 differently, so it must be doing a bitwise
comparison. This might not order the numbers correctly, but that's not
important, since we don't need them sorted other than for quick lookup
(and any arbitrary sorting is fine, as long as it's consistent).

Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-14 23:45:29 +02:00
Gabriel Ivăncescu 251eda6f56 jscript: Support passing 'this' context to the Map callback when iterating.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-14 23:45:29 +02:00
Gabriel Ivăncescu 399f8b6f06 jscript: Pass the Map object to the callback when iterating.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-14 23:45:29 +02:00
Gabriel Ivăncescu 477026a55b jscript: Set a map entry using a helper function.
So it can be re-used by Set objects.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-14 23:45:29 +02:00
Gabriel Ivăncescu ce644eedae jscript: Iterate through the map in a helper function.
So it can be re-used by Set objects.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-14 23:45:29 +02:00
Gabriel Ivăncescu 27ce397307 jscript: Move Set below Map.
So it can be implemented on top of Map.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-14 23:45:29 +02:00
Gabriel Ivăncescu c464c1bd47 jscript: Handle NULL return pointers in all constructors.
Instead of crashing.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-14 23:45:29 +02:00
Gabriel Ivăncescu 2bdce91e8f jscript: Defer lookup to the actual locals for function statements.
Functions declared as function statements have an associated local_ref and
can be changed from within themselves by using their name (by literally
changing the local variable), while function expressions can not.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-13 20:19:47 +02:00