{"id":20576519,"url":"https://github.com/divs1210/toyvm","last_synced_at":"2026-06-06T00:31:29.292Z","repository":{"id":68119440,"uuid":"318788523","full_name":"divs1210/ToyVM","owner":"divs1210","description":"ToyVM: Bytecode VM for a simple lisp","archived":false,"fork":false,"pushed_at":"2020-12-27T19:21:39.000Z","size":31,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-06T11:19:14.011Z","etag":null,"topics":["bytecode-compiler","bytecode-interpreter","clojure","lisp","virtual-machine"],"latest_commit_sha":null,"homepage":"","language":"Clojure","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/divs1210.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2020-12-05T12:55:47.000Z","updated_at":"2020-12-27T19:21:42.000Z","dependencies_parsed_at":"2023-06-15T07:00:19.113Z","dependency_job_id":null,"html_url":"https://github.com/divs1210/ToyVM","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/divs1210/ToyVM","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/divs1210%2FToyVM","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/divs1210%2FToyVM/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/divs1210%2FToyVM/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/divs1210%2FToyVM/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/divs1210","download_url":"https://codeload.github.com/divs1210/ToyVM/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/divs1210%2FToyVM/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33965591,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-05T02:00:06.157Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["bytecode-compiler","bytecode-interpreter","clojure","lisp","virtual-machine"],"created_at":"2024-11-16T05:46:03.292Z","updated_at":"2026-06-06T00:31:29.273Z","avatar_url":"https://github.com/divs1210.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ToyVM\n\n**Bytecode VM for a simple lisp**\n\n* At the REPL, all forms are converted to bytecode, which is interpreted\n* Possible to AOT compile a lisp file to bytecode\n* Possible to directly interpret a bytecode file\n\nHeavily inspired by [this blogpost](https://bernsteinbear.com/blog/bytecode-interpreters/)\nby **Max Bernstein** with the following changes:\n* `lambda` is called `fn`\n* `recfn` is for creating recursive lambdas\n* `define` not required\n* written in Clojure in a functional manner\n* stackless evaluation using [xodarap](https://github.com/divs1210/xodarap)\n\n## Usage\n\n### Start a REPL\n\n    $ rlwrap lein do clean, run\n    ==================\n    === ToyVM REPL ===\n    ==================\n\n    \u003e (def dec\n        (fn (x)\n          (- x 1)))\n    nil\n\n    \u003e (dec 43)\n    42\n\n### Compile to bytecode\n\nCompile the example file:\n\n    $ cat factorial.edn\n    [\n\n     (def dec\n       (fn (n)\n         (- n 1)))\n\n     (def fact\n       (recfn fact (n)\n         (if (\u003c n 2)\n           1\n           (* n (fact (dec n))))))\n\n     (print (fact 5))\n\n    ]\n\n    $ lein bcompile factorial.edn\n\n    $ cat out.edn\n    [[:push-const (n)]\n     [:push-const\n      [[:push-name -]\n       [:push-name n]\n       [:push-const 1]\n       [:call-function 2]]]\n     [:make-function 1]\n     [:store-name dec]\n     [:push-const fact]\n     [:push-const (n)]\n     [:push-const\n      [[:push-name \u003c]\n       [:push-name n]\n       [:push-const 2]\n       [:call-function 2]\n       [:relative-jump-if-true 9]\n       [:push-name *]\n       [:push-name n]\n       [:push-name fact]\n       [:push-name dec]\n       [:push-name n]\n       [:call-function 1]\n       [:call-function 1]\n       [:call-function 2]\n       [:relative-jump 1]\n       [:push-const 1])]\n     [:make-recursive-function 1]\n     [:store-name fact]\n     [:push-name print]\n     [:push-name fact]\n     [:push-const 5]\n     [:call-function 1]\n     [:call-function 1]]\n\n### Run bytecode file\n\nInterpret the compiled output:\n\n    $ lein binterpret out.edn\n    120\n\n### Compile and run in one go\n\n    $ lein do clean, bcompile factorial.edn, binterpret out.edn\n    120\n\n## License\n\nCopyright © 2020 Divyansh Prakash\n\nThis program and the accompanying materials are made available under the\nterms of the Eclipse Public License 2.0 which is available at\nhttp://www.eclipse.org/legal/epl-2.0.\n\nThis Source Code may also be made available under the following Secondary\nLicenses when the conditions for such availability set forth in the Eclipse\nPublic License, v. 2.0 are satisfied: GNU General Public License as published by\nthe Free Software Foundation, either version 2 of the License, or (at your\noption) any later version, with the GNU Classpath Exception which is available\nat https://www.gnu.org/software/classpath/license.html.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdivs1210%2Ftoyvm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdivs1210%2Ftoyvm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdivs1210%2Ftoyvm/lists"}