Tor Andersson
2eb4fd2272
Bug 703459: Handle undefined argument to Error constructor.
2021-02-03 17:31:50 +01:00
Tor Andersson
a09d8697db
Bug 697702: Add workaround for MSVC not having unistd.h
2021-01-12 14:54:50 +01:00
Tor Andersson
603977ae5b
Add repr() function to shell, and use it in the REPL.
2019-03-22 14:00:20 +01:00
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
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
Tor Andersson
b0e3f5e80d
Add readline support to mujs shell.
2018-05-08 13:15:39 +02: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
ac9de3c67b
Fix memory leak in main.
2017-09-26 14:37:56 +02:00
Sebastian Rasmussen
1399bbe244
Free script buffer read from standard input.
2017-05-22 22:17:57 +08:00
Tor Andersson
6a85c78a5d
Fix error message when missing stack traces in main.c
2017-05-16 13:17:04 +02:00
Tor Andersson
134134e899
Don't do unprotected js_tostring calls in js_dostring/file.
...
Since js_tostring can invoke a toString method, we should guard against
uncaught exceptions when trying to convert the error object to a string.
Add a public function, js_trystring that does a "safe" conversion
to a string.
2017-05-09 14:47:19 +02:00
Tor Andersson
2296f47e4c
Make Error.prototype.toString conform to the spec.
...
Override the toString function in the default shell to provide a
stack trace instead.
2017-04-20 14:56:53 +02:00
Tor Andersson
eafe79436d
Handle non-tty stdin more gracefully in example shell tool.
...
If stdin is not a tty, read the entire script from stdin and run it
silently.
2016-12-27 13:49:17 +01:00
Tor Andersson
3e3c382a0c
Avoid using 'unsigned int'.
...
Mixing signed and unsigned ints is just a plain headache.
2016-04-27 16:26:00 +02:00
Tor Andersson
c90c32326e
Fix bugs introduced when moving from argc to js_gettop.
...
The 'length' field of a function is used to fill in missing arguments
with undefined; this does not mesh well with functions that query for
missing arguments using js_gettop. Set their lengths to 0 instead.
2016-04-15 12:18:34 +02:00
Tor Andersson
d800b59f0f
Clean up stack on errors in js_pcall and js_pconstruct.
...
Exactly one value will remain on the stack after js_pcall: either
the return value or the error object.
2016-01-06 13:43:59 +01:00
Tor Andersson
0b9d3be3d0
Remove 'report' argument from js_dostring.
2015-12-16 11:49:52 +01:00
Tor Andersson
8f790df9e5
Add strict mode flag to constructor.
2015-01-14 13:04:46 +01:00
Tor Andersson
5e3e9fdde4
Check error for all fseek/ftell calls.
2015-01-05 13:03:30 +01:00
Tor Andersson
031513b25b
Add stack traces to error objects.
...
Revert 'add context and flag argument to js_newstate' commit.
The context argument just adds clutter. The flag which was intended
for JS_DEBUG and/or JS_STRICT shouldn't be necessary.
js_newcfunction and js_newcconstructor need an extra argument, the
name of the function to use in stack traces.
2014-12-03 01:18:21 +01:00
Tor Andersson
84faaff8ff
Add user context pointer and flag argument to js_State constructor.
2014-11-29 16:12:30 +01:00
Tor Andersson
1f137b8e48
Improve MuJS interactive shell.
...
Add read/readline/write/quit functions.
Add CommonJS style modules with require function.
2014-07-31 16:52:26 +02:00
Tor Andersson
48aed4bbb6
Name the library: MuJS!
2014-03-19 23:07:33 +01:00
Tor Andersson
d366e4b852
Don't pass argc to functions. Use js_gettop instead.
2014-03-12 16:40:48 +01:00
Tor Andersson
abd59674cc
Allow custom allocator.
2014-02-28 17:14:11 +01:00
Tor Andersson
70b0d8b902
Change C functions to not have a return value.
...
They should always push a return value on the JS stack.
2014-02-25 00:56:33 +01:00
Tor Andersson
c7e9ab0b05
Fix signed/unsigned comparison warnings.
2014-02-24 23:55:58 +01:00
Tor Andersson
7573f4238e
Abort main.c with return status if a script fails.
...
Needed for test suites.
2014-02-05 05:18:25 +01:00
Tor Andersson
241905d43c
Add load() function to main.c
2014-02-04 15:30:16 +01:00
Tor Andersson
96667d99b1
Use precedence table when pretty-printing syntax.
2014-02-04 15:05:03 +01:00
Tor Andersson
4595872bb3
Move non-standard 'gc' and 'print' global functions into main.c example.
2014-01-24 16:18:55 +01:00
Tor Andersson
b22dc395c9
Use ES5 specification for implementation of Error.prototype.toString().
2014-01-24 02:13:20 +01:00
Tor Andersson
5cdcc20936
Simplistic REPL.
2014-01-21 15:15:22 +01:00
Tor Andersson
40a12fba0d
Split header into js.h public and jsi.h private. Start cleaning up
...
private function prefixes.
2014-01-20 16:13:09 +01:00
Tor Andersson
704d16409f
Collect garbage.
2014-01-18 00:02:04 +01:00
Tor Andersson
56042de82b
Fix the shape of the outer API a bit. Implement eval.
2014-01-16 21:36:54 +01:00
Tor Andersson
18b192b8aa
Minor cleanups.
2014-01-16 02:14:07 +01:00
Sebastian Rasmussen
429d7cdce9
Fix typo so all arguments are loaded.
2013-12-30 22:58:43 +01:00
Sebastian Rasmussen
bb2279e43d
Add lexer.
2013-12-23 19:53:34 +01:00