-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit with support for wasi
- Loading branch information
0 parents
commit f72fc66
Showing
10 changed files
with
685 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/target | ||
*.wasm | ||
*.wasmu | ||
*.out |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[package] | ||
authors = ["Kartik Sharma <[email protected]>"] | ||
categories = ["compiler", "command-line-utilities"] | ||
description = "A brainfuck compiler which compiles to raw wasm" | ||
name = "brainfk-rs" | ||
license = "MIT" | ||
version = "0.1.0" | ||
repository = "https://github.com/crazystylus/brainfk-rs.git" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
clap = { version = "3.2.2", features = ["derive"] } | ||
wasm-encoder = "0.13" | ||
wasmparser = "0.86.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Copyright 2021 crazystylus | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Brainfk -> WASM | ||
## Introduction | ||
This repo contains a brainfk compiler written in Rust which compiles code directly to wasm. Later the generated wasm file can be ran using wasmer. | ||
### Install Wasmer Runtime | ||
Follow this link to install wasmer-runtime | ||
https://docs.wasmer.io/ecosystem/wasmer/getting-started | ||
|
||
### Example | ||
```shell | ||
$ cargo run | ||
Finished dev [unoptimized + debuginfo] target(s) in 0.01s | ||
Running `target/debug/brainfk-rs` | ||
error: The following required arguments were not provided: | ||
--target <TARGET> | ||
<INPUT_FILE> | ||
<OUTPUT_FILE> | ||
|
||
USAGE: | ||
brainfk-rs --target <TARGET> <INPUT_FILE> <OUTPUT_FILE> | ||
|
||
For more information try --help | ||
|
||
$ cargo run -- tests/files/hello.f hello.wasm --target wasi | ||
Compiling brainfk-rs v0.1.0 (/root/Documents/brainfk-rs) | ||
Finished dev [unoptimized + debuginfo] target(s) in 0.91s | ||
Running `target/debug/brainfk-rs tests/files/hello.f abc.wasm --target wasi` | ||
|
||
$ wasmer run hello.wasm | ||
Hello World! | ||
``` | ||
### Support | ||
- [X] WASI (It uses STDIN and STDOUT) | ||
- [ ] Browser | ||
|
||
### TODO | ||
- [ ] Memory access validation and growth | ||
- [ ] Add support for JS/Browser | ||
- [ ] Integrate with wasmer and support run & compile | ||
- [ ] Add testing |
Oops, something went wrong.