From 1cf08e018e51bbd65f649f723b48e120cdede55a Mon Sep 17 00:00:00 2001 From: nicosammito Date: Thu, 23 Apr 2026 23:03:45 +0200 Subject: [PATCH] refactor: enhance node code generation in utils.ts for improved clarity and functionality --- src/utils.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index 09dc199..bf6924d 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -157,11 +157,13 @@ export function generateFlowSourceCode( if (node.functionDefinition.identifier === "std::control::return") { code += `return /* @pos ${nodeId} null */ ${funcName}(${args.join(", ")})${needsAnyCast ? "" : ""} ;\n` } else if (node.functionDefinition.identifier === "std::control::if") { - code += `/* @pos ${nodeId} null */ if(${args[0]}) { + code += `const ${varName} = /* @pos ${nodeId} null */ ${funcName}(${args.join(", ")})${needsAnyCast ? "" : ""} ;\n` + code += `if(${args[0]}) { ${generateNodeCode((node.parameters?.nodes?.[1]?.value as NodeFunctionIdWrapper)?.id!, indent + " ")} }` } else if (node.functionDefinition.identifier === "std::control::if_else") { - code += `/* @pos ${nodeId} null */ if(${args[0]}) { + code += `const ${varName} = /* @pos ${nodeId} null */ ${funcName}(${args.join(", ")})${needsAnyCast ? "" : ""} ;\n` + code += `if(${args[0]}) { ${generateNodeCode((node.parameters?.nodes?.[1]?.value as NodeFunctionIdWrapper)?.id!, indent + " ")} } else { ${generateNodeCode((node.parameters?.nodes?.[2]?.value as NodeFunctionIdWrapper)?.id!, indent + " ")}