summaryrefslogtreecommitdiffhomepage
path: root/tests/02_runtime
AgeCommit message (Collapse)Author
2020-10-19eval: record correct source contexts in call stackJo-Philipp Wich
Also handle calls to C functions. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-10-18ast, eval: add recursion limitJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-10-18eval: fix segmentation faults with self-invoking functionsJo-Philipp Wich
Store the invocation scope and function context in the call stack frame and not in the function object to properly deal with recursive invocations. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-10-15syntax: allow consecutive case valuesJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-10-14treewide: unify error handlingJo-Philipp Wich
Get rid of the distinction between lexer/parser errors and runtime exceptions, use exceptions everywhere instead. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-10-14treewide: rework source file and callstack handlingJo-Philipp Wich
- Keep an open FILE* reference to processed source files in order to be able to rewind and extract error context later - Build a proper call stack when invoking utpl functions - Report call stack in exceptions Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-10-14lexer: rewriteJo-Philipp Wich
Rewrite the lexer into a restartable state machine to support parsing from file streams without the need to read the entire source text into memory first. As a side effect, the length of labels and strings is unlimited now. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-10-06eval: properly break out of switch/case on return/continue/exceptionJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-10-06eval: restore context pointer of first evaluated dot/bracket expressionJo-Philipp Wich
When an expression such as `foo.bar(a.b, c.d)` is evaluated, the state context pointer will point to `c` while we need `foo` when invoking functions. Since the context pointer is only relevant for function calls and since for function call opcodes, the lhs expression is always the first operand, there is no need to store the context of subsequent ops. Adjust the ut_get_operands() procedure to restore state->ctx to the result of the first evaluated operand. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-10-04treewide: rework function scopingJo-Philipp Wich
- Implement proper closure scoping for function - Avoid circular references when managing scopes pointers - Eliminate ut_putval() in favor to json_object_put() - Fix function return value handling - Change internal function structure Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-22syntax: allow empty switch statementsJo-Philipp Wich
Also add testcases for switch/case blocks. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-21tests: add try/catch testcaseJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-21tests: fix `this` context testcaseJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-15tests: add test for "this" contextJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-14tests: add initial runtime testsJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>