当前位置: 首页>>代码示例>>C#>>正文


C# GraphToDSCompiler.Node类代码示例

本文整理汇总了C#中GraphToDSCompiler.Node的典型用法代码示例。如果您正苦于以下问题:C# Node类的具体用法?C# Node怎么用?C# Node使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Node类属于GraphToDSCompiler命名空间,在下文中一共展示了Node类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BinExprNode

 /// <summary>
 /// Represents simple binary expressions which involve identifier on left and literal on the right
 /// </summary>
 /// <param name="i1"></param>
 /// <param name="o"></param>
 /// <param name="i2"></param>
 internal BinExprNode(IdentNode i1, Operator o, LiteralNode i2)
     : base(i1.Name + o.Name + i2.Name, o.Guid)
 {
     op = o;
     left = i1;
     right = i2;
 }
开发者ID:algobasket,项目名称:Dynamo,代码行数:13,代码来源:DerivedNodes.cs

示例2: CreateTempIdentifierNode

        // TODO: Deprecate
        private static IdentifierNode CreateTempIdentifierNode(Node node)
        {
            uint tguid = GraphCompiler.GetTempGUID(node.Guid);
            string tempName = GraphToDSCompiler.kw.tempPrefix + tguid;

            return new IdentifierNode(tempName);
        }
开发者ID:ankushraizada,项目名称:Dynamo,代码行数:8,代码来源:GraphNodeToASTGenerator.cs

示例3: Assignment

 //
 // TODO Jun: Deprecate the overloaded constructors.
 // All assignment nodes must be instantiated with this constructor
 public Assignment(Node left, Node right)
     : base("", left.Guid)
 {
     Optr = ProtoCore.DSASM.Operator.assign;
     base.Name = ProtoCore.Utils.CoreUtils.GetOperatorString(Optr);
     this.left = left;
     this.right = right;
 }
开发者ID:Benglin,项目名称:designscript,代码行数:11,代码来源:DerivedNodes.cs

示例4: IsNotVisited

 private static Boolean IsNotVisited(Node node, Dictionary<Node, int> nodeStateMap)
 {
     if (!nodeStateMap.ContainsKey(node))
     {
         return true;
     }
     int state = nodeStateMap[node];
     return NOT_VISTITED == state;
 }
开发者ID:ankushraizada,项目名称:Dynamo,代码行数:9,代码来源:TopSort.cs

示例5: DFS

 static List<Node> DFS(Node node, AST statementList)
 {
     List<Node> sotedNodes = new List<Node>();
     Dictionary<Node, int> nodeStateMap = new Dictionary<Node, int>();
     if (IsNotVisited(node, nodeStateMap))
     {
         DFSVisit(node, nodeStateMap, sotedNodes, statementList);
     }
     return sotedNodes;
 }
开发者ID:ankushraizada,项目名称:Dynamo,代码行数:10,代码来源:TopSort.cs

示例6: GetKeysFromValue

 public static List<int> GetKeysFromValue(Dictionary<int, Node> dict, Node node)
 {
     List<int> ks = new List<int>();
     foreach (int k in dict.Keys)
     {
         if (dict[k].Equals(node))
         {
             ks.Add(k);
         }
     }
     return ks;
 }
开发者ID:samuto,项目名称:designscript,代码行数:12,代码来源:TopSort.cs

示例7: DFSVisit

 static void DFSVisit(Node node, Dictionary<Node, int> nodeStateMap, List<Node> list)
 {
     nodeStateMap.Add(node, VISITING);
     List<Node> nodes = node.GetChildren();
     IEnumerable iter = nodes;
     foreach (Node nodeI in iter)
     {
         if (IsNotVisited(nodeI, nodeStateMap))
             DFSVisit(nodeI, nodeStateMap, list);
     }
     nodeStateMap[node] = VISITED;
     list.Add(node);
 }
开发者ID:ankushraizada,项目名称:Dynamo,代码行数:13,代码来源:TopSort.cs

