Skip to content

Commit 6a23793

Browse files
committed
Add wat dependency and implement compile_to_wasm function
1 parent 1911969 commit 6a23793

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

inference/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ homepage = { workspace = true }
77
repository = { workspace = true }
88

99
[dependencies]
10+
wat = "1.222.0"
1011
tree-sitter.workspace = true
1112
tree-sitter-inference.workspace = true
1213
inference-ast.workspace = true

inference/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Inference is a programming language that is designed to be easy to learn and use.
2+
13
pub fn compile_to_wat(source_code: &str) -> String {
24
let inference_language = tree_sitter_inference::language();
35
let mut parser = tree_sitter::Parser::new();
@@ -10,3 +12,8 @@ pub fn compile_to_wat(source_code: &str) -> String {
1012
let ast = inference_ast::builder::build_ast(root_node, code);
1113
inference_wat_codegen::wat_generator::generate_for_source_file(&ast)
1214
}
15+
16+
pub fn compile_to_wasm(source_code: &str) -> Vec<u8> {
17+
let wat = compile_to_wat(source_code);
18+
wat::parse_str(wat).unwrap()
19+
}

0 commit comments

Comments
 (0)