Package info

A code generator and interpreter for ABC bytecode, and a JavaScript foreign function interface.

# ABC interpreter This repository contains the following: - The toolset used by [`clm`]( to generate bytecode from Clean's intermediate language ABC. - A C interpreter to run this bytecode independent from a native Clean runtime. - A WebAssembly interpreter to run this bytecode in the browser (or other Wasm runtimes). - A Clean library to lazily de/serialize arbitrary Clean expressions (including functions), collecting the accompanying bytecode, and evaluate and interpret the expression on a different machine (or in WebAssembly). Most notably this is used in [iTasks]( to run functional editor logic in the browser. This system was presented at Implementation and application of Functional Languages (IFL) 2019 by Camil Staps, John van Groningen, and Rinus Plasmeijer. [doi:10.1145/3412932.3412941](; [PDF]( ## Usage To generate bytecode for the interpreter, add the following to your `nitrile.yml`: ```yml dependencies: abc-interpreter: ... # the current version clm_options: bytecode: true ``` If you want to generate bytecode for the WebAssembly interpreter, use `bytecode: prelinked` instead. By default, ABC code will be optimized for use in the interpreter. If you do not want this, use a record: ```yml clm_options: bytecode: optimize_abc: false prelink: true ``` When `bytecode` is given (and not `null`), `clm` will generate a file `target.bc` alongside `target.exe` / `target`. Prelinked bytecode is generated as `target.pbc`. When using the Clean library for de/serialization of Clean expressions, you should also set the following options: ```yml clm_options: generate_descriptors: true export_local_labels: true strip: false ``` See the documentation in [ABC.Interpreter](/lib/ABC/Interpreter.dcl) for more details about the serialization library itself. ### Independent interpretation and debugging The interpreter can also be used stand-alone to run Clean programs. `bin/abci-interpret` is included in the nitrile package and can be used to interpret any bytecode file: ```bash abci-interpret path/to/application.bc ``` On Linux systems there is also a graphical debugger, inspired by `gdb`: ```bash abci-debug path/to/application.bc ``` For help on the interface, press <kbd>?</kbd> in the debugger GUI. ## Maintainer, authors, copyright & license This project is maintained by [Camil Staps][]. Copyright is held by the authors of the individual commits. Use `git blame` or the GitLab blame view to determine the copyright holder on specific parts of the code base. Contributors include: - Gijs Alberts - Elroy Jumpertz - Bas Lijnse - Mart Lubbers - Steffen Michels - Camil Staps - Erin van der Veen [Camil Staps]:
# Changelog #### v1.3.1 - Fix: fix native interworking with `{#Bool}`. - Fix: fix WebAssembly interworking with `{#Bool}`. ### v1.3.0 - Enhancement: update array representation to the one used in base-rts 2.0. #### v1.2.3 - Fix: fix JavaScript FFI for the smallest value in the `Int` range. #### v1.2.2 - Fix: fix WebAssembly string deserialization for `[]`. #### v1.2.1 - Enhancement: improve error when file I/O is not allowed in C interpreter. - Fix: fix printing of constant `[]` as `[]` rather than `_Nil`. - Fix: fix constant `[]` node in C interpreter when used in ABC instructions (e.g. `create_array_`). ### v1.2.0 - Feature: add `forEach` function to `ABC.Interpreter.JavaScript` module. ### v1.1.0 - Feature: add `perform_gc_on_idle` option to JavaScript interface to automatically perform garbage collection when the thread becomes idle. - Chore: make `base-compiler-itasks` dependency optional. ## v1.0.0 First tagged release. Some recent changes: - 2022-06-21 Add option to `addJSFromUrl` to not reload URLs if they have already been loaded before - 2022-02-20 Add support for `select_nc` and `update_nc` ABC instructions - 2022-01-27 Fix linker error on Windows - 2021-11-06 Fix segmentation fault in x86 interworking when garbage collection is needed in the host - 2021-11-06 Fix gcc-10 warnings in `writeFR` - 2021-08-03 Fix interworking with the WebAssembly interpreter on 32-bit systems, [!176]( - 2021-07-30 Fix native interworking, which was broken due to upstream changes, [!177]( - 2021-07-10 Fixed crashes of `debug` and `interpret` with incorrect command line arguments, [!174]( - 2021-06-30 Fixed WebAssembly `ItoAC` implementation for big integers, [!171]( - 2021-06-30 Fixed copying of JavaScript `BigInt` to Clean, [!171]( - 2021-06-25 Added implementation of `repl_r_a_args_n_a` ABC instruction, [Steffen Michels](, [!168]( - 2021-06-18 Added `toJSONArgs` instance for `JSONNode`, [!166]( - 2021-06-18 Fixed `jsWrapFunWithResult` (since f4f4dea9, no result would be returned), [!164](