Tor Andersson
278590fcb4
Merge the small private header files into jsi.h
2023-01-04 17:29:22 +01:00
Tor Andersson
1780d0ea73
Bug 704756: Don't trust function.length property!
...
Calling js_call with n < 0 led to us popping a negative number of items
from the stack, which could make us miss the stack size check.
Sanitize all uses of function.length in Function.prototype.apply and
Function.prototype.bind.
2021-12-08 12:56:12 +01:00
Tor Andersson
9f34a074eb
Revert "Bug 701886: Always create new scope for eval()."
...
This reverts commit d248b0ce18 .
2021-03-04 12:08:42 +01:00
Tor Andersson
d248b0ce18
Bug 701886: Always create new scope for eval().
...
Distinguish eval code from script code.
2020-01-02 14:37:05 +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
833f82ca95
Fix issue #65 : Uninitialized name in Function.prototype function.
2018-05-03 10:38:55 +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
8c27b1260d
Fix leak in Function.prototype.toString.
2017-09-07 14:31:27 +02:00
Tor Andersson
ae54eaa652
Move js_Buffer to jsi.h and fix some potential leaks.
2017-07-05 13:31:12 +02:00
Tor Andersson
a3a4fe840b
Fix bug 697137: off by one in string length calculation.
...
We were not allocating space for the terminating zero byte.
2016-09-20 17:19:56 +02:00
Tor Andersson
e4c77a78fb
Handle null/undefined argArray in Function.prototype.apply().
2016-04-28 13:04:48 +02:00
Tor Andersson
a2fcfd69fe
Define built-in functions with the full name.
...
Improves error messages and stack traces.
2016-04-28 12:57:22 +02:00
Tor Andersson
5aed7d6e94
Fix bug in Function.prototype.bind().
...
We were not setting the prototype of the bound function properly.
2016-04-28 12:40:52 +02: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
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
051d504cfb
Add missing js_endtry call in Fp_toString.
2014-10-31 16:58:08 +01:00
Tor Andersson
858d5890b3
Handle empty arguments to Function constructor.
2014-03-13 13:11:42 +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
69cb649c2b
Use array helper functions.
2014-03-06 21:26:51 +01:00
Tor Andersson
c87898e63b
Implement Function.prototype.bind().
2014-03-06 21:21:06 +01:00
Tor Andersson
67b33c5a86
Handle malloc failure by throwing exceptions.
2014-02-28 14:24:13 +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
e4a6860f6e
More signedness fixes.
2014-02-25 00:22:17 +01:00
Tor Andersson
c7e9ab0b05
Fix signed/unsigned comparison warnings.
2014-02-24 23:55:58 +01:00
Tor Andersson
68862386d8
Implement lightweight functions.
...
When a function does not use eval, arguments, with and has no inner
functions it does not need a closure. We can call it without creating
a variable object if we store local variables on the stack instead.
2014-02-10 18:00:13 +01:00
Tor Andersson
46dec712a7
Simplify string-buffer function API.
2014-02-10 13:17:33 +01:00
Tor Andersson
d59d0e2721
Make argc/undefined checks more resilient.
2014-02-07 15:45:08 +01:00
Tor Andersson
d5b83c3bf2
Implement Function constructor.
2014-02-07 11:44:39 +01:00
Tor Andersson
fac3f501e4
Add js_hasproperty function.
2014-01-25 22:57:39 +01:00
Tor Andersson
90b54a9eec
Add userdata class.
...
js_newuserdata(J, tag, ptr) creates a userdata object, wrapping the ptr.
It takes the prototype for the new object from the top of the stack, just
like js_newcconstructor does.
js_touserdata(J, tag, idx) extracts the userdata pointer. Throws a
TypeError if the object is not a userdata object with a matching tag.
js_isuserdata(J, tag, idx) checks if a value on the stack is a userdata
object with a matching tag.
2014-01-24 17:11:49 +01:00
Tor Andersson
195816c208
Set property attributes on built-in objects and respect DontEnum.
2014-01-23 17:53:22 +01:00
Tor Andersson
3a92e13e47
Rename files and move a few functions around.
2014-01-21 13:58:32 +01:00