示例8: AddEdge

 public void AddEdge(Node from, Node to, int inputIndex, int fromIndex)
 {
     from.AddChild(to, inputIndex, fromIndex);
     to.AddParent(from);
     List<Node> cycle = CheckForCycle.CreatesCycle(to);
     if (cycle != null)
     {
         // remove edge which introduced cycle
         //    RemoveEdge( from, to );
         String msg = "Edge between '" + from.Name + "' and '" + to.Name + "' introduces a cycle in the graph";
         GraphCompilationStatus.HandleError(new HasCycleException(msg, cycle)) ;
     }
 }
开发者ID:samuto,项目名称:designscript,代码行数:13,代码来源:AST.cs

示例9: BuildBlockToBlockStatement

        private static void BuildBlockToBlockStatement(Node node, Node nodeI, AST statementList)
        {
            if (node.children.Count > 1)
            {
                statementList.AddNode(node);
            }
            else
            {
                string content = string.Empty;
                Block block = nodeI as Block;
                Validity.Assert(block != null);
                Assignment a1 = null;
                Node n1 = statementList.GetNode(node.Guid);
                if (n1 is Assignment)
                {
                    a1 = n1 as Assignment;

                    //
                    // Comment Jun:
                    // This condition basically checks if the single line codeblock is either a full expression or a single ident
                    // For now, in order to check for single ident, we check if the LHS if empty
                    // This needs refinement
                    bool isSingleIdent = string.IsNullOrEmpty((((Block)node).LHS));
                    if (isSingleIdent)
                    {
                        // This single line codeblock is a single identifier
                        a1.right.Name = block.LHS != "" ? block.LHS : block.Name.Replace(";", "").Trim();
                        content = a1.ToScript();
                    }
                    else
                    {
                        // This single line codeblock is a full expression
                        content = ((Block)node).Name;
                    }

                    // Comment Jun: Create a new block that represents the new contents
                    Block block2 = new Block(content, node.Guid);
                    int index = statementList.nodeList.IndexOf(a1);
                    statementList.RemoveNode(a1);

                    statementList.nodeList.Insert(index, block2);
                    statementList.nodeMap.Add(block2.Guid, block2);

                    // Comment Jun: Reflect the new changes to the original block
                    (node as Block).SetData(block2.LHS, content);
                }
            }
        }
开发者ID:samuto,项目名称:designscript,代码行数:48,代码来源:TopSort.cs

示例10: AddNode

        /*public HashSet<uint> GetNames()
        {
            HashSet<uint> nameSet = new HashSet<uint>(nodeMap.Keys);
            return nameSet;
        }
        */
        /// <summary>
        /// Adds a new node to the nodemap given its name and guid if it is not present in the graph.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="guid"></param>
        /// <returns></returns>
        public Node AddNode(string name, uint guid)
        {
            Node newNode = null;

            if (nodeMap.ContainsKey(guid))
            {
                newNode = (Node)nodeMap[guid];
            }
            else
            {
                newNode = new Node(name, guid);
                nodeMap.Add(guid, newNode);
                nodeList.Add(newNode);
            }
            return newNode;
        }
开发者ID:RobertiF,项目名称:Dynamo,代码行数:28,代码来源:AST.cs

示例11: CreatesCycle

 public static List<Node> CreatesCycle(Node node, Dictionary<Node, int> nodeStateMap)
 {
     List<Node> cycleStack = new List<Node>();
     Boolean hasCycle = DFSVisit( node, nodeStateMap,cycleStack);
     if ( hasCycle )
     {
         // we have a situation like: [c, a, b, c, f, g, h].
         // Node which introduced  the cycle is at the first position in the list
         // We have to find second occurence of this node and use its position in the list
         // for getting the sublist of vertex labels of cycle paricipants
         // So in our case we are seraching for [c, a, b, c]
         //string name = cycleStack[0].Name;
         int pos = cycleStack.IndexOf(cycleStack[0],0);
         List<Node> cycle = new List<Node>(pos + 1);
         for(int i=0;i<pos+1;i++)
             cycle.Add(cycleStack[i]);
         cycle.Reverse();
         return cycle;
     }
     return null;
 }
开发者ID:RobertiF,项目名称:Dynamo,代码行数:21,代码来源:CheckForCycle.cs

