From 7a9ac73037f207e3895332e5ba2b30d465c9c339 Mon Sep 17 00:00:00 2001 From: Antonio Navarro Perez Date: Thu, 21 Mar 2024 15:46:33 +0100 Subject: Add extra GoDoc to explain why Dump is on the Compiler. Signed-off-by: Antonio Navarro Perez --- parser/compiler.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/parser/compiler.go b/parser/compiler.go index 568ed4a..fb79720 100644 --- a/parser/compiler.go +++ b/parser/compiler.go @@ -377,7 +377,13 @@ type DumpValue struct { Value any } -// Dump gets the execution state of global variables. +// Dump creates a snapshot of the execution state of global variables. +// This method is specifically implemented in the Compiler to minimize the coupling between +// the dump format and other components. By situating the dump logic in the Compiler, +// it relies solely on the program being executed and the indexing algorithm used for ordering variables +// (currently, this is an integer that corresponds to the order of variables in the program). +// This design choice allows the Virtual Machine (VM) to evolve its memory management strategies +// without compromising backward compatibility with dumps generated by previous versions. func (c *Compiler) Dump() *Dump { var dv []*DumpValue dict := c.symbolsByIndex() -- cgit v1.2.3