summaryrefslogtreecommitdiffhomepage
path: root/lib
AgeCommit message (Collapse)Author
2021-04-27treewide: ISO C / pedantic complianceJo-Philipp Wich
- Shuffle typedefs to avoid need for non-compliant forward declarations - Fix non-compliant empty struct initializers - Remove use of braced expressions - Remove use of anonymous unions - Avoid `void *` pointer arithmetic - Fix several warnings reported by gcc -pedantic mode and clang 11 compilation Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-04-25treewide: rework internal data type systemJo-Philipp Wich
Instead of relying on json_object values internally, use custom types to represent the different ucode value types which brings a number of advantages compared to the previous approach: - Due to the use of tagged pointers, small integer, string and bool values can be stored directly in the pointer addresses, vastly reducing required heap memory - Ability to create circular data structures such as `let o; o = { test: o };` - Ability to register custom `tostring()` function through prototypes - Initial mark/sweep GC implementation to tear down circular object graphs on VM deinit The change also paves the way for possible future extensions such as constant variables and meta methods for custom ressource types. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-04-24treewide: fix issues reported by clang code analyzerJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-03-08fs: make error function available on directory, process and file handlesJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-03-08ubus: make error function available on the connection instanceJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-03-08uci: fix potential invalid memory access in error()Jo-Philipp Wich
Check the numerical error code index before attempting to look it up in the error string array. Also make error function available on the cursor instance as well. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-03-08fs: fix readlink() return valueJo-Philipp Wich
The fs.readlink() function incorrectly produced a JSON string containing trailing null bytes. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-02-17treewide: rewrite ucode interpreterJo-Philipp Wich
Replace the former AST walking interpreter implementation with a single pass bytecode compiler and a corresponding virtual machine. The rewrite lays the groundwork for a couple of improvements with will be subsequently implemented: - Ability to precompile ucode sources into binary byte code - Strippable debug information - Reduced runtime memory usage Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-12-07uci: fix -Werror=maybe-uninitialized warningJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-12-07ubus: fix uninitialized pointer return in uc_ubus_call() and uc_ubus_list()Jo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-11-19treewide: rebrand to ucodeJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-11-15fs: extend process close() function to return program exit codeJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-11-10fs: do not close stdio streams when gc'ing scopeJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
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-06fs: add stdio handlesJo-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-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-11fs: implement getcwd() and chdir()Jo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-11lib: move math functions to new moduleJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-11lib: implement uci pluginJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-10treewide: eliminate unused function argumentsJo-Philipp Wich
Also introduce convenience macro for registering function arrays in modules. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-10lib: add ubus moduleJo-Philipp Wich
Also move shared library output files to the lib/ directory Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-09fs: implement popen()Jo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-08fs: rename readdir() and closedir() to read() and close() respectivelyJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-08fs: fix file seek() return valueJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-08fs: fix crash when closing file handle twiceJo-Philipp Wich
We need to clear the file handle pointer after closing the file to avoid invoking the dtor later. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-08fs: implement seek() and tell() for directory handlesJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-06fs: use ARRAY_SIZE macroJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-06fs: add further filesystem functionsJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-06treewide: refactor internal AST structuresJo-Philipp Wich
- unify operand and value tag structures - use a contiguous array for storing opcodes - use relative offsets for next and children ops - defer function creation to runtime - rework "this" context handling by storing context pointer in scope tags Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-02lib: introduce filesystem moduleJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>