Implement abstractions over Structs and NDArray #554

Merged
sb10q merged 16 commits from ndstrides-neo into master 2024-11-21 18:16:28 +08:00
9 changed files with 21 additions and 65 deletions
Showing only changes of commit 2822074b2d - Show all commits

View File

@ -1,10 +1,4 @@
#![deny( #![deny(future_incompatible, let_underscore, nonstandard_style, clippy::all)]
future_incompatible,
let_underscore,
nonstandard_style,
clippy::all
)]
#![warn(rust_2024_compatibility)]
#![warn(clippy::pedantic)] #![warn(clippy::pedantic)]
#![allow( #![allow(
unsafe_op_in_unsafe_fn, unsafe_op_in_unsafe_fn,
@ -741,7 +735,7 @@ impl Nac3 {
}; };
let return_obj = let return_obj =
generator.gen_expr(ctx, &expr)?.map(|value| (expr.custom.unwrap(), value)); generator.gen_expr(ctx, expr)?.map(|value| (expr.custom.unwrap(), value));
has_return = return_obj.is_some(); has_return = return_obj.is_some();
registry.wait_tasks_complete(handles); registry.wait_tasks_complete(handles);
attributes_writeback( attributes_writeback(
@ -765,7 +759,7 @@ impl Nac3 {
let buffers = membuffers.lock(); let buffers = membuffers.lock();
let main = context let main = context
.create_module_from_ir(MemoryBuffer::create_from_memory_range( .create_module_from_ir(MemoryBuffer::create_from_memory_range(
&buffers.last().unwrap(), buffers.last().unwrap(),
"main", "main",
)) ))
.unwrap(); .unwrap();

View File

@ -1,10 +1,4 @@
#![deny( #![deny(future_incompatible, let_underscore, nonstandard_style, clippy::all)]
future_incompatible,
let_underscore,
nonstandard_style,
clippy::all
)]
#![warn(rust_2024_compatibility)]
#![warn(clippy::pedantic)] #![warn(clippy::pedantic)]
#![allow( #![allow(
clippy::missing_errors_doc, clippy::missing_errors_doc,

View File

@ -56,9 +56,8 @@ fn main() {
let output = Command::new("clang-irrt") let output = Command::new("clang-irrt")
.args(flags) .args(flags)
.output() .output()
.map(|o| { .inspect(|o| {
assert!(o.status.success(), "{}", std::str::from_utf8(&o.stderr).unwrap()); assert!(o.status.success(), "{}", std::str::from_utf8(&o.stderr).unwrap());
o
}) })
.unwrap(); .unwrap();

View File

@ -1,10 +1,4 @@
#![deny( #![deny(future_incompatible, let_underscore, nonstandard_style, clippy::all)]
future_incompatible,
let_underscore,
nonstandard_style,
clippy::all
)]
#![warn(rust_2024_compatibility)]
#![warn(clippy::pedantic)] #![warn(clippy::pedantic)]
#![allow( #![allow(
dead_code, dead_code,

View File

@ -536,9 +536,8 @@ impl<'a> Fold<()> for Inferencer<'a> {
} }
ast::StmtKind::Assert { test, msg, .. } => { ast::StmtKind::Assert { test, msg, .. } => {
self.unify(test.custom.unwrap(), self.primitives.bool, &test.location)?; self.unify(test.custom.unwrap(), self.primitives.bool, &test.location)?;
match msg { if let Some(m) = msg {
Some(m) => self.unify(m.custom.unwrap(), self.primitives.str, &m.location)?, self.unify(m.custom.unwrap(), self.primitives.str, &m.location)?;
None => (),
} }
} }
_ => return report_error("Unsupported statement type", stmt.location), _ => return report_error("Unsupported statement type", stmt.location),

View File

@ -1,10 +1,4 @@
#![deny( #![deny(future_incompatible, let_underscore, nonstandard_style, clippy::all)]
future_incompatible,
let_underscore,
nonstandard_style,
clippy::all
)]
#![warn(rust_2024_compatibility)]
#![warn(clippy::pedantic)] #![warn(clippy::pedantic)]
#![allow( #![allow(
clippy::cast_possible_truncation, clippy::cast_possible_truncation,

