Tor Andersson
a65416046c
Make instanceof a public function.
2014-01-23 09:13:39 +01:00
Tor Andersson
c55b4e18bc
Implement instanceof expression.
2014-01-23 00:16:21 +01:00
Tor Andersson
60253cedab
Add stack and scope balancing to exits from try/catch blocks.
...
Because finally blocks are inlined, their break and continue instructions
are duplicated so we need to use a list of jumps to patch instead of
a single instruction and target pointer.
Also save the top return value from the stack, since an interrupted
return (return out of a try block that has a finally with another
jump or return) will leave multiple return values on the stack.
2014-01-22 23:15:18 +01:00
Tor Andersson
cf9867c833
Implement try/catch/finally exception handling.
...
TODO: return/break/continue and finally.
2014-01-22 18:04:11 +01:00
Tor Andersson
f1e1171eef
Clean up stack and with/endwith balancing on abrupt exits.
2014-01-22 16:24:45 +01:00
Tor Andersson
a6a5bd7994
Add prefixes and remove duplicate functions.
...
Allows compiling all sources as one big blob.
2014-01-22 03:14:37 +01:00
Tor Andersson
7389d25b1a
Fix typos.
2014-01-21 16:36:15 +01:00
Tor Andersson
8b6493eece
Implement with statement.
2014-01-21 15:49:36 +01:00
Tor Andersson
6c8400d872
Fix CFunction calling conventions.
...
'this' is always argument 0 (even for constructors, where it is null).
argc is the number of real arguments (not counting the 'this' object).
for (i = 1; i <= argc; ++i)
js_toXXX(J, i);
2014-01-20 23:16:07 +01:00
Tor Andersson
26cde86041
Fix constructors to return the created object if the function doesn't.
2014-01-20 23:15:39 +01:00
Tor Andersson
7c82ec2541
Clean up error object creation and throwing functions.
2014-01-20 18:27:52 +01:00
Tor Andersson
b262cc3673
Rename many jsR functions to jsV.
...
Danger! jsV work on values internally without the stack.
Also rearrange how C-constructors are created.
2014-01-20 17:44:56 +01:00
Tor Andersson
759acbd4dd
Add enum-to-string functions for syntax tree and opcodes.
2014-01-20 16:18:49 +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
8aa0627557
Add Error builtin objects and exception stack.
2014-01-20 00:13:47 +01:00
Tor Andersson
f3ea55fc64
Implement String.prototype.charAt and charCodeAt.
2014-01-19 15:06:10 +01:00
Tor Andersson
32c0c6c410
Rename jsR_numbertostring to jsR_stringfromnumber.
...
Add js_tointeger, js_toint32, js_touint32.
2014-01-19 14:55:19 +01:00
Tor Andersson
95ac24c7cf
Put js_Object contents in a union.
2014-01-19 13:29:38 +01:00
Tor Andersson
07610bd0ac
Refactor ToString and ToNumber functions. Add ToPrimitive.
2014-01-18 20:16:28 +01:00
Tor Andersson
05275e2e5d
Implement relational and equality operators.
2014-01-18 18:20:33 +01:00
Tor Andersson
d3d92291f6
Reorder switch cases to match opcode order.
2014-01-18 17:44:20 +01:00
Tor Andersson
24f48308ce
Support 'typeof' operator.
2014-01-18 17:38:40 +01:00
Tor Andersson
f8ff865248
Move object creation functions into jsobject.c
2014-01-18 01:22:11 +01:00
Tor Andersson
702fb1eb4a
Rename functions that push new objects on the stack.
2014-01-18 01:15:10 +01:00
Tor Andersson
ffc82eabd7
Add allocation counter to trigger garbage collector during interpretation.
...
Only trigger between function calls, during bytecode interpretation,
to allow for intra-function race conditions where an object has been
created but not yet inserted into the stack or environment scope chain.
2014-01-18 00:57:18 +01:00
Tor Andersson
96ca91ec7c
Garbage collector lists.
2014-01-17 23:02:14 +01:00
Tor Andersson
299dbda156
Move stack into state.
2014-01-17 22:42:15 +01:00
Tor Andersson
81b2bb9ca4
Add constructors called with 'new' keyword.
...
Support built-in constructors that create their own objects. They get
called without a this object, which they should create and push on the
stack.
2014-01-17 22:03:35 +01:00
Tor Andersson
e431170dae
Improve stackidx function to return "undefined" for out-of-bounds accesses.
2014-01-17 21:10:54 +01:00
Tor Andersson
060dbbb03c
Create function objects with initial properties.
...
Set "length" and "prototype" and "prototype.constructor" properties.
Only for functions, not script functions or C-functions.
2014-01-17 21:03:22 +01:00
Tor Andersson
f487a7db10
Set prototype internal property when creating objects.
2014-01-17 19:41:41 +01:00
Tor Andersson
5ce44f9d4a
Remember file name and line where a function object came from.
...
Make "debugger" statement useful: dump current function bytecode,
stack, and environment scope chain.
2014-01-17 16:00:51 +01:00
Tor Andersson
10ffd559de
Compile global/eval code as script objects rather than regular functions.
...
Handle scoping rules ath the js_call level instead of having to use
separate functions to call on the objects.
2014-01-17 15:58:51 +01:00
Tor Andersson
f6c5c56b44
Keep the current environment scope chain in the js_State struct.
...
Create script (global/eval code) functions without a scope (they're
not closures) and run them with js_eval so they can execute with the
current scope chain.
Normal functions still have a scope and are run with js_call.
2014-01-17 14:58:03 +01:00
Tor Andersson
2a027a1b21
String concatenation.
2014-01-17 03:21:20 +01:00
Tor Andersson
b595422da9
Add object property accessor functions to public API.
2014-01-17 03:03:10 +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
7228ec51c4
Handle "this" by always keeping it in stack[0].
2014-01-16 20:48:43 +01:00
Tor Andersson
288eef80e1
Clean up. Rearrange files. Rename functions.
2014-01-16 20:48:43 +01:00
Tor Andersson
0f87d01184
Add callable CFunctions and a print() function.
2014-01-16 02:14:07 +01:00
Tor Andersson
18b192b8aa
Minor cleanups.
2014-01-16 02:14:07 +01:00
Tor Andersson
4a3fdcef74
Functions!
2014-01-16 00:23:27 +01:00
Tor Andersson
ede0f888ce
Prepare for objects with internal properties, and closures as objects.
2014-01-15 23:41:41 +01:00
Tor Andersson
6ba9e94d02
js_pushlstring() for pushing literal (and interned strings).
...
js_pushstring() will intern its argument first.
2014-01-15 17:03:12 +01:00
Tor Andersson
47e88ac805
Calculate stack index for both positive and negative numbers.
...
Call all functions with "this" as the first argument.
Negative indexes count from the top, positive indexes count from
the current function call frame (so arguments start at 0).
2014-01-15 01:34:30 +01:00
Tor Andersson
6b1906f3b5
Add for-in iterator.
2014-01-15 00:36:22 +01:00
Tor Andersson
6d690be969
Normal for statement.
2014-01-14 19:06:44 +01:00
Tor Andersson
f77a6e7e8e
Implement value stack and use it in the interpreter.
...
We can now run simple programs that don't use function calls.
2014-01-14 18:17:06 +01:00
Tor Andersson
a4cc139e1c
Add js_Object with js_Property binary search tree.
...
Use object to represent a variable record and implement variable
loading and storing in the interpreter.
2014-01-13 21:32:33 +01:00
Tor Andersson
5756da56d1
Begin generating byte code.
2014-01-12 13:39:42 +01:00