Merge remote-tracking branch 'origin/trunk' into wasm-gen-test

This commit is contained in:
Folkert 2021-08-29 23:14:03 +02:00
commit b416e854ef
5 changed files with 44 additions and 47 deletions

View file

@ -1,3 +1,4 @@
use std::convert::TryFrom;
use std::path::Path;
use crate::llvm::bitcode::{call_bitcode_fn, call_void_bitcode_fn};
@ -4432,6 +4433,11 @@ fn run_higher_order_low_level<'a, 'ctx, 'env>(
}
}
// TODO: Fix me! I should be different in tests vs. user code!
fn expect_failed() {
panic!("An expectation failed!");
}
#[allow(clippy::too_many_arguments)]
fn run_low_level<'a, 'ctx, 'env>(
env: &Env<'a, 'ctx, 'env>,
@ -4442,6 +4448,7 @@ fn run_low_level<'a, 'ctx, 'env>(
op: LowLevel,
args: &[Symbol],
update_mode: Option<UpdateMode>,
// expect_failed: *const (),
) -> BasicValueEnum<'ctx> {
use LowLevel::*;
@ -5160,8 +5167,20 @@ fn run_low_level<'a, 'ctx, 'env>(
bd.position_at_end(throw_block);
throw_exception(env, "assert failed!");
let fn_ptr_type = context
.void_type()
.fn_type(&[], false)
.ptr_type(AddressSpace::Generic);
let fn_addr = env
.ptr_int()
.const_int(expect_failed as *const () as u64, false);
let func: PointerValue<'ctx> =
bd.build_int_to_ptr(fn_addr, fn_ptr_type, "cast_expect_failed_addr_to_ptr");
let callable = CallableValue::try_from(func).unwrap();
bd.build_call(callable, &[], "call_expect_failed");
bd.build_unconditional_branch(then_block);
bd.position_at_end(then_block);
cond