View File

@ -15,13 +15,7 @@
//! //!
//! ``` //! ```
#![deny( #![deny(future_incompatible, let_underscore, nonstandard_style, clippy::all)]
future_incompatible,
let_underscore,
nonstandard_style,
clippy::all
)]
#![warn(rust_2024_compatibility)]
#![warn(clippy::pedantic)] #![warn(clippy::pedantic)]
#![allow( #![allow(
clippy::enum_glob_use, clippy::enum_glob_use,

View File

@ -1,10 +1,4 @@
#![deny( #![deny(future_incompatible, let_underscore, nonstandard_style, clippy::all)]
future_incompatible,
let_underscore,
nonstandard_style,
clippy::all
)]
#![warn(rust_2024_compatibility)]
#![warn(clippy::pedantic)] #![warn(clippy::pedantic)]
#![allow(clippy::too_many_lines, clippy::wildcard_imports)] #![allow(clippy::too_many_lines, clippy::wildcard_imports)]

View File

@ -1,10 +1,4 @@
#![deny( #![deny(future_incompatible, let_underscore, nonstandard_style, clippy::all)]
future_incompatible,
let_underscore,
nonstandard_style,
clippy::all
)]
#![warn(rust_2024_compatibility)]
#![warn(clippy::pedantic)] #![warn(clippy::pedantic)]
#![allow(clippy::semicolon_if_nothing_returned, clippy::uninlined_format_args)] #![allow(clippy::semicolon_if_nothing_returned, clippy::uninlined_format_args)]
@ -12,47 +6,47 @@ use std::env;
static mut NOW: i64 = 0; static mut NOW: i64 = 0;
#[no_mangle] #[unsafe(no_mangle)]
pub extern "C" fn now_mu() -> i64 { pub extern "C" fn now_mu() -> i64 {
unsafe { NOW } unsafe { NOW }
} }
#[no_mangle] #[unsafe(no_mangle)]
pub extern "C" fn at_mu(t: i64) { pub extern "C" fn at_mu(t: i64) {
unsafe { NOW = t } unsafe { NOW = t }
} }
#[no_mangle] #[unsafe(no_mangle)]
pub extern "C" fn delay_mu(dt: i64) { pub extern "C" fn delay_mu(dt: i64) {
unsafe { NOW += dt } unsafe { NOW += dt }
} }
#[no_mangle] #[unsafe(no_mangle)]
pub extern "C" fn rtio_init() { pub extern "C" fn rtio_init() {
println!("rtio_init"); println!("rtio_init");
} }
#[no_mangle] #[unsafe(no_mangle)]
pub extern "C" fn rtio_get_counter() -> i64 { pub extern "C" fn rtio_get_counter() -> i64 {
0 0
} }
#[no_mangle] #[unsafe(no_mangle)]
pub extern "C" fn rtio_output(target: i32, data: i32) { pub extern "C" fn rtio_output(target: i32, data: i32) {
println!("rtio_output @{} target={target:04x} data={data}", unsafe { NOW }); println!("rtio_output @{} target={target:04x} data={data}", unsafe { NOW });
} }
#[no_mangle] #[unsafe(no_mangle)]
pub extern "C" fn print_int32(x: i32) { pub extern "C" fn print_int32(x: i32) {
println!("print_int32: {x}"); println!("print_int32: {x}");
} }
#[no_mangle] #[unsafe(no_mangle)]
pub extern "C" fn print_int64(x: i64) { pub extern "C" fn print_int64(x: i64) {
println!("print_int64: {x}"); println!("print_int64: {x}");
} }
#[no_mangle] #[unsafe(no_mangle)]
pub extern "C" fn __nac3_personality(_state: u32, _exception_object: u32, _context: u32) -> u32 { pub extern "C" fn __nac3_personality(_state: u32, _exception_object: u32, _context: u32) -> u32 {
unimplemented!(); unimplemented!();
} }