Commit Graph

574 Commits

Author SHA1 Message Date
Tor Andersson
d4655ae888 Show system error message in js_loadfile. 2018-09-04 11:27:34 +02:00
Avi Halachmi (:avih)
924649a69e mujs shell: Add compile function.
The new compile function compiles a source code string as a script and
returns a callable object. The optional 'filename' argument is used to
format error messages and stack traces.
2018-09-04 11:27:34 +02:00
Tor Andersson
84858c335e mujs shell: Make the load function behave like in the SpiderMonkey shell. 2018-09-04 11:27:34 +02:00
Tor Andersson
a2b62c028e Avoid clashing with system getopt. 2018-09-04 11:26:56 +02:00
Tor Andersson
dcb3f03e90 Inherit strictness from invoking function in eval. 2018-09-03 16:10:02 +02:00
Tor Andersson
2c0c6c94ca Use getopt command line argument processing.
Pass script arguments to script as global variable scriptArgs.
2018-09-03 15:30:30 +02:00
Tor Andersson
643d428894 Default mujs shell to non-strict mode.
Pass "-s" as the first argument to start the shell in strict mode.
2018-08-29 13:01:04 +02:00
Tor Andersson
3430d9a06d Return null instead of throwing an error when readline hits EOF. 2018-08-27 12:59:00 +02:00
Sebastian Rasmussen
c86267d8b2 Fix issue 66: Stack overflow when compiling long regexp sequences.
The syntax tree for long chains of Cat nodes leaned leftwards, which
made the compile() step potentially run out of stack. If we build the
Cat tree leaning right, we can use an iterative loop instead of
recursion.
1.0.4
2018-07-30 15:35:39 +02:00
Tor Andersson
5c1300b015 Fix 699559: Off-by-one comparison in regexp parser. 2018-07-26 23:44:15 +02:00
Tor Andersson
b4297c0dec Fix 699557: Pause garbage collector during Ap_sort.
The temporary array we use for sorting cannot be seen by the GC, and that
violates the constraint that all js_Value values must always be reachable
from the stack or global environment.

Temporarily turning off the GC will let us use the temporary array for
fast sorting using qsort(), without tripping over this violation.
2018-07-25 12:00:33 +02:00
Tor Andersson
40b73014d9 Fix 699549: Integer overflow in Array.prototype.sort().
Check size calculation for overflow before allocating memory buffer.
2018-07-23 11:30:22 +02:00
Konstantin Baladurin
dbc0931a5c Fix Date.prototype.setHours 2018-07-19 12:21:43 +02:00
Tor Andersson
bd2470847c Fix logic in Object.isFrozen to comply with spec. 2018-07-16 13:28:04 +02:00
Tor Andersson
49271d3cf2 Add js_iserror function. 2018-07-03 12:00:57 +02:00
Tor Andersson
222772f6bb Remove -ffunction-sections and -fdata-sections compile flags.
They're only of minor benefit. Simpler build systems are better.
2018-06-15 15:22:54 +02:00
Tor Andersson
ceac1b57d9 Allow enabling or disabling readline support by setting HAVE_READLINE. 2018-06-15 15:05:38 +02:00
Tor Andersson
2be672cd30 Fix makefile to remove warning from 'ar' invocation. 2018-06-08 13:52:12 +02:00
Tor Andersson
3f6b06a358 Avoid type punning with unions.
Use memcpy, which is guaranteed to be safe under all compiler flags.
2018-06-08 13:51:10 +02:00
Tor Andersson
34cb61711f Fix 699383: Sorting arrays with zero or negative length. 2018-05-29 14:29:16 +02:00
Tor Andersson
cbdf814ee2 Handle undefined and unset array slots separately in Array.prototype.sort. 2018-05-15 13:51:24 +02:00
Tor Andersson
caabe08cb1 Use qsort to sort arrays. 2018-05-15 13:22:04 +02:00
Tor Andersson
b0e3f5e80d Add readline support to mujs shell. 2018-05-08 13:15:39 +02:00
Tor Andersson
22430de3a9 Fix creation of empty regular expressions.
Handle empty regular expressions in RegExp compiler asserts.

