{"id":19072203,"url":"https://github.com/tharvik/wasm","last_synced_at":"2026-03-04T23:02:48.669Z","repository":{"id":146973222,"uuid":"119172125","full_name":"tharvik/wasm","owner":"tharvik","description":"WebAssembly for Scala","archived":false,"fork":false,"pushed_at":"2018-10-22T07:14:33.000Z","size":187,"stargazers_count":6,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-28T16:13:09.544Z","etag":null,"topics":["scala","wasm","wasm-codegen","webassembly"],"latest_commit_sha":null,"homepage":null,"language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tharvik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING.LESSER","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":"2018-01-27T14:38:08.000Z","updated_at":"2021-09-09T11:15:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"9559f44b-433a-4cd7-b4b8-5684d4a2a960","html_url":"https://github.com/tharvik/wasm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tharvik/wasm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tharvik%2Fwasm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tharvik%2Fwasm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tharvik%2Fwasm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tharvik%2Fwasm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tharvik","download_url":"https://codeload.github.com/tharvik/wasm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tharvik%2Fwasm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30098100,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T22:49:54.894Z","status":"ssl_error","status_checked_at":"2026-03-04T22:49:48.883Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["scala","wasm","wasm-codegen","webassembly"],"created_at":"2024-11-09T01:35:40.041Z","updated_at":"2026-03-04T23:02:48.647Z","avatar_url":"https://github.com/tharvik.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `wasm`\nWebAssembly for Scala\n\nProvide some AST and a way to convert them to wasm binary. There is also a printer for binary wasm.\n\nThere is two way to use `wasm`, either as a cli or a library.\n\n# install\nIt's using `sbt` for building, simply ensure that you have it.\n\nTo ensure that it's working, you may want to run `sbt test` prior to using `wasm`.\n\n## cli\nIt can be used directly from the `sbt` prompt, there is no system-wide binary installation.\n\n## library\nTo add to the local ivy storage\n```sh\nsbt publishLocal\n```\nand add `libraryDependencies += \"default\" %% \"scalawasm\" % \"0.1\"` to your `build.sbt`\n\n# use\n\n## cli\nTo compile wat file to wasm file\n```sh\nsbt run compile watfile1 watfile2 ...\n```\n\nTo print the content of a wasm file\n```sh\nsbt run print wasmfile1 wasmfile2 ...\n```\n\n## library\nThe main target is to be able to have a library to generate wasm, usable in scala, from a compiler perspective.\n\nThe compilation pipeline and data type used at each stage is\n```\npipeline         text.Lexer -\u003e text.Parser -\u003e binary.ToBinaryAst -\u003e binary.ToBinary\ndatatype    String  -\u003e  ast.Token   -\u003e   ast.Tree     -\u003e     ast.Binary   -\u003e   Stream[Byte]\n```\n\nThe most suitable coding entrypoint is `wasm.ast.Tree`, it provide a convenient, yet nearly binary, tree.\n\nA good code starter is\n```scala\nfor {\n  ast \u003c- Module(\n    name = Some(\"My Module\"),\n    funcs = Seq(\n      Function(\n        sig = Signature.Function(),\n        instrs = Seq(\n          Opcode.Nop,\n      ))))\n  p \u003c- ToBinaryAst(ast)\n} yield ToBinary(p)\n\n```\n\n# todo\n\n## short\n * `ToBinaryAst.Section.Export` works only for function, it's trivial to port it to\n   supports others\n * `ToBinaryAst.getSections` could use some refactoring, to nicely separate\n   which spaces can be used in which section\n * find a good macro system for Scala, to reduce some value duplication in\n   `LEB128.Type`\n\n## medium\n * there is structural support for some wasm extension, such has multi return or\n   multi memory, but it still have to be defined in spec and fully\n   implemented/tested\n * Data section is implemented until `Tree` but not in the remaining pipeline\n * Custom section is not implemented, there is partial structural support for it\n * remove many warning by using dedicated case object instead of having a\n   generic way to do it\n\n## long\n * parser is too simple, it support only \"regular\" wat, but the spec\n   documentation is not very precise either, that would need some improvement\n   based on the new version of the spec\n   having a better parser would lead to very easy testing, as drop-in of files\n   would works, we could reuse directly the core testing suite of the spec repo\n   (there is still some issues, such as them using some undefined opcode)\n   * correctly handle multi lines comments\n   * parse the full syntax\n   * int/float values are badly handle, it will break on some corner cases,\n     also, the parsing is based on naïve understanding (previously undefined);\n     see the \"toInt\" TODOs\n   * there is some structural check we can push to parser, such as i32 can't\n     load a value bigger that the actual available range\n   * order of `module` opcode is either not well defined or wrong\n * `Printer` can be much cooler than that and try to regenerate the wat input\n   and having a way to print wasm and also a decompiler\n * support other compilers than the reference one\n * remove quirks used for spec compatibility, but that would require that\n   WebAssembly/spec#625 be fixed first; check for `Config.enableSpecCompat`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftharvik%2Fwasm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftharvik%2Fwasm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftharvik%2Fwasm/lists"}