From 9f3db64cf8c6882e3bc7c7805123c19586f7e209 Mon Sep 17 00:00:00 2001 From: sunag Date: Sun, 29 Dec 2024 23:40:42 -0300 Subject: [PATCH 1/4] fix conditional setup process --- src/nodes/math/ConditionalNode.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/nodes/math/ConditionalNode.js b/src/nodes/math/ConditionalNode.js index e133237fba2a48..30bc4f617fe278 100644 --- a/src/nodes/math/ConditionalNode.js +++ b/src/nodes/math/ConditionalNode.js @@ -107,6 +107,8 @@ class ConditionalNode extends Node { properties.ifNode = ifNode.context( { nodeBlock: ifNode } ); properties.elseNode = elseNode ? elseNode.context( { nodeBlock: elseNode } ) : null; + super.setup( builder ); + } generate( builder, output ) { From 1f2b51e72a792f7bc8e21738e28a53b8dd63494a Mon Sep 17 00:00:00 2001 From: sunag Date: Mon, 30 Dec 2024 00:48:23 -0300 Subject: [PATCH 2/4] fix nodeType --- src/nodes/core/CacheNode.js | 11 ++++++++++- src/nodes/math/ConditionalNode.js | 10 +++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/nodes/core/CacheNode.js b/src/nodes/core/CacheNode.js index 2a3da0d5ccaff5..d7a5be87bd7773 100644 --- a/src/nodes/core/CacheNode.js +++ b/src/nodes/core/CacheNode.js @@ -56,7 +56,16 @@ class CacheNode extends Node { getNodeType( builder ) { - return this.node.getNodeType( builder ); + const previousCache = builder.getCache(); + const cache = builder.getCacheFromNode( this, this.parent ); + + builder.setCache( cache ); + + const nodeType = this.node.getNodeType( builder ); + + builder.setCache( previousCache ); + + return nodeType; } diff --git a/src/nodes/math/ConditionalNode.js b/src/nodes/math/ConditionalNode.js index 30bc4f617fe278..e837b186d7d3e5 100644 --- a/src/nodes/math/ConditionalNode.js +++ b/src/nodes/math/ConditionalNode.js @@ -69,11 +69,13 @@ class ConditionalNode extends Node { */ getNodeType( builder ) { - const ifType = this.ifNode.getNodeType( builder ); + const { ifNode, elseNode } = builder.getNodeProperties( this ); +console.log( ifNode ); + const ifType = ifNode.getNodeType( builder ); - if ( this.elseNode !== null ) { + if ( elseNode !== null ) { - const elseType = this.elseNode.getNodeType( builder ); + const elseType = elseNode.getNodeType( builder ); if ( builder.getTypeLength( elseType ) > builder.getTypeLength( ifType ) ) { @@ -107,8 +109,6 @@ class ConditionalNode extends Node { properties.ifNode = ifNode.context( { nodeBlock: ifNode } ); properties.elseNode = elseNode ? elseNode.context( { nodeBlock: elseNode } ) : null; - super.setup( builder ); - } generate( builder, output ) { From 368ec1a187fa3bc044dc6a395e4d56e284fa58e8 Mon Sep 17 00:00:00 2001 From: sunag Date: Mon, 30 Dec 2024 00:50:35 -0300 Subject: [PATCH 3/4] cleanup --- src/nodes/math/ConditionalNode.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nodes/math/ConditionalNode.js b/src/nodes/math/ConditionalNode.js index e837b186d7d3e5..3f1a72cfcdf918 100644 --- a/src/nodes/math/ConditionalNode.js +++ b/src/nodes/math/ConditionalNode.js @@ -70,7 +70,7 @@ class ConditionalNode extends Node { getNodeType( builder ) { const { ifNode, elseNode } = builder.getNodeProperties( this ); -console.log( ifNode ); + const ifType = ifNode.getNodeType( builder ); if ( elseNode !== null ) { From 94845031bc50c6fc1ec687c54e53225b3ce99d69 Mon Sep 17 00:00:00 2001 From: sunag Date: Mon, 30 Dec 2024 01:08:37 -0300 Subject: [PATCH 4/4] Update ConditionalNode.js --- src/nodes/math/ConditionalNode.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/nodes/math/ConditionalNode.js b/src/nodes/math/ConditionalNode.js index 3f1a72cfcdf918..69fb0988c0538d 100644 --- a/src/nodes/math/ConditionalNode.js +++ b/src/nodes/math/ConditionalNode.js @@ -71,6 +71,16 @@ class ConditionalNode extends Node { const { ifNode, elseNode } = builder.getNodeProperties( this ); + if ( ifNode === undefined ) { + + // fallback setup + + this.setup( builder ); + + return this.getNodeType( builder ); + + } + const ifType = ifNode.getNodeType( builder ); if ( elseNode !== null ) {