{"id":18989385,"url":"https://github.com/source-academy/sinter","last_synced_at":"2025-04-22T11:06:29.421Z","repository":{"id":54573187,"uuid":"240173320","full_name":"source-academy/sinter","owner":"source-academy","description":"Source implementation for microcontrollers (e.g. Arduino)","archived":false,"fork":false,"pushed_at":"2025-03-31T15:13:53.000Z","size":25495,"stargazers_count":5,"open_issues_count":0,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-16T22:09:14.882Z","etag":null,"topics":["ev3dev","hacktoberfest","javascript","source","source-academy","virtual-machine"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/source-academy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-02-13T04:02:53.000Z","updated_at":"2025-03-31T15:13:56.000Z","dependencies_parsed_at":"2024-02-03T18:38:53.731Z","dependency_job_id":"2595f767-b9d8-49e9-b4cb-0b1d5aa0e7aa","html_url":"https://github.com/source-academy/sinter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/source-academy%2Fsinter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/source-academy%2Fsinter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/source-academy%2Fsinter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/source-academy%2Fsinter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/source-academy","download_url":"https://codeload.github.com/source-academy/sinter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250227239,"owners_count":21395728,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ev3dev","hacktoberfest","javascript","source","source-academy","virtual-machine"],"created_at":"2024-11-08T17:06:25.293Z","updated_at":"2025-04-22T11:06:29.381Z","avatar_url":"https://github.com/source-academy.png","language":"C","readme":"# Sinter\n\n[![Coverage Status](https://coveralls.io/repos/github/source-academy/sinter/badge.svg?branch=master)](https://coveralls.io/github/source-academy/sinter?branch=master)\n\nName etymology: \u003cstrong\u003eS\u003c/strong\u003eVML \u003cstrong\u003einter\u003c/strong\u003epreter.\n\nThis is an implementation of the Source Virtual Machine Language intended for microcontroller platforms like an Arduino. We follow the [Source VM specification](https://github.com/source-academy/js-slang/wiki/SVML-Specification) as in the js-slang wiki. Use this VM with the [reference compiler](https://github.com/source-academy/js-slang/blob/master/src/vm/svmc.ts).\n\nFor implementation details, see [here](vm/docs/impl.md).\n\n## Directory layout\n\n- `vm`: The actual VM library.\n- `vm/test`: Some scripts to aid with CI testing.\n- `runner`: A simple runner to run programs from the CLI.\n- `test_programs`: SVML test programs that have been manually verified to be correct, as well as expected output for automated tests.\n- `devices`: Some examples for using Sinter on various embedded platforms.\n\n## Usage notes\n\nSinter implements most of Source §3, except:\n\n- Numbers are single-precision floating points. This means that\n  `16777216 + 1 === 16777216`.\n- The following primitives are not supported:\n  - list_to_string\n  - parse_int\n  - runtime\n  - prompt\n  - stringify\n\nUsage recommendations:\n\n- Treat arrays like C arrays, rather than JavaScript arrays (which are actually\n  maps). Sinter does not (yet) have optimisations for sparse arrays.\n\n## Use it on a device\n\nSinter is a C library. For examples on how to use Sinter, see [the CLI\nrunner](runner/src/runner.c), [the Arduino sketch\nexample](devices/arduino/arduino.ino), or the [ESP32\nexample](devices/esp32/src/main.c). There is also a [WASM example](devices/wasm).\n\nTo create an Arduino library zip, run the script\n[`make_arduino_lib.sh`](make_arduino_lib.sh). You can configure the Arduino\nlibrary by unzipping the zip and modifying\n[`sinter_config.h`](include/sinter_config.h).\n\n## Build locally\n\nWe use the CMake build system. Note: a compiler that supports C11 is _required_.\nThis excludes MSVC.\n\n```\n# cd into the root of the repository, then:\nmkdir build \u0026\u0026 cd build\ncmake .. -DCMAKE_BUILD_TYPE=Release\nmake -j8\nmake test\nrunner/runner ../test_programs/hello_world.svm\n```\n\n### Compiling your own programs\n\nUse the [SVML compiler CLI utility in js-slang](https://github.com/source-academy/js-slang/blob/master/src/vm/svmc.ts) to compile programs for testing. (A real deployment of Sinter would integrate the compiler in js-slang directly instead.)\n\nAlternatively, you could also try the [web demo](https://angelsl.github.io/sinter/), which uses Sinter compiled to WASM.\n\nFor convenience, we have included a NPM package that exposes the CLI utility.\n\nTry it out:\n\n```\n# Make sure you have built the test runner from above.\n# Then, from the root of the repository:\ncd tools/compiler\nyarn install\necho 'display(\"Hello world\");' \u003e myprogram.js\nnode svmc.js myprogram.js\n../../build/runner/runner myprogram.svm\n# (or wherever the test runner binary is)\n```\n\n### CMake configuration\n\nSome configuration is available via CMake defines:\n\n- `CMAKE_BUILD_TYPE`: controls the build type; defaults to `Debug`\n\n  - `Debug`: assertions are enabled; some extra checks are enabled; `-Og` optimisation level\n  - `Release`: assertions are disabled; `-O2` optimisation level\n\n- `SINTER_HEAP_SIZE`: size in bytes of the statically-allocated heap; defaults\n  to `0x10000` i.e. 64 KB\n\n- `SINTER_STACK_ENTRIES`: size in stack entries of the statically-allocated\n  stack; defaults to `0x200` i.e. 512\n\n- `SINTER_DISABLE_CHECKS`: if `1`, disables certain safety checks in the runtime\n  e.g. stack over/underflow checks; defaults to unset (i.e. safety checks are\n  performed)\n\n- `SINTER_DEBUG_LOGLEVEL`: controls the debug output level; defaults to `0`\n\n  - `0`: all debug output is disabled.\n  - `1`: prints reasons for most faults/errors\n  - `2`: traces every instruction executed and every push on/pop off the stack\n\n  This is available regardless of `CMAKE_BUILD_TYPE`.\n\n  When deploying on an actual microcontroller, you will likely want to use `0`.\n  `1` and `2` requires some implementation of `fprintf` and `stderr`. (This may\n  be relaxed in future so the library consumer can provide a logging function\n  instead.)\n\n- `SINTER_DEBUG_ABORT_ON_FAULT`: if `1`, raises an assertion failure when a\n  fault occurs. (Intended for use when debugging under e.g. GDB.) Defaults to\n  unset.\n\n- `SINTER_DEBUG_MEMORY_CHECK`: if `1`, does _a lot_ of checks at every\n  instruction to verify the correctness of the heap linked list, freelist,\n  stack, and reference counting. Note: this slows down execution severely.\n  Defaults to unset.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsource-academy%2Fsinter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsource-academy%2Fsinter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsource-academy%2Fsinter/lists"}