mirror of
https://github.com/edg-l/edlang.git
synced 2024-11-22 07:58:24 +00:00
fixes
This commit is contained in:
parent
64a4665dfd
commit
4dabaf070b
|
@ -218,11 +218,45 @@ fn compile_fn_signature(ctx: &ModuleCompileCtx<'_, '_>, fn_id: DefId) {
|
|||
}),
|
||||
);
|
||||
|
||||
// https://llvm.org/doxygen/group__LLVMCCoreTypes.html
|
||||
|
||||
/* starting from 1 to 80
|
||||
allocalign allocptr alwaysinline builtin cold convergent disable_sanitizer_instrumentation fn_ret_thunk_extern hot
|
||||
immarg inreg inlinehint jumptable minsize mustprogress naked nest noalias
|
||||
nobuiltin nocallback nocapture nocf_check noduplicate nofree noimplicitfloat
|
||||
noinline nomerge noprofile norecurse noredzone noreturn nosanitize_bounds
|
||||
nosanitize_coverage nosync noundef nounwind nonlazybind nonnull null_pointer_is_valid
|
||||
optforfuzzing optsize optnone presplitcoroutine readnone readonly returned returns_twice
|
||||
signext safestack sanitize_address sanitize_hwaddress sanitize_memtag sanitize_memory
|
||||
sanitize_thread shadowcallstack skipprofile speculatable speculative_load_hardening ssp
|
||||
sspreq sspstrong strictfp swiftasync swifterror swiftself willreturn writeonly (67) zeroext byref byval elementtype inalloca
|
||||
preallocated sret align 0 allockind(\"\") allocsize(0,0) dereferenceable(0) dereferenceable_or_null(0
|
||||
*/
|
||||
|
||||
// nounwind
|
||||
fn_value.add_attribute(
|
||||
inkwell::attributes::AttributeLoc::Function,
|
||||
ctx.ctx.context.create_enum_attribute(36, 0),
|
||||
);
|
||||
|
||||
// nonlazybind
|
||||
fn_value.add_attribute(
|
||||
inkwell::attributes::AttributeLoc::Function,
|
||||
ctx.ctx.context.create_enum_attribute(37, 0),
|
||||
);
|
||||
|
||||
// willreturn
|
||||
fn_value.add_attribute(
|
||||
inkwell::attributes::AttributeLoc::Function,
|
||||
ctx.ctx.context.create_enum_attribute(66, 0),
|
||||
);
|
||||
|
||||
if body.name == "main" {
|
||||
fn_value.set_call_conventions(0);
|
||||
} else {
|
||||
fn_value.set_call_conventions(1);
|
||||
}
|
||||
|
||||
let (_, line, _col) = ctx
|
||||
.ctx
|
||||
.session
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::{
|
|||
borrow::Cow,
|
||||
fmt,
|
||||
path::{Path, PathBuf},
|
||||
process::Output,
|
||||
process::Child,
|
||||
};
|
||||
|
||||
use ariadne::Source;
|
||||
|
@ -80,9 +80,6 @@ pub fn compile_program(
|
|||
})
|
||||
}
|
||||
|
||||
pub fn run_program(program: &Path, args: &[&str]) -> Result<Output, std::io::Error> {
|
||||
std::process::Command::new(program)
|
||||
.args(args)
|
||||
.spawn()?
|
||||
.wait_with_output()
|
||||
pub fn run_program(program: &Path, args: &[&str]) -> Result<Child, std::io::Error> {
|
||||
std::process::Command::new(dbg!(program)).args(args).spawn()
|
||||
}
|
||||
|
|
|
@ -18,13 +18,14 @@ mod common;
|
|||
#[test_case(TEST_IF_NO_ELSE, "TEST_IF_NO_ELSE", false, 1, &[] ; "TEST_IF_NO_ELSE")]
|
||||
#[test_case(TEST_IF_NO_ELSE, "TEST_IF_NO_ELSE", false, 2, &["a"] ; "TEST_IF_NO_ELSE args")]
|
||||
fn example_tests(source: &str, name: &str, is_library: bool, status_code: i32, args: &[&str]) {
|
||||
dbg!(source);
|
||||
let program = compile_program(source, name, is_library).unwrap();
|
||||
|
||||
assert!(program.binary_file.exists(), "program not compiled");
|
||||
|
||||
let result = run_program(&program.binary_file, args).unwrap();
|
||||
let mut result = run_program(&program.binary_file, args).unwrap();
|
||||
let status = result.wait().unwrap();
|
||||
assert_eq!(
|
||||
result.status.code().unwrap(),
|
||||
status.code().unwrap(),
|
||||
status_code,
|
||||
"Program {} returned a unexpected status code",
|
||||
name
|
||||
|
|
|
@ -5,7 +5,7 @@ mod Main {
|
|||
}
|
||||
|
||||
fn factorial(n: i32) -> i32 {
|
||||
if n == 0 {
|
||||
if n == 1 {
|
||||
return n;
|
||||
} else {
|
||||
return n * factorial(n - 1);
|
||||
|
|
Loading…
Reference in a new issue