Skip to content

Commit

Permalink
attempt initial fix
Browse files Browse the repository at this point in the history
  • Loading branch information
aparajit-pratap committed Dec 7, 2023
1 parent c48f42a commit 76b04a4
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 82 deletions.
52 changes: 2 additions & 50 deletions src/Engine/ProtoAssociative/CodeGen_SSA.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using ProtoCore.AST.AssociativeAST;
using ProtoCore.AST.AssociativeAST;
using ProtoCore.DSASM;
using ProtoCore.Utils;
using System.Collections.Generic;
Expand Down Expand Up @@ -275,7 +275,7 @@ private List<AssociativeNode> BuildSSA(List<AssociativeNode> 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);
Expand Down Expand Up @@ -382,53 +382,6 @@ private List<AssociativeNode> BuildSSA(List<AssociativeNode> astList, ProtoCore.
return astList;
}

private void DfsSSAIeentList(AssociativeNode node, ref Stack<AssociativeNode> ssaStack, ref List<AssociativeNode> 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<AssociativeNode> ssaStack1 = new Stack<AssociativeNode>();
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<AssociativeNode> ssaStack, ref List<AssociativeNode> astlist)
{
Validity.Assert(null != astlist && null != ssaStack);
Expand Down Expand Up @@ -488,7 +441,6 @@ private void DFSEmitSSA_AST(AssociativeNode node, Stack<AssociativeNode> ssaStac

var bnode = AstFactory.BuildAssignment(leftNode, rightNode);
bnode.isSSAAssignment = isSSAAssignment;
bnode.IsInputExpression = astBNode.IsInputExpression;

astlist.Add(bnode);
ssaStack.Push(bnode);
Expand Down
51 changes: 50 additions & 1 deletion src/Libraries/CoreNodeModels/Enum.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
Expand Down Expand Up @@ -36,6 +36,55 @@ public override IEnumerable<AssociativeNode> BuildOutputAst(List<AssociativeNode
}
}

[NodeName("Test Dropdown Node")]
[NodeCategory("TestUINodes")]
[NodeDescription("test dropdown node")]
[OutPortTypes("string")]
[IsDesignScriptCompatible]
public class TestDropdown : DSDropDownBase
{
public TestDropdown() : base("TestDropdown") { }


public override IEnumerable<AssociativeNode> BuildOutputAst(List<AssociativeNode> 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<AssociativeNode> { 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<T> : DSDropDownBase
{
protected EnumBase() : base(typeof(T).ToString()) { }
Expand Down
62 changes: 31 additions & 31 deletions test/DynamoCoreWpfTests/NodeExecutionUITest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
// }
}
}

0 comments on commit 76b04a4

Please sign in to comment.