ProgramMemory refactor - eliminate copies of memory (#5273)

* refactor program memory for encapsulation and remove special treatment of return values

Signed-off-by: Nick Cameron <nrc@ncameron.org>

* Refactor ProgramMemory to isolate mutation

Signed-off-by: Nick Cameron <nrc@ncameron.org>

* Refactor ProgramMemory

Signed-off-by: Nick Cameron <nrc@ncameron.org>

* Generated output

Signed-off-by: Nick Cameron <nrc@ncameron.org>

* Cache the result of executing modules for their items

Signed-off-by: Nick Cameron <nrc@ncameron.org>

* Compress envs when popped

Signed-off-by: Nick Cameron <nrc@ncameron.org>

* Remove the last traces of geometry from the memory module

Signed-off-by: Nick Cameron <nrc@ncameron.org>

* docs

Signed-off-by: Nick Cameron <nrc@ncameron.org>

* Fixups

Signed-off-by: Nick Cameron <nrc@ncameron.org>

* Frontend

Signed-off-by: Nick Cameron <nrc@ncameron.org>

* Improve Environment GC

Signed-off-by: Nick Cameron <nrc@ncameron.org>

* Fixup mock execution frontend and interpreter, misc bug fixes

Signed-off-by: Nick Cameron <nrc@ncameron.org>

---------

Signed-off-by: Nick Cameron <nrc@ncameron.org>
This commit is contained in:
Nick Cameron
2025-02-12 10:22:56 +13:00
committed by GitHub
parent bc4d254297
commit 322f398049
139 changed files with 4825 additions and 8154 deletions

View File

@ -1,6 +1,5 @@
import {
PathToNode,
ProgramMemory,
VariableDeclaration,
VariableDeclarator,
parse,
@ -708,7 +707,7 @@ export const modelingMachine = setup({
const modifiedAst = await deleteFromSelection(
ast,
selectionRanges.graphSelections[0],
kclManager.programMemory,
kclManager.variables,
getFaceDetails
)
if (err(modifiedAst)) {
@ -719,8 +718,7 @@ export const modelingMachine = setup({
const testExecute = await executeAst({
ast: modifiedAst,
engineCommandManager,
// We make sure to send an empty program memory to denote we mean mock mode.
programMemoryOverride: ProgramMemory.empty(),
isMock: true,
})
if (testExecute.errors.length) {
toast.error(errorMessage)
@ -1087,7 +1085,7 @@ export const modelingMachine = setup({
selectionRanges,
'horizontal',
kclManager.ast,
kclManager.programMemory
kclManager.variables
)
if (trap(constraint)) return false
const { modifiedAst, pathToNodeMap } = constraint
@ -1122,7 +1120,7 @@ export const modelingMachine = setup({
selectionRanges,
'vertical',
kclManager.ast,
kclManager.programMemory
kclManager.variables
)
if (trap(constraint)) return false
const { modifiedAst, pathToNodeMap } = constraint