Commit Graph

28 Commits

Author SHA1 Message Date
Tor Andersson
d04cbf3cc7 Add pretty-printing command line tool. 2018-04-23 18:24:31 +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
588fdd18d6 Small cleanups. 2014-02-18 14:38:50 +01:00
Tor Andersson
e39e0bdcd1 Separate generic AST_IDENTIFIER and EXP_IDENTIFIER.
Use EXP_IDENTIFIER for the primary expression, and AST_IDENTIFIER for
non-expression uses.
2014-02-10 15:44:40 +01:00
Tor Andersson
d5b83c3bf2 Implement Function constructor. 2014-02-07 11:44:39 +01:00
Tor Andersson
96667d99b1 Use precedence table when pretty-printing syntax. 2014-02-04 15:05:03 +01:00
Tor Andersson
546ee1e6c2 Fix switch test-chain stack leftovers. Fix iterator on null and undefined. 2014-01-24 01:48:24 +01:00
Tor Andersson
4c326a51a4 Compile switch statements. 2014-01-22 23:31:55 +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
fdd94dc5dd Break and continue to labelled statements. 2014-01-22 15:18:02 +01:00
Tor Andersson
14043f0e11 Implement unlabeled break and continue.
TODO: Does not traverse block edges to add balancing endwith instructions.
2014-01-22 03:52:28 +01:00
Tor Andersson
3a92e13e47 Rename files and move a few functions around. 2014-01-21 13:58:32 +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
9650392e04 Return value of last evaluated expression in eval and script code.
Patch in a return statement at the end of such code.
2014-01-18 17:19:31 +01:00
Tor Andersson
442b8d27a1 Rename AST free-list. 2014-01-18 15:10:57 +01:00
Tor Andersson
288eef80e1 Clean up. Rearrange files. Rename functions. 2014-01-16 20:48:43 +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
4b981faad7 Clean up handling of function declarations / statements / expressions. 2014-01-13 14:56:17 +01:00
Tor Andersson
52f78c5687 Compile sub-functions. 2014-01-12 15:31:43 +01:00
Tor Andersson
5756da56d1 Begin generating byte code. 2014-01-12 13:39:42 +01:00
Tor Andersson
d9588c2c98 Add UNDEF expression to handle array elisions properly. 2014-01-11 13:03:58 +01:00
Tor Andersson
9db2fce3a2 Add proper pretty-printing functions.
jsP_dumpsyntax to print as javascript.
jsP_dumplist to print as s-expressions.
2014-01-10 19:50:01 +01:00
Tor Andersson
7e40d3fefd Ensure that we can seek in the file in js_loadfile. 2014-01-10 16:55:36 +01:00
Tor Andersson
effc3ae9ad Add constant folding. 2014-01-10 14:38:01 +01:00
Tor Andersson
3f564db259 Clean split between loader, parser and pretty-printer. 2014-01-10 14:37:57 +01:00
Tor Andersson
8342452b13 Rename files and put stuff in the correct headers. 2014-01-10 14:37:57 +01:00