From 1ce76bcfc9cb6494601fd1641297f2c8df759be3 Mon Sep 17 00:00:00 2001 From: lyken Date: Tue, 20 Aug 2024 11:28:20 +0800 Subject: [PATCH] core/object: introduce object A small abstraction to simplify implementations. --- nac3core/src/codegen/mod.rs | 1 + nac3core/src/codegen/object/any.rs | 12 ++++++++++++ nac3core/src/codegen/object/mod.rs | 1 + 3 files changed, 14 insertions(+) create mode 100644 nac3core/src/codegen/object/any.rs create mode 100644 nac3core/src/codegen/object/mod.rs diff --git a/nac3core/src/codegen/mod.rs b/nac3core/src/codegen/mod.rs index 6b872707..fc5a15fd 100644 --- a/nac3core/src/codegen/mod.rs +++ b/nac3core/src/codegen/mod.rs @@ -48,6 +48,7 @@ pub mod irrt; pub mod llvm_intrinsics; pub mod model; pub mod numpy; +pub mod object; pub mod stmt; #[cfg(test)] diff --git a/nac3core/src/codegen/object/any.rs b/nac3core/src/codegen/object/any.rs new file mode 100644 index 00000000..c7a983e0 --- /dev/null +++ b/nac3core/src/codegen/object/any.rs @@ -0,0 +1,12 @@ +use inkwell::values::BasicValueEnum; + +use crate::typecheck::typedef::Type; + +/// A NAC3 LLVM Python object of any type. +#[derive(Debug, Clone, Copy)] +pub struct AnyObject<'ctx> { + /// Typechecker type of the object. + pub ty: Type, + /// LLVM value of the object. + pub value: BasicValueEnum<'ctx>, +} diff --git a/nac3core/src/codegen/object/mod.rs b/nac3core/src/codegen/object/mod.rs new file mode 100644 index 00000000..93d2f453 --- /dev/null +++ b/nac3core/src/codegen/object/mod.rs @@ -0,0 +1 @@ +pub mod any;