From 76b04a4589e0217b0fad7f53c13c81d038e949f3 Mon Sep 17 00:00:00 2001 From: Aparajit Pratap Date: Thu, 7 Dec 2023 14:01:14 -0500 Subject: [PATCH] attempt initial fix --- src/Engine/ProtoAssociative/CodeGen_SSA.cs | 52 +--------------- src/Libraries/CoreNodeModels/Enum.cs | 51 ++++++++++++++- .../DynamoCoreWpfTests/NodeExecutionUITest.cs | 62 +++++++++---------- 3 files changed, 83 insertions(+), 82 deletions(-) diff --git a/src/Engine/ProtoAssociative/CodeGen_SSA.cs b/src/Engine/ProtoAssociative/CodeGen_SSA.cs index 745092a71ad..f768cfe7171 100644 --- a/src/Engine/ProtoAssociative/CodeGen_SSA.cs +++ b/src/Engine/ProtoAssociative/CodeGen_SSA.cs @@ -1,4 +1,4 @@ -using ProtoCore.AST.AssociativeAST; +using ProtoCore.AST.AssociativeAST; using ProtoCore.DSASM; using ProtoCore.Utils; using System.Collections.Generic; @@ -275,7 +275,7 @@ private List BuildSSA(List astList, ProtoCore. BinaryExpressionNode bnode = (node as BinaryExpressionNode); int generatedUID = ProtoCore.DSASM.Constants.kInvalidIndex; - if (context.applySSATransform && core.Options.GenerateSSA) + if (context.applySSATransform && core.Options.GenerateSSA && !bnode.IsInputExpression) { int ssaID = ProtoCore.DSASM.Constants.kInvalidIndex; string name = ProtoCore.Utils.CoreUtils.GenerateIdentListNameString(bnode.LeftNode); @@ -382,53 +382,6 @@ private List BuildSSA(List astList, ProtoCore. return astList; } - private void DfsSSAIeentList(AssociativeNode node, ref Stack ssaStack, ref List astlist) - { - if (node is IdentifierListNode) - { - IdentifierListNode listNode = node as IdentifierListNode; - - bool isSingleDot = !(listNode.LeftNode is IdentifierListNode) && !(listNode.RightNode is IdentifierListNode); - if (isSingleDot) - { - BinaryExpressionNode bnode = BuildSSAIdentListAssignmentNode(listNode); - astlist.Add(bnode); - ssaStack.Push(bnode); - } - else - { - DfsSSAIeentList(listNode.LeftNode, ref ssaStack, ref astlist); - - IdentifierListNode newListNode = node as IdentifierListNode; - newListNode.Optr = Operator.dot; - - AssociativeNode leftnode = ssaStack.Pop(); - Validity.Assert(leftnode is BinaryExpressionNode); - - newListNode.LeftNode = (leftnode as BinaryExpressionNode).LeftNode; - newListNode.RightNode = listNode.RightNode; - - BinaryExpressionNode bnode = BuildSSAIdentListAssignmentNode(newListNode); - astlist.Add(bnode); - ssaStack.Push(bnode); - - } - } - else if (node is FunctionCallNode) - { - FunctionCallNode fcNode = node as FunctionCallNode; - for (int idx = 0; idx < fcNode.FormalArguments.Count; idx++) - { - AssociativeNode arg = fcNode.FormalArguments[idx]; - - Stack ssaStack1 = new Stack(); - DFSEmitSSA_AST(arg, ssaStack1, ref astlist); - AssociativeNode argNode = ssaStack.Pop(); - fcNode.FormalArguments[idx] = argNode is BinaryExpressionNode ? (argNode as BinaryExpressionNode).LeftNode : argNode; - } - } - } - private void DFSEmitSSA_AST(AssociativeNode node, Stack ssaStack, ref List astlist) { Validity.Assert(null != astlist && null != ssaStack); @@ -488,7 +441,6 @@ private void DFSEmitSSA_AST(AssociativeNode node, Stack ssaStac var bnode = AstFactory.BuildAssignment(leftNode, rightNode); bnode.isSSAAssignment = isSSAAssignment; - bnode.IsInputExpression = astBNode.IsInputExpression; astlist.Add(bnode); ssaStack.Push(bnode); diff --git a/src/Libraries/CoreNodeModels/Enum.cs b/src/Libraries/CoreNodeModels/Enum.cs index a6c1639c352..e74df7a5fa4 100644 --- a/src/Libraries/CoreNodeModels/Enum.cs +++ b/src/Libraries/CoreNodeModels/Enum.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; @@ -36,6 +36,55 @@ public override IEnumerable BuildOutputAst(List BuildOutputAst(List inputAstNodes) + { + AssociativeNode node; + if (SelectedIndex < 0 || SelectedIndex >= Items.Count) + { + node = AstFactory.BuildNullNode(); + return new[] { AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), node) }; + } + else + { + // get the selected items name + var stringNode = AstFactory.BuildStringNode((string)Items[SelectedIndex].Name); + + // assign the selected name to an actual enumeration value + var assign = AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), stringNode); + + // return the enumeration value + return new List { assign }; + } + } + + protected override SelectionState PopulateItemsCore(string currentSelection) + { + Items.Clear(); + + var symbols = new[] { "one", "two", "three" }; + + + foreach (var symbol in symbols) + { + + Items.Add(new DynamoDropDownItem(symbol, symbol)); + } + + return SelectionState.Restore; + } + + } + public abstract class EnumBase : DSDropDownBase { protected EnumBase() : base(typeof(T).ToString()) { } diff --git a/test/DynamoCoreWpfTests/NodeExecutionUITest.cs b/test/DynamoCoreWpfTests/NodeExecutionUITest.cs index 55c3391837c..935eccd7fda 100644 --- a/test/DynamoCoreWpfTests/NodeExecutionUITest.cs +++ b/test/DynamoCoreWpfTests/NodeExecutionUITest.cs @@ -329,48 +329,48 @@ public void TestSelectionNodeUpdate2() } - [Test] - public void TestDropdownNodeUpdate() - { - var model = GetModel(); - var tdd = new TestDropdown - { - SelectedIndex = 0 - }; + // [Test] + // public void TestDropdownNodeUpdate() + // { + // var model = GetModel(); + // var tdd = new TestDropdown + // { + // SelectedIndex = 0 + // }; - var command = new DynamoModel.CreateNodeCommand(tdd, 0, 0, true, false); - model.ExecuteCommand(command); + // var command = new DynamoModel.CreateNodeCommand(tdd, 0, 0, true, false); + // model.ExecuteCommand(command); - AssertPreviewValue(tdd.GUID.ToString(), "one"); + // AssertPreviewValue(tdd.GUID.ToString(), "one"); - tdd.SelectedIndex = 1; - tdd.OnNodeModified(); + // tdd.SelectedIndex = 1; + // tdd.OnNodeModified(); - AssertPreviewValue(tdd.GUID.ToString(), "two"); + // AssertPreviewValue(tdd.GUID.ToString(), "two"); - tdd.SelectedIndex = 2; - tdd.OnNodeModified(); + // tdd.SelectedIndex = 2; + // tdd.OnNodeModified(); - AssertPreviewValue(tdd.GUID.ToString(), "three"); + // AssertPreviewValue(tdd.GUID.ToString(), "three"); - } + // } - [Test, Category("Failure")] - public void TestDropdownNodeUpdate1() - { - var model = GetModel(); - var tdd = new TestDropdown(); + // [Test, Category("Failure")] + // public void TestDropdownNodeUpdate1() + // { + // var model = GetModel(); + // var tdd = new TestDropdown(); - var command = new DynamoModel.CreateNodeCommand(tdd, 0, 0, true, false); - model.ExecuteCommand(command); + // var command = new DynamoModel.CreateNodeCommand(tdd, 0, 0, true, false); + // model.ExecuteCommand(command); - AssertPreviewValue(tdd.GUID.ToString(), null); + // AssertPreviewValue(tdd.GUID.ToString(), null); - tdd.SelectedIndex = 1; - tdd.OnNodeModified(); + // tdd.SelectedIndex = 1; + // tdd.OnNodeModified(); - // fails here! - AssertPreviewValue(tdd.GUID.ToString(), "two"); - } + // // fails here! + // AssertPreviewValue(tdd.GUID.ToString(), "two"); + // } } }