From 0e46932588fb15b3fbf6edbd26857bd6a6603a2d Mon Sep 17 00:00:00 2001 From: lyken Date: Tue, 20 Aug 2024 11:28:20 +0800 Subject: [PATCH] core/object: introduce object 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 b96f3bd1..697fcf89 100644 --- a/nac3core/src/codegen/mod.rs +++ b/nac3core/src/codegen/mod.rs @@ -43,6 +43,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..b6abd599 --- /dev/null +++ b/nac3core/src/codegen/object/any.rs @@ -0,0 +1,12 @@ +use inkwell::values::BasicValueEnum; + +use crate::typecheck::typedef::Type; + +/// An NAC3 LLVM Python object. +#[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;