Commit Graph

19 Commits

Author SHA1 Message Date
Tor Andersson
2eb4fd2272 Bug 703459: Handle undefined argument to Error constructor. 2021-02-03 17:31:50 +01:00
Tor Andersson
6f93cab7ff Fix enumerability of Error and Function properties.
The Error.message, Error.stackTrace, Function.prototype properties were
defined with the wrong attributes.

x
2020-01-23 12:06:06 +01: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
c1bd06728a Don't truncate error messages. 2017-04-20 00:21:27 +02:00
Tor Andersson
c596dd58c3 Fix stack trace off-by-one error when skipping the top level entry. 2016-06-01 15:23:43 +02:00
Tor Andersson
1b5cc3a082 Improve debugging stack trace print-out. 2016-04-28 13:33:58 +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
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
0cbd5326f2 Garbage collect (some) strings.
Separate literal/interned and garbage collected string types in js_Value.

js_pushintern/js_tointern are convenience functions to push/pop strings and
automatically intern them (so that the string pointers are guaranteed to be
stable).

js_pushliteral should push stable strings (either interned or actual literals).

js_pushstring will copy the string into garbage collected memory.

The pointer returned by js_tostring is guaranteed to be stable only for as long as
the stack slot it came from remains untouched.

Some uses will always cause a string to be interned:

 * Using it as a property name.
 * Wrapping it in a new String() object.
 * Strings returned by toString().
	ToPrimitive must not clobber the stack, so the result has to be unrooted.
 * Numbers converted to strings (by js_tostring)
	Likewise, we have nowhere to store the temporary string here.
	Passing in a scratch buffer to js_tostring could help this problem.
	Mostly an issue with array accesses (OP_GETPROP, etc) so an auxiliary
	function and we don't have to clutter the API needlessly.
2014-11-28 17:10:08 +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
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
d59d0e2721 Make argc/undefined checks more resilient. 2014-02-07 15:45:08 +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
b22dc395c9 Use ES5 specification for implementation of Error.prototype.toString(). 2014-01-24 02:13:20 +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
Tor Andersson
7c82ec2541 Clean up error object creation and throwing functions. 2014-01-20 18:27:52 +01:00