示例12: DFSVisit

 /// <summary>
 /// Returns false if a depth-first search of Graph yields no back edges.
 /// If back edges found then return true and update cycleStack.
 /// </summary>
 /// <param name="node"></param>
 /// <param name="nodeStateMap"></param>
 /// <param name="cycleStack"></param>
 /// <returns></returns>
 public static Boolean DFSVisit(Node node, Dictionary<Node, int> nodeStateMap, List<Node> cycleStack)
 {
     cycleStack.Add(node);
     nodeStateMap.Add(node, visiting);
     List<Node> nodes = node.GetChildren();
     IEnumerable iter = nodes;
     foreach (Node nodeI in iter)
     {
         if (IsNotVisited(nodeI, nodeStateMap))
         {
             if (DFSVisit(nodeI, nodeStateMap, cycleStack)) return true;
         }
         else if (IsVisiting(nodeI, nodeStateMap))
         {
             cycleStack.Insert(0,node);
             return true;
         }
     }
     nodeStateMap[node] = visited;
     cycleStack.RemoveAt(0);
     return false;
 }
开发者ID:RobertiF,项目名称:Dynamo,代码行数:30,代码来源:CheckForCycle.cs

示例13: BuildBlockToIdentStatement

        private static void BuildBlockToIdentStatement(Node node, Node nodeIdent, AST statementList)
        {
            Validity.Assert(node is Block);

            if (node.children.Count > 1)
            {
                statementList.AddNode(node);
            }
            else
            {
                IdentNode identNode = nodeIdent as IdentNode;
                Validity.Assert(null != identNode);

                Block block = node as Block;

                string lhs = string.Empty;
                string content = string.Empty;
                bool isSingleIdent = string.IsNullOrEmpty(block.LHS);
                if (isSingleIdent)
                {
                    lhs = block.TrimName();
                }
                else
                {
                    lhs = block.LHS;
                }

                // Create the cnontents of the new block. 
                content = lhs + '=' + identNode.Name;

                // Comment Jun: Remove the current codeblock first
                // Codeblock removal is guid dependent
                Node nodeToRemove = statementList.GetNode(node.Guid);
                int index = statementList.nodeList.IndexOf(nodeToRemove);
                statementList.RemoveNode(nodeToRemove);

                // Comment Jun: Create a new block using the current guid
                // This new codeblock represents the new contents
                Block block2 = new Block(content, node.Guid);
                statementList.nodeList.Insert(index, block2);
                statementList.nodeMap.Add(block2.Guid, block2);
                statementList.AddNode(block2);


                // Comment Jun: Reflect the new changes to the original block
                (node as Block).SetData(block2.LHS, content);
            }
        }
开发者ID:ankushraizada,项目名称:Dynamo,代码行数:48,代码来源:TopSort.cs

示例14: BuildIdentToOperatorStatement

        private static void BuildIdentToOperatorStatement(Node node, AST statementList, Node nodeI)
        {
            Assignment a2 = (Assignment)statementList.GetNode(nodeI.Guid);
            Assignment a = new Assignment((IdentNode)node, (IdentNode)a2.left);
            if (statementList.nodeMap.ContainsKey(a.Guid))
            {
                Node nodeToRemove = statementList.GetNode(a.Guid);
                int index = statementList.nodeList.IndexOf(nodeToRemove);
                statementList.RemoveNode(nodeToRemove);

                statementList.nodeList.Insert(index, a);
                statementList.nodeMap.Add(a.Guid, a);
            }
            else
                statementList.AddNode(a);
        }
开发者ID:ankushraizada,项目名称:Dynamo,代码行数:16,代码来源:TopSort.cs

示例15: BuildIdentToIdentStatement

        private static void BuildIdentToIdentStatement(Node node, Node nodeI, AST statementList)
        {
            Assignment a = new Assignment((IdentNode)node, (IdentNode)nodeI);
            if (statementList.nodeMap.ContainsKey(node.Guid))
            {
                Node nodeToRemove = statementList.GetNode(a.Guid);
                int index = statementList.nodeList.IndexOf(nodeToRemove);
                statementList.RemoveNode(nodeToRemove);

                statementList.nodeList.Insert(index, a);
                statementList.nodeMap.Add(a.Guid, a);
            }
            else
                statementList.AddNode(a);
        }
开发者ID:ankushraizada,项目名称:Dynamo,代码行数:15,代码来源:TopSort.cs


注:本文中的GraphToDSCompiler.Node类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。