Also turn them into /(?:)/ on the JS side, so they can be printed
back as valid JS syntax where // is a comment, not a regular expression.
2018-05-03 10:45:34 +02:00
Tor Andersson
833f82ca95 Fix issue #65: Uninitialized name in Function.prototype function. 2018-05-03 10:38:55 +02:00
Tor Andersson
b46ee8d829 Add more js_tryxxx conversion functions. 2018-04-27 16:59:35 +02:00
Tor Andersson
780b14b5b7 Fix bug in Ap_sort where tostring values were put back into the array. 2018-04-27 11:11:50 +02:00
Tor Andersson
57b698f0b2 Return null if String.prototype.match with a global regex finds no matches. 2018-04-26 13:30:13 +02:00
Tor Andersson
9d72b07e0b Don't forget to zero-terminate string buffer in Fp_toString. 2018-04-24 15:46:03 +02:00
Tor Andersson
d04cbf3cc7 Add pretty-printing command line tool. 2018-04-23 18:24:31 +02:00
Tor Andersson
25821e6d74 Fix 698920: Guard jsdtoa from integer overflow wreaking havoc. 1.0.3 2018-01-24 16:55:49 +01:00
Tor Andersson
4d45a96e57 Guard binary expressions from too much recursion. 2018-01-24 16:27:16 +01:00
Tor Andersson
8df3dcd8c1 Add XCFLAGS to the CFLAGS in the Makefile.
Supports adding custom compiler flags without editing the Makefile.
2018-01-24 14:44:14 +01:00
Tor Andersson
e25c83d6b5 Fix issue #62: Handle 'this' binding consistently in REPL.
The promotion of 'this' to the global object happens in the interpreter
on the OP_THIS instruction, depending on the current strictness. Don't
push the global object in eval_print in main.c.
2018-01-23 16:19:29 +01:00
Tor Andersson
66cf4ccd82 Fix issue #61: Silence misleading indentation warning.
Add NULL check to pexpi to simplify call sites.
2018-01-22 13:37:09 +01:00
Tor Andersson
849fb89be7 Add recursion overflow check when parsing unary expressions.
Add a recursion counter when we jump to the same grammar clause.
2018-01-15 13:08:31 +01:00
Tor Andersson
228719d087 Remove mention of broken web site. 2018-01-05 14:22:15 +01:00
Tor Andersson
2cb57c6e71 Fix issue #56: MacOS X not detected as a Unix for gettimeofday().
Add ifdef check for __APPLE__ since MacOS X doesn't define __unix__.
1.0.2
2017-12-11 14:15:01 +01:00
Tor Andersson
505751a54e Fix issue #55: Stack overflow bug in Array.prototype.sort(). 2017-12-11 13:22:23 +01:00
Tor Andersson
41625ec2d0 Fix logo size in docs. 2017-11-15 15:24:19 +01:00
Tor Andersson
d63cf4a906 Throw a TypeError when converting an object without toString and valueOf. 2017-11-15 15:10:33 +01:00
Tor Andersson
ac9de3c67b Fix memory leak in main. 2017-09-26 14:37:56 +02:00
Sebastian Rasmussen
5d1904912c Extract mujs version from directory name for releases. 2017-09-26 12:51:39 +02:00
Tor Andersson
2f3d5550a4 Use automatic length in "digits" array in Np_toString.
Hard coding the length to 36 does not match the length of the
initializer, which includes the string zero terminator.

Fixes github issue #48.
2017-09-26 12:50:29 +02:00
Tor Andersson
919238c356 Update docs. 2017-09-19 13:47:28 +02:00
Tor Andersson
8c27b1260d Fix leak in Function.prototype.toString. 2017-09-07 14:31:27 +02:00
Tor Andersson
991f5e738e Add 'make watch' target.
Requires the inotify-tools package on linux, and allows automatic
rebuilds when the source is modified.
2017-09-07 14:31:27 +02:00
Tor Andersson
ffd25b0fe6 Add download link. 2017-09-07 14:31:27 +02:00
Tor Andersson
5b0111dabf Add logo. 2017-09-07 14:31:27 +02:00
Tor Andersson
26af0ff339 Add official web site link to README. 2017-08-21 14:39:18 +02:00