summaryrefslogtreecommitdiffhomepage
AgeCommit message (Collapse)Author
2020-10-02eval: avoid null pointer access in ut_invoke()Jo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-10-02eval: properly forward execeptions in for-in loop value evaluationJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-10-02ast: store function declarations as opcode offsetsJo-Philipp Wich
We cannot use direct pointers since the opcode array might be reallocated resulting in potentially changed memory addresses. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-10-02lib: fix missing refcount increase in ut_push()Jo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-10-02eval: free previous exception when storing a new oneJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-10-02uci: fix some memory leaks in ut_uci_foreach()Jo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-10-02lib: fix incorrect exception type check in ut_include()Jo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-10-02lib: wrap runtime exceptions in included utpl codeJo-Philipp Wich
This is needed to preserve error context information. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-10-02build: install extension libraries as wellJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-10-02lib: tweak error context formattingJo-Philipp Wich
Do not emit additional newline when formatting error context and print it instead when outputting the exception. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-10-02eval: fix potential uninitialized memory access in ut_getref()Jo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-10-02Revert "eval: release root scope after finishing the execution"Jo-Philipp Wich
This reverts commit 206630d7141f32594e9110081f6710446f5aebd3. Revert this commit to fix a double-free. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-10-02treewide: rework handling of memory allocation failuresJo-Philipp Wich
Instead of propagating failures to the caller, print a generic error message and terminate program execution through abort(). Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-10-02eval: release root scope after finishing the executionJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-10-02lib: add include() functionJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-10-02main: track current template filename during executionJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-10-02lib: fix procedure entry in ut_require_utpl()Jo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-26lib: add json() functionJo-Philipp Wich
The json function allows parsing JSON strings into structured data. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-26lib: implement '%J' printf formatJo-Philipp Wich
The `%J` format allows outputting values as valid JSON string. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-24syntax: add regular expression supportJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-24main: support invoking utpl interpreter through shebangJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-23eval: ensure that argument array is initialized when invoking C functionsJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-23eval: propagate exceptions when resolving referencesJo-Philipp Wich
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-22syntax: introduce case statement supportJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-22tests: support multiple testcases per test fileJo-Philipp Wich
Also support specifying expected exit codes. 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-21eval: fix potential null pointer access when computing operandsJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-21syntax: introduce try/catch blocksJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-21eval: don't escape slashes when outputting array or object JSONJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-21treewide: ensure to properly propagate exceptionsJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-20treewide: rework extended type handlingJo-Philipp Wich
Register prototype object directly together with the type instead of setting it manually whenever an extended type value is instantiated. This also allows freeing the various prototype objects in dlopened modules. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-20eval: fix leaking calculated object keysJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-20eval: fix double free of env valuesJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-20ast: fix context value leakJo-Philipp Wich
Free any remaining context value when freeing the runtime state. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-20main: fix memory leak with -e optionJo-Philipp Wich
Release the parsed intermediate object after copying its values into the global env object. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-20eval: implement -m option to preload modulesJo-Philipp Wich
The -m option instructs the interpreter to automatically require the named module and to register the module context as global variable. The following two commands are equivalent, with the former one serving as a shortcut for the latter: utpl -m fs -s '{{ fs.open("test.txt").read("all") }}' utpl -s '{% fs = require("fs"); print(fs.open("test.txt").read("all")) %}' Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-20eval: improve reference error reportingJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-20Revert "treewide: rework exception handling"Jo-Philipp Wich
This reverts commit 54bb15b2be3656e91386b80074f45591b20fed3f. Relying on setjmp() / longjmp() causes too many headaches trying to track and properly release intermediate values. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-17eval: sanitize variable namesJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-16eval: implement -e and -E options to set global vars from JSONJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-16treewide: implement strict assignment modeJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-16treewide: rework exception handlingJo-Philipp Wich
Use setjmp() and longjmp() to deal with runtime exceptions. 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-15eval: only set "this" scope for functions being object membersJo-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>
2020-09-14eval: increase refcount when reading function contextJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-13tests: extend for-loop tests to cover local variantsJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-13syntax: fix for() loop quirks and variable scopingJo-Philipp Wich
- Support `for (var x in ...)` syntax - Support `for (var i = 0; i < ...; i++)` syntax - Properly handle "for" loops without condition and increment expression - Reject for-in loops with invalid lhs Signed-off-by: Jo-Philipp Wich <jo@mein.io>