Tor Andersson
914ae72a24
Improve line number tracking in parser.
...
Associate statements with their initial keyword, and expressions
with their operator token.
2019-03-07 16:08:06 +01:00
Tor Andersson
245a6f97e6
Fix 700090, 700094, 700095: Iterate through lists in AST analysis passes.
2018-11-05 16:00:13 +01:00
Tor Andersson
4d45a96e57
Guard binary expressions from too much recursion.
2018-01-24 16:27:16 +01:00
Tor Andersson
849fb89be7
Add recursion overflow check when parsing unary expressions.
...
Add a recursion counter when we jump to the same grammar clause.
2018-01-15 13:08:31 +01:00
Tor Andersson
5f83cc9842
Add recursion overflow checks in parser.
...
Add a recursion counter at every point we jump 'back' to in the grammar.
2017-05-16 13:25:00 +02:00
Tor Andersson
fb32b5c893
Add a js_setreport callback function to report warnings.
...
Don't print error and warning messages directly to stderr.
2017-05-16 12:03:38 +02:00
Tor Andersson
44d4109a1c
Use the line number of the lookahead token when building the syntax tree.
...
We were tagging nodes with the previous token's line number, which is
not correct.
2017-05-09 13:52:11 +02:00
Tor Andersson
8a26e20943
Compile functions with per-function strictness.
...
Recognize 'use strict' pragma.
Move strictness checks into compiler from parser.
2017-04-17 23:27:00 +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
e9f4ecc378
strict mode: No 'with' statements allowed.
2015-01-14 13:05:12 +01:00
Tor Andersson
b4fb12662d
Rename next/accept/expect macros in lexer and parser.
...
Make the names regular, and don't conflict with libc function accept().
2015-01-02 13:43:57 +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
67b33c5a86
Handle malloc failure by throwing exceptions.
2014-02-28 14:24:13 +01:00
Tor Andersson
01d85a4994
Move nelem() macro into jsi.h
2014-02-26 17:35:18 +01:00
Tor Andersson
c67ca523aa
Remove more dead code.
2014-02-25 20:08:16 +01:00
Tor Andersson
45e3a31950
Some -pedantic warning fixes.
...
Drop the use of 'inline' in most places... place some trust in the
compiler.
2014-02-25 01:23:52 +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
934c7a37de
Check list of future reserved words for primary expression identifiers.
2014-02-06 16:07:37 +01:00
Tor Andersson
b659aa50e1
Compile ES5 getters and setters.
2014-02-06 13:56:50 +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
833d2a6fad
Fix parser bug.
2014-01-22 18:03:29 +01:00
Tor Andersson
424f7161be
Remove incorrect eval result hack.
2014-01-22 15:18:02 +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
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
5cdcc20936
Simplistic REPL.
2014-01-21 15:15: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
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
7bf5257d00
Save line number where the token starts for improved error messages.
2014-01-18 15:10:57 +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
3715d6d145
Add JS_NORETURN declaration to longjumping functions.
2014-01-16 14:15:17 +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
62fea907a6
Compile logical or/and operators with early termination.
...
Make the && and || operators right-associative since that generates
better code, and should make no difference in semantics.
2014-01-12 13:39:48 +01:00
Tor Andersson
8a1c1c24ed
Add warning function to parser. Warn but accept function expressions
...
as expression statements.
2014-01-11 18:11:23 +01:00
Tor Andersson
f36eb04aee
Track newlines properly.
2014-01-11 18:11:23 +01:00
Tor Andersson
e23d2070a0
Check future reserved words in parser to allow them as IdentifierName tokens.
2014-01-11 18:11:23 +01:00
Tor Andersson
88abe2c38c
Fix parser bugs.
2014-01-11 18:11:23 +01:00
Tor Andersson
d9588c2c98
Add UNDEF expression to handle array elisions properly.
2014-01-11 13:03:58 +01:00
Tor Andersson
a476ffcc12
Preserve regexp flags. Escape more characters when dumping strings.
2014-01-11 12:47:08 +01:00
Tor Andersson
33c60e4d7b
Fix bug.
2014-01-10 23:29:54 +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