From 56f44086d6dc2f890c563d8602b8159eae0f96f7 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 ca5aa23c..cbf51402 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..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;