{"id":13632900,"url":"https://github.com/nervosnetwork/muta-minits","last_synced_at":"2025-04-18T05:33:30.216Z","repository":{"id":40785251,"uuid":"200999038","full_name":"nervosnetwork/muta-minits","owner":"nervosnetwork","description":"TypeScript to LLVM compiler","archived":true,"fork":false,"pushed_at":"2022-06-23T22:34:40.000Z","size":1082,"stargazers_count":133,"open_issues_count":24,"forks_count":11,"subscribers_count":20,"default_branch":"master","last_synced_at":"2024-11-09T01:35:44.691Z","etag":null,"topics":["muta"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nervosnetwork.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}},"created_at":"2019-08-07T07:41:31.000Z","updated_at":"2024-06-03T19:16:50.000Z","dependencies_parsed_at":"2022-09-09T12:41:47.453Z","dependency_job_id":null,"html_url":"https://github.com/nervosnetwork/muta-minits","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/nervosnetwork%2Fmuta-minits","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nervosnetwork%2Fmuta-minits/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nervosnetwork%2Fmuta-minits/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nervosnetwork%2Fmuta-minits/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nervosnetwork","download_url":"https://codeload.github.com/nervosnetwork/muta-minits/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249437022,"owners_count":21271991,"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":["muta"],"created_at":"2024-08-01T22:03:24.441Z","updated_at":"2025-04-18T05:33:29.808Z","avatar_url":"https://github.com/nervosnetwork.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","Experimental/Research Projects"],"sub_categories":[],"readme":"# Minits\n\n[![Build Status](https://travis-ci.org/cryptape/minits.svg?branch=master)](https://travis-ci.org/cryptape/minits)\n\nTypescript with LLVM backend.\n\n![img](/res/flow.png)\n\n# Installing minits on Linux or macOS\n\nFirst of all, you need install LLVM, See [https://llvm.org/docs/GettingStarted.html](https://llvm.org/docs/GettingStarted.html). But if you are using Ubuntu or other distributions, using the built-in package management tool is a more convenient option like:\n\n```\n$ apt install -y llvm\n```\n\nThen install minits:\n\n```\n$ git clone https://github.com/cryptape/minits\n$ npm install\n$ npm run build\n```\n\n# Writing and Compiling a TypeScript Program\n\nFilename: main.ts\n\n```ts\nfunction main(): number {\n    console.log(\"Hello World!\");\n    return 0;\n}\n```\n\nSave the file and open your terminal:\n\n```\n$ node build/main/index.js build main.ts -o main.ll\n$ clang main.ll -o main\n$ ./main\n```\n\n# Analysis for a minits Program: Brainfuck\n\nminits is a completely static language, similar to clang or rust, `function main()` is the entry point to every executable minits program. It receives(optional) 2 parameters `argc: number` and `argv: string[]`, and returns the exit code. So you can also write it as `function main(argc: number, argv: string[]): number`.\n\nWe suggest you read the source code under `./examples`. Let's hava a look at `./examples/brainfuck.ts`. Brainfuck is an esoteric programming language created in 1993 by Urban Müller, and is notable for its extreme minimalism. We wrote a brainfuck interpreter by minits. Compile this interpreter by\n\n```\n$ node build/main/index.js build examples/brainfuck.ts -o brainfuck.ll\n$ clang brainfuck.ll -o brainfuck\n```\n\nAnd then execute a piece of code that generates Sierpinski Triangle:\n\n```\n$ ./brainfuck \"\u003e++++[\u003c++++++++\u003e-]\u003e++++++++[\u003e++++\u003c-]\u003e\u003e++\u003e\u003e\u003e+\u003e\u003e\u003e+\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c[-[-\u003e+\u003c]\u003e[-\u003c+\u003e\u003e\u003e.\u003c\u003c]\u003e\u003e\u003e[[-\u003e++++++++[\u003e++++\u003c-]\u003e.\u003c\u003c[-\u003e+\u003c]+\u003e[-\u003e++++++++++\u003c\u003c+\u003e]\u003e.[-]\u003e]]+\u003c\u003c\u003c[-[-\u003e+\u003c]+\u003e[-\u003c+\u003e\u003e\u003e-[-\u003e+\u003c]++\u003e[-\u003c-\u003e]\u003c\u003c\u003c]\u003c\u003c\u003c\u003c]++++++++++.+++.[-]\u003c]+++++\"\n```\n\n![img](/res/brainfuck.png)\n\nMost ts syntax is available at now, but there is still a lot of work to be done.\n\n# Project status\n\nWe plan to implement the following syntax:\n\n## Types\n\n- [ ] Primitive Types\n    - [x] number(support signed 64): `0x10`, `12`\n    - [x] boolean: `true`, `false`\n    - [x] string: `\"Hello\"`\n    - [x] void\n    - [ ] null\n    - [ ] \u003cdel\u003e* undefined\u003c/del\u003e\n    - [x] enum: `enum { a = 1, b, c }`\n- [ ] Object\n    - [x] Array\n    - [ ] Tuple\n\n## Expression\n\n- [x] Assignment: `let a: number = 1;`, `let a: number[] = [1, 2, 3]`\n- [x] Parentheses\n- [x] Function Expressions\n- [ ] Arrow Functions\n- [ ] * Class Expressions\n- [x] Function Calls\n- [x] `++` / `--`\n- [x] `+` / `-` / `~`\n- [x] `!`\n- [ ] * `typeof`\n- [x] +: number + number, string + string, eg.\n- [x] `*`, `/`, `%,` `–`, `\u003c\u003c`, `\u003e\u003e`, `\u003e\u003e\u003e`, `\u0026`, `^`, and `|` operators\n- [x] `\u003c`, `\u003e`, `\u003c=`, `\u003e=`, `==`, `!=`, `===`, and `!==` operators\n- [ ] * `in`\n- [x] `\u0026\u0026` and `||`\n- [x] The Conditional Operator: `test ? expr1 : expr2`\n- [x] `*=`, `/=`, `%=`, `+=`, `-=`, `\u003c\u003c=`, `\u003e\u003e=`, `\u003e\u003e\u003e=`, `\u0026=`, `^=`, `|=`\n- [ ] \u003cdel\u003e Destructuring Assignment: `[x, y] = [y, x];` \u003c/del\u003e\n\n## Statements\n\n- [x] Block\n- [x] Variable Statements\n- [x] Let and Const Declarations\n- [x] If, Do, and While Statements\n- [x] For Statements\n- [ ] \u003cdel\u003eFor-In Statements\u003c/del\u003e\n- [x] For-Of Statements\n- [x] Continue Statements\n- [x] Break Statements\n- [x] Return Statements\n- [ ] \u003cdel\u003e With Statements \u003c/del\u003e\n- [x] Switch Statements\n- [ ] Throw Statements\n- [ ] * Try Statements\n\n## Function\n\n- [x] Function Declarations\n- [x] Function Implementations\n\n\n## Interfaces\n\nTODO\n\n## Class\n\n- [ ] Class Declarations\n- [ ] New class\n\n## Build in functions\n\n- [ ] See: https://www.tutorialspoint.com/javascript/javascript_builtin_functions.htm\n\n# Licences\n\n[MIT](/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnervosnetwork%2Fmuta-minits","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnervosnetwork%2Fmuta-minits","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnervosnetwork%2Fmuta-minits/lists"}