Refactor VM to use trait objects for closures

The `CallFrame` struct and various VM methods now use `Rc<dyn Object>`
to hold closures, allowing for more flexibility and avoiding unnecessary
cloning.

This change also addresses the performance concern regarding deep copies
of closures, preferring `Rc<dyn Trait>` with local `downcast_ref` where
appropriate.

Additionally, a documentation note has been added to `gemini.md`
regarding this performance preference in Rust.
This commit is contained in:
Michael Schimmel
2026-02-28 14:26:29 +01:00
parent 3daf8ef94d
commit 0dfbda5e15
4 changed files with 29 additions and 21 deletions
+4
View File
@@ -33,6 +33,10 @@ Wichtig: zentraler Einstiegspunkt ist Delphi/Myc.Ast.Environment.pasund die dort
* Dokumentation nach Rust-Regeln.
* Im Code und den Kommentaren muss alles auf englisch sein.
## Rust
* Performance: Bevorzuge `Rc<dyn Trait>` + lokales `downcast_ref` gegenüber Deep Copies via `Rc::new(obj.clone())`.
## Interaktion
* Ich kann Rust noch nicht so gut. Erkläre mir, was du machst und welche Konzepte du nutzt. Ich will was dazulernen.