From 918c8485a449d5301b4020b5c49e96963cdb53a4 Mon Sep 17 00:00:00 2001 From: fro Date: Thu, 26 Oct 2017 19:24:40 +0300 Subject: [PATCH] fix logic + types --- build/src/main.rs | 4 ++-- src/pack.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build/src/main.rs b/build/src/main.rs index faaf2ff..401243c 100644 --- a/build/src/main.rs +++ b/build/src/main.rs @@ -136,12 +136,12 @@ fn main() { // If module has an exported function with name=CREATE_SYMBOL // build will pack the module (raw_module) into this funciton and export as CALL_SYMBOL. // Otherwise it will just save an optimised raw_module - if !has_ctor(&ctor_module) { + if has_ctor(&ctor_module) { if !matches.is_present("skip_optimization") { wasm_utils::optimize(&mut ctor_module, vec![CREATE_SYMBOL, "setTempRet0"]).expect("Optimizer to finish without errors"); } wasm_utils::pack_instance(raw_module, &mut ctor_module); - parity_wasm::serialize_to_file(path, ctor_module).expect("Failed to serialize to file"); + parity_wasm::serialize_to_file(&path, ctor_module).expect("Failed to serialize to file"); } else { let mut file = fs::File::create(&path).expect("Failed to create file"); file.write_all(&raw_module).expect("Failed to write module to file"); diff --git a/src/pack.rs b/src/pack.rs index dbc9f16..a5e7fa7 100644 --- a/src/pack.rs +++ b/src/pack.rs @@ -42,7 +42,7 @@ pub fn pack_instance(raw_module: Vec, ctor_module: &mut elements::Module) { if let Opcode::I32Const(offst) = entry.offset().code()[0] { let len = entry.value().len() as i32; let offst = offst as i32; - (entry.index(), offst + (len + 32) - len % 32) + (entry.index(), offst + (len + 4) - len % 4) } else { (0, 0) }