mirror of
https://github.com/roc-lang/roc.git
synced 2024-09-19 23:07:33 +03:00
update to run on our fork of inkwell again
This commit is contained in:
parent
cdb768e458
commit
be6752542b
10
Cargo.lock
generated
10
Cargo.lock
generated
@ -1123,9 +1123,10 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "inkwell"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/rtfeldman/inkwell#d0a1ce5e678cf0f0e62b757760d1019301c603c9"
|
||||
dependencies = [
|
||||
"either",
|
||||
"inkwell_internals 0.1.0",
|
||||
"inkwell_internals 0.1.0 (git+https://github.com/rtfeldman/inkwell)",
|
||||
"libc",
|
||||
"llvm-sys",
|
||||
"once_cell",
|
||||
@ -1146,6 +1147,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "inkwell_internals"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/rtfeldman/inkwell#d0a1ce5e678cf0f0e62b757760d1019301c603c9"
|
||||
dependencies = [
|
||||
"proc-macro2 0.4.30",
|
||||
"quote 0.6.13",
|
||||
@ -2119,7 +2121,7 @@ dependencies = [
|
||||
"im",
|
||||
"im-rc",
|
||||
"indoc",
|
||||
"inkwell 0.1.0",
|
||||
"inkwell 0.1.0 (git+https://github.com/rtfeldman/inkwell)",
|
||||
"inlinable_string",
|
||||
"maplit",
|
||||
"pretty_assertions",
|
||||
@ -2196,7 +2198,7 @@ dependencies = [
|
||||
"im",
|
||||
"im-rc",
|
||||
"indoc",
|
||||
"inkwell 0.1.0",
|
||||
"inkwell 0.1.0 (git+https://github.com/rtfeldman/inkwell)",
|
||||
"inlinable_string",
|
||||
"libc",
|
||||
"maplit",
|
||||
@ -2327,7 +2329,7 @@ dependencies = [
|
||||
"im",
|
||||
"im-rc",
|
||||
"indoc",
|
||||
"inkwell 0.1.0",
|
||||
"inkwell 0.1.0 (git+https://github.com/rtfeldman/inkwell)",
|
||||
"inlinable_string",
|
||||
"libc",
|
||||
"maplit",
|
||||
|
@ -76,8 +76,7 @@ libc = "0.2"
|
||||
# commit of TheDan64/inkwell, push a new tag which points to the latest commit,
|
||||
# change the tag value in this Cargo.toml to point to that tag, and `cargo update`.
|
||||
# This way, GitHub Actions works and nobody's builds get broken.
|
||||
# inkwell = { git = "https://github.com/rtfeldman/inkwell", tag = "llvm10-0.release1" }
|
||||
inkwell = { path = "/home/folkertdev/roc/inkwell" }
|
||||
inkwell = { git = "https://github.com/rtfeldman/inkwell" }
|
||||
target-lexicon = "0.10"
|
||||
|
||||
[dev-dependencies]
|
||||
|
@ -15,14 +15,6 @@ mod repl_eval {
|
||||
assert!(out.status.success());
|
||||
}
|
||||
|
||||
fn expect_failure(input: &str, expected: &str) {
|
||||
let out = helpers::repl_eval(input);
|
||||
|
||||
assert_eq!(&out.stderr, "");
|
||||
assert_eq!(&out.stdout, expected);
|
||||
assert!(out.status.success());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn literal_0() {
|
||||
expect_success("0", "0 : Num *");
|
||||
|
@ -44,8 +44,7 @@ tokio = { version = "0.2", features = ["blocking", "fs", "sync", "rt-threaded",
|
||||
# commit of TheDan64/inkwell, push a new tag which points to the latest commit,
|
||||
# change the tag value in this Cargo.toml to point to that tag, and `cargo update`.
|
||||
# This way, GitHub Actions works and nobody's builds get broken.
|
||||
# inkwell = { git = "https://github.com/rtfeldman/inkwell", tag = "llvm10-0.release1" }
|
||||
inkwell = { path = "/home/folkertdev/roc/inkwell" }
|
||||
inkwell = { git = "https://github.com/rtfeldman/inkwell" }
|
||||
target-lexicon = "0.10"
|
||||
|
||||
[dev-dependencies]
|
||||
|
@ -38,8 +38,7 @@ inlinable_string = "0.1"
|
||||
# commit of TheDan64/inkwell, push a new tag which points to the latest commit,
|
||||
# change the tag value in this Cargo.toml to point to that tag, and `cargo update`.
|
||||
# This way, GitHub Actions works and nobody's builds get broken.
|
||||
# inkwell = { git = "https://github.com/rtfeldman/inkwell", tag = "llvm10-0.release1" }
|
||||
inkwell = { path = "/home/folkertdev/roc/inkwell" }
|
||||
inkwell = { git = "https://github.com/rtfeldman/inkwell" }
|
||||
target-lexicon = "0.10"
|
||||
|
||||
[dev-dependencies]
|
||||
|
@ -23,6 +23,7 @@ impl<T: Copy> Into<Result<T, String>> for RocCallResult<T> {
|
||||
|
||||
let result = format!("{:?}", raw);
|
||||
|
||||
// make sure rust does not try to free the Roc string
|
||||
std::mem::forget(raw);
|
||||
|
||||
result
|
||||
@ -102,13 +103,17 @@ macro_rules! run_jit_function_dynamic_type {
|
||||
use std::ffi::CString;
|
||||
use std::os::raw::c_char;
|
||||
|
||||
// first field is a char pointer (to the error message)
|
||||
// read value, and transmute to a pointer
|
||||
let ptr_as_int = *(result as *const u64).offset(1);
|
||||
let ptr = std::mem::transmute::<u64, *mut c_char>(ptr_as_int);
|
||||
|
||||
// make CString (null-terminated)
|
||||
let raw = CString::from_raw(ptr);
|
||||
|
||||
let result = format!("{:?}", raw);
|
||||
|
||||
// make sure rust doesn't try to free the Roc constant string
|
||||
std::mem::forget(raw);
|
||||
|
||||
eprintln!("{}", result);
|
||||
|
@ -1,37 +1,5 @@
|
||||
use roc_collections::all::MutSet;
|
||||
use roc_types::subs::Subs;
|
||||
use std::ffi::CString;
|
||||
use std::os::raw::c_char;
|
||||
|
||||
#[repr(C)]
|
||||
union Payload<T: Copy> {
|
||||
success: T,
|
||||
failure: *mut c_char,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct RocCallResult<T: Copy> {
|
||||
pub flag: u64,
|
||||
payload: Payload<T>,
|
||||
}
|
||||
|
||||
impl<T: Copy> Into<Result<T, String>> for RocCallResult<T> {
|
||||
fn into(self) -> Result<T, String> {
|
||||
if self.flag == 0 {
|
||||
Ok(unsafe { self.payload.success })
|
||||
} else {
|
||||
Err(unsafe {
|
||||
let raw = CString::from_raw(self.payload.failure);
|
||||
|
||||
let result = format!("{:?}", raw);
|
||||
|
||||
std::mem::forget(raw);
|
||||
|
||||
result
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn helper_without_uniqueness<'a>(
|
||||
arena: &'a bumpalo::Bump,
|
||||
@ -394,10 +362,9 @@ pub fn helper_with_uniqueness<'a>(
|
||||
#[macro_export]
|
||||
macro_rules! assert_opt_evals_to {
|
||||
($src:expr, $expected:expr, $ty:ty, $transform:expr, $leak:expr) => {
|
||||
use crate::helpers::eval::RocCallResult;
|
||||
use bumpalo::Bump;
|
||||
use inkwell::context::Context;
|
||||
use inkwell::execution_engine::JitFunction;
|
||||
use roc_gen::run_jit_function;
|
||||
|
||||
let arena = Bump::new();
|
||||
|
||||
@ -406,18 +373,8 @@ macro_rules! assert_opt_evals_to {
|
||||
let (main_fn_name, execution_engine) =
|
||||
$crate::helpers::eval::helper_with_uniqueness(&arena, $src, $leak, &context);
|
||||
|
||||
unsafe {
|
||||
let main: JitFunction<unsafe extern "C" fn() -> RocCallResult<$ty>> = execution_engine
|
||||
.get_function(main_fn_name)
|
||||
.ok()
|
||||
.ok_or(format!("Unable to JIT compile `{}`", main_fn_name))
|
||||
.expect("errored");
|
||||
|
||||
match main.call().into() {
|
||||
Ok(success) => assert_eq!($transform(success), $expected),
|
||||
Err(error_msg) => panic!("Roc failed with message: {}", error_msg),
|
||||
}
|
||||
}
|
||||
let transform = |success| assert_eq!($transform(success), $expected);
|
||||
run_jit_function!(execution_engine, main_fn_name, $ty, transform)
|
||||
};
|
||||
|
||||
($src:expr, $expected:expr, $ty:ty, $transform:expr) => {
|
||||
@ -428,10 +385,9 @@ macro_rules! assert_opt_evals_to {
|
||||
#[macro_export]
|
||||
macro_rules! assert_llvm_evals_to {
|
||||
($src:expr, $expected:expr, $ty:ty, $transform:expr, $leak:expr) => {
|
||||
use crate::helpers::eval::RocCallResult;
|
||||
use bumpalo::Bump;
|
||||
use inkwell::context::Context;
|
||||
use inkwell::execution_engine::JitFunction;
|
||||
use roc_gen::run_jit_function;
|
||||
|
||||
let arena = Bump::new();
|
||||
|
||||
@ -440,23 +396,8 @@ macro_rules! assert_llvm_evals_to {
|
||||
let (main_fn_name, errors, execution_engine) =
|
||||
$crate::helpers::eval::helper_without_uniqueness(&arena, $src, $leak, &context);
|
||||
|
||||
unsafe {
|
||||
let main: JitFunction<unsafe extern "C" fn() -> RocCallResult<$ty>> = execution_engine
|
||||
.get_function(main_fn_name)
|
||||
.ok()
|
||||
.ok_or(format!("Unable to JIT compile `{}`", main_fn_name))
|
||||
.expect("errored");
|
||||
|
||||
match main.call().into() {
|
||||
Ok(success) => {
|
||||
// only if there are no exceptions thrown, check for errors
|
||||
assert_eq!(errors, Vec::new(), "Encountered errors: {:?}", errors);
|
||||
|
||||
assert_eq!($transform(success), $expected);
|
||||
}
|
||||
Err(error_msg) => panic!("Roc failed with message: {}", error_msg),
|
||||
}
|
||||
}
|
||||
let transform = |success| assert_eq!($transform(success), $expected);
|
||||
run_jit_function!(execution_engine, main_fn_name, $ty, transform, errors)
|
||||
};
|
||||
|
||||
($src:expr, $expected:expr, $ty:ty, $transform:expr) => {
|
||||
|
Loading…
Reference in New Issue
Block a user