Get control flow working (fingers crossed)

This commit is contained in:
Lachlan Sneff
2019-02-12 18:02:00 -08:00
parent 5ee19e55a5
commit 2572a0259b
5 changed files with 377 additions and 52 deletions

View File

@ -30,21 +30,26 @@ impl Compiler for LLVMCompiler {
#[test]
fn test_read_module() {
use wabt::wat2wasm;
let WAT: &'static str = r#"
let wat = r#"
(module
(type $t0 (func (param i32) (result i32)))
(import "env" "memory" (memory 1 1))
(import "env" "table" (table 10 anyfunc))
(import "env" "global" (global i32))
(import "env" "print_i32" (func $print_i32 (type $t0)))
(func $identity (type $t0) (param $p0 i32) (result i32)
get_local $p0)
(func $print_num (export "print_num") (type $t0) (param $p0 i32) (result i32)
get_global 0
call $identity
call $print_i32))
(type $t1 (func (result i32)))
(func $foo (type $t0) (param i32) (result i32)
get_local 0
(if
(then
i32.const 42
set_local 0
)
(else
i32.const 24
set_local 0
)
)
get_local 0
))
"#;
let wasm = wat2wasm(WAT).unwrap();
let wasm = wat2wasm(wat).unwrap();
let (info, code_reader) = read_info::read_module(&wasm).unwrap();