Skip to content

Commit

Permalink
Simple WASM generating (#55)
Browse files Browse the repository at this point in the history
* create standard abbreviation table

* update dependencies

* new fix irreducible framework

* fix fold_if_else

* nested loop with same header

* done generate_function

* pass all tests

* fix several bugs

* memory operation

* fix loop

* come command can generate wasm now
  • Loading branch information
longfangsong authored May 10, 2024
1 parent f069b0e commit 967de0a
Show file tree
Hide file tree
Showing 32 changed files with 3,670 additions and 1,841 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,5 @@ Cargo.lock
!integration-test/cases/*/expected/*.asm
*.clef
doc/public
lcov.info
*.wasm
30 changes: 15 additions & 15 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,36 @@ version = "0.1.0"
edition = "2021"
build = "build.rs"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bimap = "0.6.3"
bincode = "1.3.3"
bitvec = { version = "1.0.1", features=["serde"] }
clap = { version = "4.2.7", features = ["derive"] }
enum_dispatch = "0.3.11"
indexmap = "1.9.3"
itertools = "0.10.5"
bitvec = { version = "1.0.1", features = ["serde"] }
clap = { version = "4.4.14", features = ["derive"] }
enum_dispatch = "0.3.12"
indexmap = "2.1.0"
itertools = "0.12.0"
nom = "7.1.3"
paste = "1.0.12"
petgraph = "0.6.3"
phf = { version = "0.11.1", features = ["macros"] }
serde = { version = "1.0.162", features = ["derive"] }
toml = "0.7.3"
shadow-rs = { version = "0.21.0", optional = true }
paste = "1.0.14"
petgraph = "0.6.4"
phf = { version = "0.11.2", features = ["macros"] }
serde = { version = "1.0.195", features = ["derive"] }
toml = "0.8.8"
shadow-rs = { version = "0.26.0", optional = true }
ezio = { version = "0.1.2", optional = true }
delegate = "0.12.0"
wasm-encoder = "0.205.0"

[dev-dependencies]
cov-mark = "1.1.0"

[build-dependencies]
shadow-rs = "0.21.0"
shadow-rs = "0.26.0"

[lib]
crate-type = ["lib"]

[features]
build-binary = []
build-binary = ["shadow-rs", "ezio"]

[[bin]]
name = "clefviewer"
Expand Down
7 changes: 7 additions & 0 deletions doc/content/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ section = "docs"
url = "/docs/getting-started/introduction/"
weight = 10


[[extra.menu.main]]
name = "Rules"
section = "rules"
url = "/rules/naming/"
weight = 10

[[extra.menu.main]]
name = "Crate doc"
section = "crate-doc"
Expand Down
9 changes: 9 additions & 0 deletions doc/content/rules/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
+++
title = "Rules"
description = "The rules for developing Come."
date = 2023-07-16T04:19:34.823Z
updated = 2023-07-16T04:19:34.823Z
sort_by = "weight"
weight = 1
template = "docs/section.html"
+++
26 changes: 26 additions & 0 deletions doc/content/rules/naming/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
+++
title = "Naming"
description = "Naming rules for Come."
date = 2023-07-16T04:21:20.130Z
updated = 2023-07-16T04:21:20.130Z
template = "docs/section.html"
sort_by = "weight"
weight = 1
draft = false
+++

Except for the rules mentioned on [rust naming guides](https://rust-lang.github.io/api-guidelines/naming.html),
there are some additional rules for Come.

## Don't use undocumented abbreviations

We don't use abbreviations unless they are documented in the glossary.

Here is the glossary:

| Abbreviation | Origin | In Module |
|--------------|--------|-----------|
| ast | Abstract Syntax Tree | (All) |
| asm | ASseMbly language | (All) |
| ir | Intermediate Representation | (All) |
| bb | Basic Block | `come::ir` |
17 changes: 7 additions & 10 deletions doc/content/tools/graph_editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ function renderComeIR() {
parameters: Vec::new(),
return_type: data_type::Type::None,
},
content: vec![`;
content: vec![\n`;
let nodes = new Set();
for (let edge of edgesInfo) {
let { first, second, line } = edge;
Expand All @@ -346,30 +346,27 @@ function renderComeIR() {
nodes.add(secondId);
}
for (let node of nodes) {
content += `
BasicBlock {
name: Some("bb${node}".to_string()),
content: vec![`;
let to = edgesInfo.filter(({ first }) => {
const firstId = first.getAttribute("id").substring("node-".length);
return firstId === node;
}).map(({ second }) => {
const secondId = second.getAttribute("id").substring("node-".length);
return secondId;
});
content += " ";
if (to.length === 0) {
content += `Ret { value: None }.into()`;
content += `ret_block(${node}),`;
} else if (to.length === 1) {
let target = to[0];
content += `jump("bb${target}")`;
content += `jump_block(${node}, ${target}),`;
} else if (to.length === 2) {
let first = to[0];
let second = to[1];
content += `branch("bb${first}", "bb${second}")`;
content += `branch_block(${node}, ${first}, ${second}),`;
}
content += `],
},`
content += "\n";
}
content = content.slice(0, -1);
content += `
],
};`;
Expand Down
Empty file added doc/templates/.gitkeep
Empty file.
Loading

0 comments on commit 967de0a

Please sign in to comment.