Shuffle object implementation stuff

* Finalize is implemented using the procmacro (I didn't realize this was
  available)
* The `base` BaseObjInst member for objects is now the first member in
  the structure. It will probably be shuffled around by the optimizer
  but I prefer it is the first thing so it is clear what these things
  are.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2024-09-26 10:52:47 -07:00
parent 645105c2c5
commit 3a9bee0e35
2 changed files with 17 additions and 61 deletions

View File

@@ -54,7 +54,7 @@ pub enum FunctionState {
pub type BuiltinFunctionPtr = fn(vm: &mut Vm, function_state: FunctionState) -> FunctionResult;
#[derive(Debug, Trace)]
#[derive(Debug, Trace, Finalize)]
pub struct BuiltinFunctionInst {
base: BaseObjInst,
#[unsafe_ignore_trace]
@@ -85,10 +85,6 @@ impl BuiltinFunctionInst {
}
}
impl Finalize for BuiltinFunctionInst {
fn finalize(&self) {}
}
impl Display for BuiltinFunctionInst {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
write!(
@@ -132,7 +128,7 @@ impl Obj for BuiltinFunctionInst {
// UserFunctionInst
////////////////////////////////////////////////////////////////////////////////
#[derive(Debug, Clone, Trace)]
#[derive(Debug, Clone, Trace, Finalize)]
pub struct UserFunctionInst {
base: BaseObjInst,
#[unsafe_ignore_trace]
@@ -173,10 +169,6 @@ impl UserFunctionInst {
}
}
impl Finalize for UserFunctionInst {
fn finalize(&self) {}
}
impl Display for UserFunctionInst {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
write!(
@@ -223,7 +215,7 @@ impl Obj for UserFunctionInst {
// MethodInst
////////////////////////////////////////////////////////////////////////////////
#[derive(Trace)]
#[derive(Trace, Finalize)]
pub struct MethodInst {
base: BaseObjInst,
self_binding: ObjP,
@@ -260,10 +252,6 @@ impl MethodInst {
}
}
impl Finalize for MethodInst {
fn finalize(&self) {}
}
impl Display for MethodInst {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
write!(fmt, "{}", self.function.borrow())