Fix default memory so its always initialized in one place -> rust (#1395)

* initial redo

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* default memory

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* rename values

* find tricky case

* fix test

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
Co-authored-by: Kurt Hutten Irev-Dev <k.hutten@protonmail.ch>
This commit is contained in:
Jess Frazelle
2024-02-11 18:26:09 -08:00
committed by GitHub
parent f1ea9b6ece
commit 5f0f3f40d0
9 changed files with 113 additions and 80 deletions

View File

@ -42,6 +42,7 @@ import {
PipeExpression,
Program,
ProgramMemory,
programMemoryInit,
recast,
SketchGroup,
VariableDeclaration,
@ -49,7 +50,7 @@ import {
} from 'lang/wasm'
import { kclManager } from 'lang/KclSingleton'
import { getNodeFromPath, getNodePathFromSourceRange } from 'lang/queryAst'
import { defaultProgramMemory, executeAst } from 'useStore'
import { executeAst } from 'useStore'
import { engineCommandManager } from 'lang/std/engineConnection'
import {
createArcGeometry,
@ -869,10 +870,7 @@ function prepareTruncatedMemoryAndAst(
..._ast,
body: [JSON.parse(JSON.stringify(_ast.body[bodyIndex]))],
}
const programMemoryOverride: ProgramMemory = {
root: defaultProgramMemory(),
return: null,
}
const programMemoryOverride: ProgramMemory = programMemoryInit()
for (let i = 0; i < bodyIndex; i++) {
const node = _ast.body[i]
if (node.type !== 'VariableDeclaration') {