Improved formatting

This commit is contained in:
Syrus Akbary
2018-10-24 02:01:46 +02:00
parent 48f7c46020
commit e9a968b4b0
4 changed files with 27 additions and 30 deletions

View File

@ -53,8 +53,7 @@ fn wabt2rust_type(v: &Value) -> String {
fn is_nan(v: &Value) -> bool {
if let Value::F32(v) = v {
return v.is_nan();
}
else if let Value::F64(v) = v {
} else if let Value::F64(v) = v {
return v.is_nan();
}
return false;
@ -65,7 +64,6 @@ fn wabt2rust_value(v: &Value) -> String {
Value::I32(v) => format!("{:?} as i32", v),
Value::I64(v) => format!("{:?} as i64", v),
Value::F32(v) => {
match *v {
std::f32::INFINITY => "std::f32::INFINITY".to_string(),
std::f32::NEG_INFINITY => "std::f32::NEG_INFINITY".to_string(),
@ -74,17 +72,15 @@ fn wabt2rust_value(v: &Value) -> String {
if v.is_nan() {
if v.is_sign_negative() {
"-std::f32::NAN".to_string()
}
else {
} else {
"std::f32::NAN".to_string()
}
}
else {
} else {
format!("{:?} as f32", v)
}
}
}
},
}
Value::F64(v) => {
match *v {
std::f64::INFINITY => "std::f64::INFINITY".to_string(),
@ -94,12 +90,10 @@ fn wabt2rust_value(v: &Value) -> String {
if v.is_nan() {
if v.is_sign_negative() {
"-std::f64::NAN".to_string()
}
else {
} else {
"std::f64::NAN".to_string()
}
}
else {
} else {
format!("{:?} as f64", v)
}
}
@ -264,10 +258,12 @@ fn l{}_assert_malformed() {{
"()".to_string()
};
let assertion = if expected.len() > 0 && is_nan(&expected[0]) {
format!("assert!(result.is_nan());
assert_eq!(result.is_sign_positive(), ({}).is_sign_positive());", expected_result)
}
else {
format!(
"assert!(result.is_nan());
assert_eq!(result.is_sign_positive(), ({}).is_sign_positive());",
expected_result
)
} else {
format!("assert_eq!(result, {});", expected_result)
};
// We map the arguments provided into the raw Arguments provided

View File

@ -37,9 +37,9 @@ use wabt::wat2wasm;
mod macros;
pub mod common;
pub mod integrations;
pub mod webassembly;
#[cfg(test)]
mod spectests;
pub mod webassembly;
#[derive(Debug, StructOpt)]
#[structopt(name = "wasmer", about = "WASM execution runtime.")]

View File

@ -6,10 +6,10 @@
//! synchronously instantiate a given webassembly::Module object. However, the
//! primary way to get an Instance is through the asynchronous
//! webassembly::instantiateStreaming() function.
use cranelift_codegen::ir::LibCall;
use cranelift_codegen::{binemit, isa, Context};
use cranelift_entity::EntityRef;
use cranelift_wasm::{FuncIndex, GlobalInit};
use cranelift_codegen::ir::LibCall;
use memmap::MmapMut;
use region;
use spin::RwLock;
@ -657,42 +657,43 @@ extern "C" fn current_memory(memory_index: u32, vmctx: &VmCtx) -> u32 {
// }
}
// Because of this bug https://github.com/rust-lang/rust/issues/34123
// We create internal functions for it
use std::intrinsics::{ceilf32, floorf32, truncf32, nearbyintf32, ceilf64, floorf64, truncf64, nearbyintf64};
use std::intrinsics::{
ceilf32, ceilf64, floorf32, floorf64, nearbyintf32, nearbyintf64, truncf32, truncf64,
};
// F32
unsafe extern fn _ceilf32(x: f32) -> f32 {
unsafe extern "C" fn _ceilf32(x: f32) -> f32 {
ceilf32(x)
}
unsafe extern fn _floorf32(x: f32) -> f32 {
unsafe extern "C" fn _floorf32(x: f32) -> f32 {
floorf32(x)
}
unsafe extern fn _truncf32(x: f32) -> f32 {
unsafe extern "C" fn _truncf32(x: f32) -> f32 {
truncf32(x)
}
unsafe extern fn _nearbyintf32(x: f32) -> f32 {
unsafe extern "C" fn _nearbyintf32(x: f32) -> f32 {
nearbyintf32(x)
}
// F64
unsafe extern fn _ceilf64(x: f64) -> f64 {
unsafe extern "C" fn _ceilf64(x: f64) -> f64 {
ceilf64(x)
}
unsafe extern fn _floorf64(x: f64) -> f64 {
unsafe extern "C" fn _floorf64(x: f64) -> f64 {
floorf64(x)
}
unsafe extern fn _truncf64(x: f64) -> f64 {
unsafe extern "C" fn _truncf64(x: f64) -> f64 {
truncf64(x)
}
unsafe extern fn _nearbyintf64(x: f64) -> f64 {
unsafe extern "C" fn _nearbyintf64(x: f64) -> f64 {
nearbyintf64(x)
}

View File

@ -3,7 +3,7 @@
//! any other calls that this function is doing, so we can "patch" the
//! function addrs in runtime with the functions we need.
use cranelift_codegen::binemit;
use cranelift_codegen::ir::{self, ExternalName, SourceLoc, TrapCode, LibCall};
use cranelift_codegen::ir::{self, ExternalName, LibCall, SourceLoc, TrapCode};
pub use cranelift_codegen::binemit::Reloc;
use cranelift_wasm::FuncIndex;