Inheritance: TreeNode
コード例 #1
0
        public BetaBuilderContext <T, T> BuildJoinNode <T>(AlphaBuilderContext <T> context)
            where T : class
        {
            using (_logger.BeginScope($"{nameof(BuildJoinNode)}<{typeof(T).Name}>"))
            {
                var betaSource  = new DummyNode <T>() as ITupleSource <T>;
                var alphaSource = context.CurrentSource as IFactSource <T>;

                _logger.LogDebug($"Creating join node: {typeof(T).Name}");

                var node = new JoinNode <T, T>(betaSource, alphaSource, new BetaCondition <T, T>((x, y) => true));

                return(new RuntimeBetaBuilderContext <T, T>(context.Declaration, node));
            }
        }
コード例 #2
0
ファイル: SchemaReteVisitor.cs プロジェクト: arastoul/NRules
 protected internal override void VisitDummyNode(SchemaBuilder builder, DummyNode node)
 {
     if (builder.IsVisited(node))
     {
         return;
     }
     builder.AddNode(node, ReteNode.Create);
     foreach (var sink in node.Sinks)
     {
         if (!builder.IsVisited(sink))
         {
             builder.AddLink(node, sink);
         }
     }
     base.VisitDummyNode(builder, node);
 }
コード例 #3
0
ファイル: InfoBubbleTests.cs プロジェクト: reddyashish/Dynamo
        public void NodeWarningBarVisibility()
        {
            OpenModel(@"core\Home.dyn");

            var info = "Information";

            // Arrange
            var         dummyNode = new DummyNode();
            DynamoModel model     = GetModel();

            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(dummyNode, 0, 0, true, true));

            NodeViewModel dummyNodeViewModel = ViewModel.CurrentSpaceViewModel.Nodes
                                               .FirstOrDefault(x => x.NodeModel.GUID == dummyNode.GUID);

            NodeModel dummyNodeModel = dummyNodeViewModel.NodeModel;

            if (dummyNodeViewModel.ErrorBubble == null)
            {
                dummyNodeViewModel.ErrorBubble = new InfoBubbleViewModel(ViewModel);
            }

            InfoBubbleViewModel infoBubbleViewModel = dummyNodeViewModel.ErrorBubble;

            ObservableCollection <InfoBubbleDataPacket> nodeMessages = infoBubbleViewModel.NodeMessages;

            // Assert
            Assert.IsFalse(dummyNodeViewModel.NodeWarningBarVisible);

            // Act
            InfoBubbleDataPacket infoBubbleDataPacket = new InfoBubbleDataPacket
                                                        (
                InfoBubbleViewModel.Style.Info,
                new Point(dummyNodeModel.X, dummyNodeModel.Y),
                new Point(dummyNodeModel.X + dummyNodeModel.Width, dummyNodeModel.Y + dummyNodeModel.Height),
                info,
                InfoBubbleViewModel.Direction.Top
                                                        );

            nodeMessages.Add(infoBubbleDataPacket);

            Assert.IsTrue(infoBubbleViewModel.NodeInfoVisible);

            infoBubbleViewModel.DismissMessageCommand.Execute(infoBubbleDataPacket);

            Assert.IsFalse(dummyNodeViewModel.NodeWarningBarVisible);
        }
コード例 #4
0
    public void BlobTest()
    {
        var node   = new DummyNode();
        var loader = new SceneLoader(node);

        loader.Load(new StringReader(blobYaml), "blobtest.yml").Wait();

        SyncObject obj  = node.Objects[0];
        var        task = node.ReadBlob((BlobHandle)obj.GetField("blobtest"));

        task.Wait();
        Blob blob = task.Result;

        byte[] data = File.ReadAllBytes(loadedFile);

        Assert.That(blob.Data.SequenceEqual(data));
    }
コード例 #5
0
ファイル: NodeFactory.cs プロジェクト: zjloscar/Dynamo
        /// <summary>
        ///     Creates and Loads a new NodeModel from its Serialized form, using the node loaders
        ///     registered in this factory. If loading fails, a Dummy Node is produced.
        /// </summary>
        /// <param name="elNode"></param>
        /// <param name="context"></param>
        /// <param name="resolver"></param>
        /// <returns></returns>
        internal NodeModel CreateNodeFromXml(XmlElement elNode, SaveContext context, ElementResolver resolver)
        {
            XmlAttribute typeAttrib = elNode.Attributes["type"];
            string       typeName   = Nodes.Utilities.PreprocessTypeName(typeAttrib.Value);

            Type      type;
            NodeModel node;

            if (ResolveType(typeName, out type) &&
                LoadNodeModelInstanceByType(type, elNode, context, resolver, out node))
            {
                return(node);
            }

            node = new DummyNode(1, 1, typeName, elNode, "", DummyNode.Nature.Deprecated);
            return(node);
        }
コード例 #6
0
ファイル: InfoBubbleTests.cs プロジェクト: reddyashish/Dynamo
        public void CanDismissUserFacingMessages()
        {
            OpenModel(@"core\Home.dyn");

            var info1 = "Dismissed Info 1";

            // Arrange
            var         dummyNode = new DummyNode();
            DynamoModel model     = GetModel();

            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(dummyNode, 0, 0, true, true));

            NodeViewModel dummyNodeViewModel = ViewModel.CurrentSpaceViewModel.Nodes
                                               .FirstOrDefault(x => x.NodeModel.GUID == dummyNode.GUID);

            NodeModel dummyNodeModel = dummyNodeViewModel.NodeModel;

            var topLeft  = new Point(dummyNodeModel.X, dummyNodeModel.Y);
            var botRight = new Point(dummyNodeModel.X + dummyNodeModel.Width, dummyNodeModel.Y + dummyNodeModel.Height);

            if (dummyNodeViewModel.ErrorBubble == null)
            {
                dummyNodeViewModel.ErrorBubble = new InfoBubbleViewModel(ViewModel);
            }

            InfoBubbleViewModel infoBubbleViewModel = dummyNodeViewModel.ErrorBubble;

            // The collection of messages the node receives
            ObservableCollection <InfoBubbleDataPacket> nodeMessages = infoBubbleViewModel.NodeMessages;

            // Act
            InfoBubbleDataPacket infoBubbleDataPacket = new InfoBubbleDataPacket(InfoBubbleViewModel.Style.Info, topLeft, botRight, info1, InfoBubbleViewModel.Direction.Top);

            nodeMessages.Add(infoBubbleDataPacket);

            Assert.AreEqual(1, infoBubbleViewModel.NodeInfoToDisplay.Count);
            Assert.AreEqual(0, infoBubbleViewModel.DismissedMessages.Count);
            Assert.IsTrue(infoBubbleViewModel.NodeInfoVisible);

            infoBubbleViewModel.DismissMessageCommand.Execute(infoBubbleDataPacket);

            // Assert
            Assert.AreEqual(0, infoBubbleViewModel.NodeInfoToDisplay.Count);
            Assert.AreEqual(1, infoBubbleViewModel.DismissedMessages.Count);
            Assert.AreEqual(info1, infoBubbleViewModel.DismissedMessages.First().Message);
        }
コード例 #7
0
        public void WarningShowsWhenSavingWithLinterWarningsOrErrors()
        {
            // Arrange
            var expectedWindowTitle = WpfResources.GraphIssuesOnSave_Title;
            var recivedEvents       = new List <string>();

            ViewModel.SaveWarningOnUnresolvedIssuesShows += delegate(SaveWarningOnUnresolvedIssuesArgs e)
            {
                recivedEvents.Add(e.TaskDialog.Title);
            };

            Mock <LinterExtensionBase> mockLinter = new Mock <LinterExtensionBase>()
            {
                CallBase = true
            };

            SetupMockLinter(mockLinter);

            var startupParams = new StartupParams(Model.AuthenticationManager.AuthProvider,
                                                  Model.PathManager, new ExtensionLibraryLoader(Model), Model.CustomNodeManager,
                                                  Model.GetType().Assembly.GetName().Version, Model.PreferenceSettings, Model.LinterManager);

            mockLinter.Object.InitializeBase(Model.LinterManager);
            mockLinter.Object.Startup(startupParams);
            Model.ExtensionManager.Add(mockLinter.Object);

            OpenDynamoDefinition(Path.Combine(GetTestDirectory(ExecutingDirectory), @"UI/SaveWithIssuesWarning.dyn"));

            var failureNode = new DummyNode();

            Model.ExecuteCommand(new DynamoModel.CreateNodeCommand(failureNode, 0, 0, false, false));

            Model.LinterManager.SetActiveLinter(Model.LinterManager.AvailableLinters
                                                .Where(x => x.Id == mockLinter.Object.UniqueId)
                                                .FirstOrDefault());

            // Act
            failureNode.Name = "NewNodeName";
            Assert.That(Model.LinterManager.RuleEvaluationResults.Count > 0);

            ViewModel.ShowSaveDialogIfNeededAndSaveResult(null);

            // Assert
            Assert.That(recivedEvents.Count == 1);
            Assert.That(recivedEvents.First() == expectedWindowTitle);
        }
コード例 #8
0
 private void addCategoryToRepository(RepositoryNode repository)
 {
     try
     {
         foreach (CategoryInfo category in OfficeApplication.OfficeApplicationProxy.getCategories(repository.Repository.name))
         {
             CategoryNode categoryNode = new CategoryNode(category, repository.Repository);
             repository.Nodes.Add(categoryNode);
             if (category.childs > 0)
             {
                 TreeNode dummyNode = new DummyNode();
                 categoryNode.Nodes.Add(dummyNode);
             }
         }
     }
     catch
     {
     }
 }
コード例 #9
0
 private void addCategory(CategoryNode parentcategoryNode)
 {
     try
     {
         foreach (CategoryInfo category in OfficeApplication.OfficeApplicationProxy.getCategories(parentcategoryNode.Repository.name, parentcategoryNode.Category.UDDI))
         {
             CategoryNode categoryNode = new CategoryNode(category, parentcategoryNode.Repository);
             parentcategoryNode.Nodes.Add(categoryNode);
             if (category.childs > 0)
             {
                 TreeNode dummyNode = new DummyNode();
                 categoryNode.Nodes.Add(dummyNode);
             }
         }
     }
     catch
     {
     }
 }
コード例 #10
0
        public void TestCopyPasteNestedGroup()
        {
            // Arrange
            var nestedGroupTitle = "Nested Group";
            var parentGroupNode  = new DummyNode();
            var nestedGroupNode  = new DummyNode();

            CurrentDynamoModel.CurrentWorkspace.AddAndRegisterNode(parentGroupNode, false);
            CurrentDynamoModel.CurrentWorkspace.AddAndRegisterNode(nestedGroupNode, false);

            // Created nested group
            DynamoSelection.Instance.Selection.Add(nestedGroupNode);
            var nestedGroupId = Guid.NewGuid();
            var nestedGroup   = CurrentDynamoModel.CurrentWorkspace.AddAnnotation(nestedGroupTitle, "A group inside another group", nestedGroupId);

            // Create parent group
            var parentGroup = new AnnotationModel(
                new NodeModel[] { parentGroupNode },
                new NoteModel[] { },
                new AnnotationModel[] { nestedGroup });

            CurrentDynamoModel.CurrentWorkspace.AddAnnotation(parentGroup);

            // Act
            DynamoSelection.Instance.Selection.Add(nestedGroup);
            CurrentDynamoModel.Copy();
            CurrentDynamoModel.Paste();

            var copiedGroups = CurrentDynamoModel.CurrentWorkspace.Annotations
                               .Where(x => x.AnnotationText == nestedGroupTitle);

            var copiedGroup = copiedGroups.Where(x => x.GUID != nestedGroupId);

            // Assert
            Assert.That(parentGroup.Nodes.Contains(nestedGroup));
            Assert.That(CurrentDynamoModel.CurrentWorkspace.Annotations.Count() == 3);
            Assert.That(copiedGroups.Count() == 2);
            Assert.That(copiedGroup.Count() == 1);
            Assert.IsFalse(parentGroup.Nodes.Contains(copiedGroup.FirstOrDefault()));
        }
コード例 #11
0
ファイル: FlowAITest.cs プロジェクト: tsuki-fox/IGCC2017TeamJ
    public void BasisTest()
    {
        Debug.Log("---initial---");

        var basis = new FlowAIBasis();

        var dummy1 = new DummyNode();
        var dummy2 = new DummyNode();
        var dummy3 = new DummyNode();
        var branch = new RandomBranchNode();

        dummy1.duration = 0.5f;
        dummy1.nextNode = branch;

        branch.duration = 0.2f;
        branch.nextNode1 = dummy2;
        branch.nextNode2 = dummy3;

        dummy2.duration = 0.5f;
        dummy2.nextNode = dummy1;

        dummy3.duration = 0.5f;
        dummy3.nextNode = dummy1;

        basis.AddNode(dummy1);
        basis.AddNode(branch);
        basis.AddNode(dummy2);
        basis.AddNode(dummy3);

        basis.entryPointNode.nextNode = dummy1;

        basis.Entry();
        for(int f1=0;f1<30;f1++)
        {
            Debug.Log("\n");
            Debug.LogFormat("---{0}[sec]---", (f1+1) * 0.1f);
            basis.Update(0.1f);
        }
    }
コード例 #12
0
        public void TestADDandSELECT()
        {
            var tataravo = new DummyNode("tataravo");
            var bisavo1  = new DummyNode("bisavo1");
            var bisavo2  = new DummyNode("bisavo2");
            var avo      = new DummyNode("avo");
            var neto     = new DummyNode("neto");

            var tree = new Tree <DummyNode, string>(tataravo);

            tree.AddLeft(bisavo1);
            tree.AddRight(bisavo2);
            tree.SelectLeft();
            tree.AddLeft(avo);
            Assert.AreEqual(tataravo, bisavo1.Root, "O Nó adicionado à esquerda do Root do bisavo1, é foi definido como o atual selecionado.");

            tree.SelectLeft();
            Assert.AreEqual(tree.CurrentSelected, avo, "O Nó adicionado à esquerda não foi selecionado quando chamada a função SelectLeft.");

            tree.AddRight(neto);
            Assert.AreEqual(tree.CurrentSelected.Right, neto, "O Nó neto adicionado à direita, não foi definido na chamado da funçao.");
        }
コード例 #13
0
        public void LinterManagerStoresRuleEvaluationResults()
        {
            // Arrange
            var evaluationResultsBefore = model.LinterManager.RuleEvaluationResults.ToList();

            SetupNodeNameChangedRule(mockRule);

            mockExtension.Object.AddLinterRule(mockRule.Object);

            // Act
            var failureNode = new DummyNode();

            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(failureNode, 0, 0, false, false));

            // When setting a linter as the active linter, that linters Activate() gets called
            // which will initialize the rules using the init function. As we only have one mock rule
            // that checks if the node name is "NewNodeName" no failed evaluation results should be created here.
            model.LinterManager.ActiveLinter = model.LinterManager.AvailableLinters
                                               .Where(x => x.Id == MOCK_GUID)
                                               .FirstOrDefault();

            // Update graph nodes name to trigger the node rule evaluation
            failureNode.Name = "NewNodeName";

            // Assert
            CollectionAssert.IsEmpty(evaluationResultsBefore);
            Assert.That(model.LinterManager.RuleEvaluationResults.Count == 1);
            Assert.That(model.LinterManager.RuleEvaluationResults.
                        Any(x => x.RuleId == MOCK_RULE_ID));

            Assert.That(model.LinterManager.RuleEvaluationResults.
                        Any(x => x is NodeRuleEvaluationResult));

            Assert.That(model.LinterManager.RuleEvaluationResults.
                        Where(x => x is NodeRuleEvaluationResult).
                        Cast <NodeRuleEvaluationResult>().
                        Any(x => x.NodeId == failureNode.GUID.ToString()));
        }
コード例 #14
0
ファイル: ReteNode.cs プロジェクト: arastoul/NRules
 internal static ReteNode Create(DummyNode node)
 {
     return(new ReteNode(node.Id, NodeType.Dummy));
 }
コード例 #15
0
ファイル: Spec.cs プロジェクト: DragonXYZ/cilpe
        internal static void SpecializeMethod(ResidualAssemblyHolder holder, ResidualMethod method)
        {
            Value[] args = method.Arguments;
            PointerValue[] ptrs = method.Pointers;
            MethodBodyBlock mbbDown = holder.AnnotatedHolder[method.AnnotatedMethod];
            MethodBodyBlock mbbUp = new MethodBodyBlock(mbbDown.ReturnType);
            holder.AddMethod(method, mbbUp);

            SpecState state = new SpecState(mbbDown.Variables.Count);
            VariablesHashtable varsHash = new VariablesHashtable();

            int varCount = 0;
            int argCount = 0;
            foreach (Variable varDown in mbbDown.Variables.ParameterMapper)
            {
                state.Pool[varDown] = new Location(varDown.Type);
                Variable varUp;
                if (Annotation.GetValueBTType(method.AnnotatedMethod.ParamVals[varCount++].Val) == BTType.Static)
                {
                    state.Pool[varDown].Val = args[argCount++];
                    varUp = mbbUp.Variables.CreateVar(varDown.Type, VariableKind.Local);
                }
                else
                    varUp = mbbUp.Variables.CreateVar(varDown.Type, VariableKind.Parameter);
                varsHash[new PointerToLocationValue(state.Pool[varDown])] = varUp;
            }
            foreach (Variable varDown in mbbDown.Variables)
                if (! state.Pool.ContainsVar(varDown))
                {
                    state.Pool[varDown] = new Location(varDown.Type);
                    Variable varUp = mbbUp.Variables.CreateVar(varDown.Type, VariableKind.Local);
                    varsHash[new PointerToLocationValue(state.Pool[varDown])] = varUp;
                }

            PointerToNode ptrUpNode = new PointerToNode(mbbUp);
            Node dummyUp = new DummyNode(mbbUp);
            Node upNode = dummyUp;
            for (int i = 0; i < ptrs.Length; i++)
            {
                Type ptrType = ptrs[i].Type;
                Type type = ptrType.GetElementType();
                Variable newVar1 = mbbUp.Variables.CreateVar(ptrType, VariableKind.Parameter);
                Variable newVar2 = mbbUp.Variables.CreateVar(type, VariableKind.Local);
                varsHash[ptrs[i]] = newVar2;

                ptrUpNode = new PointerToNode(ptrUpNode.Node = new LoadVar(newVar1));
                ptrUpNode = new PointerToNode(ptrUpNode.Node = new LoadIndirect(type));
                ptrUpNode = new PointerToNode(ptrUpNode.Node = new StoreVar(newVar2));

                upNode = upNode.Next = new LoadVar(newVar1);
                upNode = upNode.Next = new LoadVar(newVar2);
                upNode = upNode.Next = new StoreIndirect(type);
            }
            upNode.Next = new Leave();
            upNode = dummyUp.Next;
            dummyUp.RemoveFromGraph();

            GraphProcessor graphProc = new GraphProcessor();
            SpecializingVisitor visitor = new SpecializingVisitor(graphProc, holder, mbbUp, state, varsHash);
            visitor.AddTask(mbbDown.Next, ptrUpNode);
            graphProc.Process();
            visitor.SetLastNode(upNode);
        }
コード例 #16
0
        public void VerifyThatOnlyRulesFromActiveLinterGetsEvaluated()
        {
            // Arrange
            var secondLinterExtId = "cddab693-9f38-4a66-a600-a758f2c6c817";
            var secondLinterExt   = new Mock <LinterExtensionBase>()
            {
                CallBase = true
            };

            secondLinterExt.Setup(e => e.UniqueId).Returns(secondLinterExtId);

            var nodeRuleId = "999";
            var nodeRule   = new Mock <NodeLinterRule> {
                CallBase = true
            };

            nodeRule.Setup(r => r.Id).Returns(nodeRuleId);

            SetupNodeNameChangedRule(mockRule);
            SetupNodeNameChangedRule(nodeRule);

            mockExtension.Object.AddLinterRule(mockRule.Object);
            secondLinterExt.Object.AddLinterRule(nodeRule.Object);

            // Act
            // we need to call this to invoke LinterExtensionReady which will add the
            // extension to the LinterManager
            secondLinterExt.Object.InitializeBase(model.LinterManager);
            secondLinterExt.Object.Startup(mockExtension.Object.ReadyParamsRef.StartupParams);
            model.ExtensionManager.Add(secondLinterExt.Object);

            var failureNode = new DummyNode();

            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(failureNode, 0, 0, false, false));

            // First we set the active linter to the mock extension created in SetUp, this will initialize that extension
            // and subscribe everything. Then we change the active linter again but to the mock extension created in this test
            // this is to simulate a change in the active linter and to make sure we are only getting results from the active linter
            // even though two linters have been initialized.
            model.LinterManager.ActiveLinter = model.LinterManager.AvailableLinters
                                               .Where(x => x.Id == MOCK_GUID)
                                               .FirstOrDefault();

            model.LinterManager.ActiveLinter = model.LinterManager.AvailableLinters
                                               .Where(x => x.Id == secondLinterExtId)
                                               .FirstOrDefault();

            failureNode.Name = "NewNodeName";

            // Assert
            Assert.That(model.LinterManager.AvailableLinters.Count == 2);
            Assert.That(model.LinterManager.RuleEvaluationResults.Count == 1);
            Assert.That(model.LinterManager.RuleEvaluationResults.
                        Any(x => x.RuleId == nodeRuleId));

            Assert.That(model.LinterManager.RuleEvaluationResults.
                        Any(x => x is NodeRuleEvaluationResult));

            Assert.That(model.LinterManager.RuleEvaluationResults.
                        Where(x => x is NodeRuleEvaluationResult).
                        Cast <NodeRuleEvaluationResult>().
                        Any(x => x.NodeId == failureNode.GUID.ToString()));
        }
コード例 #17
0
        public void TestBuildContextMenu()
        {
            // Arrange
            var dummyNode = new DummyNode();

            ViewModel.Model.CurrentWorkspace.AddAndRegisterNode(dummyNode, false);

            Assert.That(ViewModel.Model.CurrentWorkspace.Nodes.Contains(dummyNode));

            var dummyNodeViewModel = ViewModel.CurrentSpaceViewModel.Nodes
                                     .FirstOrDefault(x => x.Id == dummyNode.GUID);

            ContextMenu contextMenu = new ContextMenu();

            // Act
            NodeContextMenuBuilder.Build
            (
                contextMenu,
                dummyNodeViewModel,
                new OrderedDictionary()
            );

            // Assert
            List <string> menuItemNames = contextMenu.Items
                                          .OfType <MenuItem>()
                                          .Select(x => x.Header.ToString())
                                          .ToList();

            CollectionAssert.Contains(menuItemNames, Dynamo.Wpf.Properties.Resources.ContextMenuDelete);
            CollectionAssert.Contains(menuItemNames, Dynamo.Wpf.Properties.Resources.ContextMenuGroups);
            CollectionAssert.Contains(menuItemNames, Dynamo.Wpf.Properties.Resources.NodesRunStatus);
            CollectionAssert.Contains(menuItemNames, Dynamo.Wpf.Properties.Resources.NodeContextMenuShowLabels);
            CollectionAssert.Contains(menuItemNames, Dynamo.Wpf.Properties.Resources.NodeContextMenuRenameNode);
            CollectionAssert.Contains(menuItemNames, Dynamo.Wpf.Properties.Resources.NodeContextMenuHelp);

            if (dummyNodeViewModel.ShowsVisibilityToggles)
            {
                CollectionAssert.Contains(menuItemNames, Dynamo.Wpf.Properties.Resources.NodeContextMenuShowLabels);
            }

            if (dummyNodeViewModel.ArgumentLacing != LacingStrategy.Disabled)
            {
                CollectionAssert.Contains(menuItemNames, Dynamo.Wpf.Properties.Resources.ContextMenuLacing);
            }

            if (dummyNodeViewModel.IsInput)
            {
                CollectionAssert.Contains(menuItemNames, Dynamo.Wpf.Properties.Resources.NodeContextMenuIsInput);
            }

            if (dummyNodeViewModel.IsOutput)
            {
                CollectionAssert.Contains(menuItemNames, Dynamo.Wpf.Properties.Resources.NodeContextMenuIsOutput);
            }

            int expectedSeparatorsCount = dummyNodeViewModel.IsInput || dummyNodeViewModel.IsOutput ? 2 : 1;

            List <Separator> separators = contextMenu.Items.OfType <Separator>().ToList();

            Assert.AreEqual(expectedSeparatorsCount, separators.Count);
        }
コード例 #18
0
ファイル: WasmRunnerTests.cs プロジェクト: tana/Mondeto
 public void SetUp()
 {
     node = new DummyNode();
     obj  = node.Objects[node.CreateObject().Result];
 }
コード例 #19
0
 protected internal virtual void VisitDummyNode(TContext context, DummyNode node)
 {
 }
コード例 #20
0
ファイル: InfoBubbleTests.cs プロジェクト: reddyashish/Dynamo
        public void CanAddUserFacingMessagesToNode()
        {
            // Arrange
            OpenModel(@"core\Home.dyn");

            var info1    = "Info 1";
            var warning1 = "Warning 1";
            var error1   = "Error 1";

            var         dummyNode = new DummyNode();
            DynamoModel model     = GetModel();

            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(dummyNode, 0, 0, true, true));

            NodeViewModel dummyNodeViewModel = ViewModel.CurrentSpaceViewModel.Nodes
                                               .FirstOrDefault(x => x.NodeModel.GUID == dummyNode.GUID);

            NodeModel dummyNodeModel = dummyNodeViewModel.NodeModel;

            var topLeft  = new Point(dummyNodeModel.X, dummyNodeModel.Y);
            var botRight = new Point(dummyNodeModel.X + dummyNodeModel.Width, dummyNodeModel.Y + dummyNodeModel.Height);

            if (dummyNodeViewModel.ErrorBubble == null)
            {
                dummyNodeViewModel.ErrorBubble = new InfoBubbleViewModel(ViewModel);
            }

            InfoBubbleViewModel infoBubbleViewModel = dummyNodeViewModel.ErrorBubble;

            // The collection of messages the node receives
            ObservableCollection <InfoBubbleDataPacket> nodeMessages = infoBubbleViewModel.NodeMessages;

            // The collections of messages the node displays to the user
            ObservableCollection <InfoBubbleDataPacket> userFacingInfo     = infoBubbleViewModel.NodeInfoToDisplay;
            ObservableCollection <InfoBubbleDataPacket> userFacingWarnings = infoBubbleViewModel.NodeWarningsToDisplay;
            ObservableCollection <InfoBubbleDataPacket> userFacingErrors   = infoBubbleViewModel.NodeErrorsToDisplay;

            // Act
            Assert.AreEqual(0, userFacingInfo.Count);
            Assert.AreEqual(0, userFacingWarnings.Count);
            Assert.AreEqual(0, userFacingErrors.Count);

            Assert.IsFalse(infoBubbleViewModel.NodeInfoVisible);
            Assert.IsFalse(infoBubbleViewModel.NodeWarningsVisible);
            Assert.IsFalse(infoBubbleViewModel.NodeErrorsVisible);

            nodeMessages.Add(new InfoBubbleDataPacket(InfoBubbleViewModel.Style.Info, topLeft, botRight, info1, InfoBubbleViewModel.Direction.Top));
            nodeMessages.Add(new InfoBubbleDataPacket(InfoBubbleViewModel.Style.Warning, topLeft, botRight, warning1, InfoBubbleViewModel.Direction.Top));
            nodeMessages.Add(new InfoBubbleDataPacket(InfoBubbleViewModel.Style.Error, topLeft, botRight, error1, InfoBubbleViewModel.Direction.Top));

            // Assert
            Assert.AreEqual(1, userFacingInfo.Count);
            Assert.AreEqual(1, userFacingWarnings.Count);
            Assert.AreEqual(1, userFacingErrors.Count);

            Assert.IsTrue(infoBubbleViewModel.NodeInfoVisible);
            Assert.IsTrue(infoBubbleViewModel.NodeWarningsVisible);
            Assert.IsTrue(infoBubbleViewModel.NodeErrorsVisible);

            Assert.IsFalse(infoBubbleViewModel.NodeInfoIteratorVisible);
            Assert.IsFalse(infoBubbleViewModel.NodeWarningsIteratorVisible);
            Assert.IsFalse(infoBubbleViewModel.NodeErrorsIteratorVisible);

            Assert.IsFalse(infoBubbleViewModel.NodeInfoShowMoreButtonVisible);
            Assert.IsFalse(infoBubbleViewModel.NodeWarningsShowMoreButtonVisible);
            Assert.IsFalse(infoBubbleViewModel.NodeErrorsShowMoreButtonVisible);

            Assert.AreEqual(info1, userFacingInfo.First().Message);
            Assert.AreEqual(warning1, userFacingWarnings.First().Message);
            Assert.AreEqual(error1, userFacingErrors.First().Message);
        }
コード例 #21
0
 internal static NodeInfo Create(DummyNode node)
 {
     return(new NodeInfo(NodeType.Dummy, string.Empty));
 }
コード例 #22
0
ファイル: Spec.cs プロジェクト: PlumpMath/cilpe-1
        internal static void SpecializeMethod(ResidualAssemblyHolder holder, ResidualMethod method)
        {
            Value[]         args    = method.Arguments;
            PointerValue[]  ptrs    = method.Pointers;
            MethodBodyBlock mbbDown = holder.AnnotatedHolder[method.AnnotatedMethod];
            MethodBodyBlock mbbUp   = new MethodBodyBlock(mbbDown.ReturnType);

            holder.AddMethod(method, mbbUp);

            SpecState          state    = new SpecState(mbbDown.Variables.Count);
            VariablesHashtable varsHash = new VariablesHashtable();

            int varCount = 0;
            int argCount = 0;

            foreach (Variable varDown in mbbDown.Variables.ParameterMapper)
            {
                state.Pool[varDown] = new Location(varDown.Type);
                Variable varUp;
                if (Annotation.GetValueBTType(method.AnnotatedMethod.ParamVals[varCount++].Val) == BTType.Static)
                {
                    state.Pool[varDown].Val = args[argCount++];
                    varUp = mbbUp.Variables.CreateVar(varDown.Type, VariableKind.Local);
                }
                else
                {
                    varUp = mbbUp.Variables.CreateVar(varDown.Type, VariableKind.Parameter);
                }
                varsHash[new PointerToLocationValue(state.Pool[varDown])] = varUp;
            }
            foreach (Variable varDown in mbbDown.Variables)
            {
                if (!state.Pool.ContainsVar(varDown))
                {
                    state.Pool[varDown] = new Location(varDown.Type);
                    Variable varUp = mbbUp.Variables.CreateVar(varDown.Type, VariableKind.Local);
                    varsHash[new PointerToLocationValue(state.Pool[varDown])] = varUp;
                }
            }

            PointerToNode ptrUpNode = new PointerToNode(mbbUp);
            Node          dummyUp   = new DummyNode(mbbUp);
            Node          upNode    = dummyUp;

            for (int i = 0; i < ptrs.Length; i++)
            {
                Type     ptrType = ptrs[i].Type;
                Type     type    = ptrType.GetElementType();
                Variable newVar1 = mbbUp.Variables.CreateVar(ptrType, VariableKind.Parameter);
                Variable newVar2 = mbbUp.Variables.CreateVar(type, VariableKind.Local);
                varsHash[ptrs[i]] = newVar2;

                ptrUpNode = new PointerToNode(ptrUpNode.Node = new LoadVar(newVar1));
                ptrUpNode = new PointerToNode(ptrUpNode.Node = new LoadIndirect(type));
                ptrUpNode = new PointerToNode(ptrUpNode.Node = new StoreVar(newVar2));

                upNode = upNode.Next = new LoadVar(newVar1);
                upNode = upNode.Next = new LoadVar(newVar2);
                upNode = upNode.Next = new StoreIndirect(type);
            }
            upNode.Next = new Leave();
            upNode      = dummyUp.Next;
            dummyUp.RemoveFromGraph();

            GraphProcessor      graphProc = new GraphProcessor();
            SpecializingVisitor visitor   = new SpecializingVisitor(graphProc, holder, mbbUp, state, varsHash);

            visitor.AddTask(mbbDown.Next, ptrUpNode);
            graphProc.Process();
            visitor.SetLastNode(upNode);
        }
コード例 #23
0
ファイル: ReteBuilderContext.cs プロジェクト: hebert26/NRules
 public ReteBuilderContext(DummyNode dummyNode)
 {
     _declarations = new List<Declaration>();
     BetaSource = dummyNode;
 }
コード例 #24
0
            private void AddTopAndNodesToTree(
                ref Nodes nodes,
                List <SubmoduleNode> submoduleNodes,
                GitModule threadModule,
                SubmoduleInfoResult result)
            {
                // Create tree of SubmoduleFolderNode for each path directory and add input SubmoduleNodes as leaves.

                // Example of (SuperPath + LocalPath).ToPosixPath() for all nodes:
                //
                // C:/code/gitextensions2/Externals/conemu-inside
                // C:/code/gitextensions2/Externals/Git.hub
                // C:/code/gitextensions2/Externals/ICSharpCode.TextEditor
                // C:/code/gitextensions2/Externals/ICSharpCode.TextEditor/gitextensions
                // C:/code/gitextensions2/Externals/ICSharpCode.TextEditor/gitextensions/Externals/conemu-inside
                // C:/code/gitextensions2/Externals/ICSharpCode.TextEditor/gitextensions/Externals/Git.hub
                // C:/code/gitextensions2/Externals/ICSharpCode.TextEditor/gitextensions/Externals/ICSharpCode.TextEditor
                // C:/code/gitextensions2/Externals/ICSharpCode.TextEditor/gitextensions/Externals/NBug
                // C:/code/gitextensions2/Externals/ICSharpCode.TextEditor/gitextensions/GitExtensionsDoc
                // C:/code/gitextensions2/Externals/NBug
                // C:/code/gitextensions2/GitExtensionsDoc
                //
                // What we want to do is first remove the topModule portion, "C:/code/gitextensions2/", and
                // then build our tree by breaking up each path into parts, separated by '/'.
                //
                // Note that when we break up the paths, some parts are just directories, the others are submodule nodes:
                //
                // Externals / ICSharpCode.TextEditor / gitextensions / Externals / Git.hub
                //  folder          submodule             submodule      folder     submodule
                //
                // Input 'nodes' is an array of SubmoduleNodes for all the submodules; now we need to create SubmoduleFolderNodes
                // and insert everything into a tree.

                var topModule = threadModule.GetTopModule();

                // Build a mapping of top-module-relative path to node
                var pathToNodes = new Dictionary <string, Node>();

                // Add existing SubmoduleNodes
                foreach (var node in submoduleNodes)
                {
                    pathToNodes[GetNodeRelativePath(topModule, node)] = node;
                }

                // Create and add missing SubmoduleFolderNodes
                foreach (var node in submoduleNodes)
                {
                    var parts = GetNodeRelativePath(topModule, node).Split(Delimiters.ForwardSlash);
                    for (int i = 0; i < parts.Length - 1; ++i)
                    {
                        var path = string.Join("/", parts.Take(i + 1));
                        if (!pathToNodes.ContainsKey(path))
                        {
                            pathToNodes[path] = new SubmoduleFolderNode(this, parts[i]);
                        }
                    }
                }

                // Now build the tree
                var rootNode    = new DummyNode();
                var nodesInTree = new HashSet <Node>();

                foreach (var node in submoduleNodes)
                {
                    Node parentNode = rootNode;
                    var  parts      = GetNodeRelativePath(topModule, node).Split(Delimiters.ForwardSlash);
                    for (int i = 0; i < parts.Length; ++i)
                    {
                        var path      = string.Join("/", parts.Take(i + 1));
                        var nodeToAdd = pathToNodes[path];

                        // If node is not already in the tree, add it
                        if (!nodesInTree.Contains(nodeToAdd))
                        {
                            parentNode.Nodes.AddNode(nodeToAdd);
                            nodesInTree.Add(nodeToAdd);
                        }

                        parentNode = nodeToAdd;
                    }
                }

                Validates.NotNull(result.TopProject);

                // Add top-module node, and move children of root to it
                var topModuleNode = new SubmoduleNode(
                    this,
                    result.TopProject,
                    result.TopProject.Bold,
                    result.TopProject.Bold ? result.CurrentSubmoduleStatus : null,
                    "",
                    result.TopProject.Path);

                topModuleNode.Nodes.AddNodes(rootNode.Nodes);
                nodes.AddNode(topModuleNode);
            }
コード例 #25
0
        public static MethodBodyBlock Convert(MethodEx method)
        {
            if (!method.IsVerified)
            {
                throw new ConvertionException();
            }
            MethodInfoExtention _method_  = new MethodInfoExtention(method.Method);
            MethodBodyBlock     mainBlock = new MethodBodyBlock(_method_.GetReturnType().type);

            mainBlock.Options["StackTypes"] = new StackTypes();
            Block currentBlock = mainBlock;

            Node[] heads = new Node[method.Count];
            Node[] tails = new Node[method.Count];
            Node   head = null;
            Node   tail = null;
            Node   firstBlock = null;
            Node   lastBlock = null;
            int    iNum, iNumNext;

            Variable[]    locals        = new Variable[method.Locals.Count];
            Variable[]    args          = new Variable[_method_.ArgCount];
            VariablesList methodVarList = mainBlock.Variables;

            for (int i = 0; i < args.Length; i++)
            {
                args[i]      = methodVarList.CreateVar(_method_.GetArgType(i).type, VariableKind.Parameter);
                args[i].Name = "Arg" + i;
//				methodVarList.Add(args[i]);
            }
            for (int i = 0; i < locals.Length; i++)
            {
                locals[i]      = methodVarList.CreateVar(method.Locals[i], VariableKind.Local);
                locals[i].Name = "Loc" + i;
//				methodVarList.Add(locals[i]);
            }

            BlockType nextBlockType;
            int       nextBlockStart = -1;
            int       nextBlockEnd   = 1 << 30;
            int       nextBlockIndex;
            Type      nextCatchBlockType;
            Hashtable tryBlocks    = new Hashtable();
            Hashtable filterBlocks = new Hashtable();
            Stack     blockEnds    = new Stack();

            blockEnds.Push(method.Count);
            FindNextBlockStart(method.EHClauses, out nextBlockType, ref nextBlockStart, ref nextBlockEnd, out nextCatchBlockType, out nextBlockIndex);

            //Nodes and blocks creation, blocks linkage
            for (iNum = 0; iNum < method.Count; iNum++)
            {
                while (iNum == (int)blockEnds.Peek())
                {
                    currentBlock = currentBlock.Parent;
                    blockEnds.Pop();
                }

                firstBlock = null;
                lastBlock  = null;
                Node thisBlock = null;
                while (iNum == nextBlockStart)
                {
                    Block currentBlockOld = currentBlock;

                    switch (nextBlockType)
                    {
                    case BlockType.Try:
                        currentBlock = new ProtectedBlock();
                        break;

                    case BlockType.Catch:
                        currentBlock = new CatchBlock(nextCatchBlockType);
                        break;

                    case BlockType.Finally:
                        currentBlock = new FinallyBlock(false);
                        break;

                    case BlockType.Filter:
                        currentBlock = new FilterBlock();
                        break;

                    case BlockType.FilteredCatch:
                        currentBlock = new UserFilteredBlock();
                        break;
                    }

                    currentBlock.setParent(currentBlockOld);

                    blockEnds.Push(nextBlockEnd);
                    if (thisBlock == null)
                    {
                        thisBlock = firstBlock = currentBlock;
                    }
                    else
                    {
                        thisBlock.Next = currentBlock;
                        thisBlock      = currentBlock;
                    }
                    switch (nextBlockType)
                    {
                    case BlockType.Try:
                        tryBlocks.Add(new Segment(nextBlockStart, nextBlockEnd), thisBlock);
                        break;

                    case BlockType.Filter:
                        filterBlocks.Add(new Segment(nextBlockStart, nextBlockEnd), thisBlock);
                        break;

                    case BlockType.Finally:
                    case BlockType.Catch:
                    {
                        Segment        tryBlockKey = FindProtectedBlock(method.EHClauses, nextBlockIndex);
                        ProtectedBlock tryBlock    = tryBlocks[tryBlockKey] as ProtectedBlock;
                        tryBlock.AddHandler(thisBlock as EHBlock);
                    }       break;

                    case BlockType.FilteredCatch:
                    {
                        Segment        tryBlockKey = FindProtectedBlock(method.EHClauses, nextBlockIndex);
                        ProtectedBlock tryBlock    = tryBlocks[tryBlockKey] as ProtectedBlock;
                        tryBlock.AddHandler(thisBlock as EHBlock);

                        Segment     filterKey   = FindFilterBlock(method.EHClauses, nextBlockIndex);
                        FilterBlock filterBlock = filterBlocks[filterKey] as FilterBlock;
                        (thisBlock as UserFilteredBlock).Filter = filterBlock;
                    }       break;
                    }
                    FindNextBlockStart(method.EHClauses, out nextBlockType, ref nextBlockStart, ref nextBlockEnd, out nextCatchBlockType, out nextBlockIndex);
                }
                lastBlock = thisBlock;

                Instruction i = method[iNum];
                switch (i.Code)
                {
                case InstructionCode.NEG:
                case InstructionCode.NOT:
                {
                    head = tail = new UnaryOp(UnaryOpFromCode(i.Code));
                    /*!*/ head.setParent(currentBlock);
                } break;

                case InstructionCode.ADD:
                case InstructionCode.AND:
                case InstructionCode.CEQ:
                case InstructionCode.CGT:
                case InstructionCode.CLT:
                case InstructionCode.DIV:
                case InstructionCode.MUL:
                case InstructionCode.OR:
                case InstructionCode.REM:
                case InstructionCode.SHL:
                case InstructionCode.SHR:
                case InstructionCode.SUB:
                case InstructionCode.XOR:
                {
                    head = tail = new BinaryOp(BinaryOpFromCode(i.Code), i.OverflowFlag, i.UnsignedFlag);
                    /*!*/ head.setParent(currentBlock);
                } break;

                case InstructionCode.LDC:
                    head = tail = new LoadConst(i.Param);
                    /*!*/ head.setParent(currentBlock);
                    break;

                case InstructionCode.LDARG:
                    head = tail = new LoadVar(args[(int)(i.Param)]);
                    /*!*/ head.setParent(currentBlock);
                    break;

                case InstructionCode.LDLOC:
                    head = tail = new LoadVar(locals[(int)(i.Param)]);
                    /*!*/ head.setParent(currentBlock);
                    break;

                case InstructionCode.LDARGA:
                    head = tail = new LoadVarAddr(args[(int)(i.Param)]);
                    /*!*/ head.setParent(currentBlock);
                    break;

                case InstructionCode.LDLOCA:
                    head = tail = new LoadVarAddr(locals[(int)(i.Param)]);
                    /*!*/ head.setParent(currentBlock);
                    break;

                case InstructionCode.LDIND:
                    head = tail = new LoadIndirect(i.TypeBySuffixOrParam());
                    /*!*/ head.setParent(currentBlock);
                    break;

                case InstructionCode.LDFLD:
                {
                    FieldInfo field = i.Param as FieldInfo;
                    if (field.IsStatic)
                    {
                        head = new RemoveStackTop();
                        /*!*/ head.setParent(currentBlock);
                        //remove the object instance when accessing the static field with LDFLD
                        tail = new LoadField(field);
                        /*!*/ tail.setParent(currentBlock);
                        head.Next = tail;
                    }
                    else
                    {
                        head = tail = new LoadField(field);
                        /*!*/ head.setParent(currentBlock);
                    }
                }       break;

                case InstructionCode.LDFLDA:
                {
                    FieldInfo field = i.Param as FieldInfo;
                    if (field.IsStatic)
                    {
                        head = new RemoveStackTop();
                        /*!*/ head.setParent(currentBlock);
                        tail = new LoadFieldAddr(field);
                        /*!*/ tail.setParent(currentBlock);
                        head.Next = tail;
                    }
                    else
                    {
                        head = tail = new LoadFieldAddr(field);
                        /*!*/ head.setParent(currentBlock);
                    }
                }       break;

                case InstructionCode.LDSFLD:
                    head = tail = new LoadField(i.Param as FieldInfo);
                    /*!*/ head.setParent(currentBlock);
                    break;

                case InstructionCode.LDSFLDA:
                    head = tail = new LoadFieldAddr(i.Param as FieldInfo);
                    /*!*/ head.setParent(currentBlock);
                    break;

                case InstructionCode.LDELEM:
                    head = tail = new LoadElement(i.TypeBySuffixOrParam());
                    /*!*/ head.setParent(currentBlock);
                    break;

                case InstructionCode.LDELEMA:
                    head = tail = new LoadElementAddr(i.TypeBySuffixOrParam());
                    /*!*/ head.setParent(currentBlock);
                    break;

                case InstructionCode.LDOBJ:
                    head = tail = new LoadIndirect(i.Param as Type);
                    /*!*/ head.setParent(currentBlock);
                    break;

                case InstructionCode.SIZEOF:
                    head = tail = new LoadSizeOfValue(i.Param as Type);
                    /*!*/ head.setParent(currentBlock);
                    break;

                case InstructionCode.LDLEN:
                    head = tail = new LoadLength();
                    /*!*/ head.setParent(currentBlock);
                    break;

                case InstructionCode.LDTOKEN:
                    if (i.Param is Type)
                    {
                        head = tail = new LoadConst((i.Param as Type).TypeHandle);
                    }
                    else if (i.Param is MethodBase)
                    {
                        head = tail = new LoadConst((i.Param as MethodBase).MethodHandle);
                    }
                    else if (i.Param is FieldInfo)
                    {
                        head = tail = new LoadConst((i.Param as FieldInfo).FieldHandle);
                    }
                    else
                    {
                        throw new ConvertionException();
                    }
                    /*!*/ head.setParent(currentBlock);
                    break;

                case InstructionCode.LDNULL:
                    head = tail = new LoadConst(null);
                    /*!*/ head.setParent(currentBlock);
                    break;

                case InstructionCode.LDSTR:
                    head = tail = new LoadConst(i.Param);
                    /*!*/ head.setParent(currentBlock);
                    break;

                case InstructionCode.STARG:
                    head = tail = new StoreVar(args[(int)(i.Param)]);
                    /*!*/ head.setParent(currentBlock);
                    break;

                case InstructionCode.STLOC:
                    head = tail = new StoreVar(locals[(int)(i.Param)]);
                    /*!*/ head.setParent(currentBlock);
                    break;

                case InstructionCode.STIND:
                    head = tail = new StoreIndirect(i.TypeBySuffixOrParam());
                    /*!*/ head.setParent(currentBlock);
                    break;

                case InstructionCode.STFLD:
                {
                    FieldInfo field = i.Param as FieldInfo;
                    if (field.IsStatic)
                    {
                        head = new StoreField(field);
                        /*!*/ head.setParent(currentBlock);
                        tail = new RemoveStackTop();
                        /*!*/ tail.setParent(currentBlock);
                        head.Next = tail;
                    }
                    else
                    {
                        head = tail = new StoreField(i.Param as FieldInfo);
                        /*!*/ head.setParent(currentBlock);
                    }
                }       break;

                case InstructionCode.STSFLD:
                    head = tail = new StoreField(i.Param as FieldInfo);
                    /*!*/ head.setParent(currentBlock);
                    break;

                case InstructionCode.STELEM:
                    head = tail = new StoreElement(i.TypeBySuffixOrParam());
                    /*!*/ head.setParent(currentBlock);
                    break;

                case InstructionCode.STOBJ:
                    head = tail = new StoreIndirect(i.Param as Type);
                    /*!*/ head.setParent(currentBlock);
                    break;

                case InstructionCode.CPOBJ:
                    head = new LoadIndirect(i.Param as Type);
                    /*!*/ head.setParent(currentBlock);
                    tail = new StoreIndirect(i.Param as Type);
                    /*!*/ tail.setParent(currentBlock);
                    head.Next = tail;
                    break;

                case InstructionCode.DUP:
                    head = tail = new DuplicateStackTop();
                    /*!*/ head.setParent(currentBlock);
                    break;

                case InstructionCode.CALL:
                    head = tail = new CallMethod(i.Param as MethodBase, false, i.HasTail);
                    /*!*/ head.setParent(currentBlock);
                    break;

                case InstructionCode.CALLVIRT:
                    MethodInfo callee = i.Param as MethodInfo;
                    head = tail = new CallMethod(callee, callee.IsVirtual, i.HasTail);
                    /*!*/ head.setParent(currentBlock);
                    break;

                case InstructionCode.NEWOBJ:
                { ConstructorInfo ctor = i.Param as ConstructorInfo;
                  if (Verifier.IsDelegate(ctor.DeclaringType))
                  {
                      if (Verifier.IsInstanceDispatch(method, iNum))
                      {
                          heads[iNum - 1] = tails[iNum - 1] = null;
                          head            = tail = new CreateDelegate(ctor, method[iNum - 1].Param as MethodInfo, false);
                      }
                      else if (Verifier.IsVirtualDispatch(method, iNum))
                      {
                          heads[iNum - 2] = tails[iNum - 2] = null;
                          heads[iNum - 1] = tails[iNum - 1] = null;
                          head            = tail = new CreateDelegate(ctor, method[iNum - 1].Param as MethodInfo, true);
                      }
                  }
                  else
                  {
                      head = tail = new NewObject(ctor);
                  }
                  /*!*/ head.setParent(currentBlock); }       break;

                case InstructionCode.NEWARR:
                    head = tail = new NewArray(i.Param as Type);
                    /*!*/ head.setParent(currentBlock);
                    break;

                case InstructionCode.INITOBJ:
                    head = tail = new InitValue(i.Param as Type);
                    /*!*/ head.setParent(currentBlock);
                    break;

                case InstructionCode.ISINST:
                    head = tail = new CastClass(i.Param as Type, false);
                    /*!*/ head.setParent(currentBlock);
                    break;

                case InstructionCode.CASTCLASS:
                    head = tail = new CastClass(i.Param as Type, true);
                    /*!*/ head.setParent(currentBlock);
                    break;


                case InstructionCode.BOX:
                    head = tail = new BoxValue(i.Param as Type);
                    /*!*/ head.setParent(currentBlock);
                    break;

                case InstructionCode.UNBOX:
                    head = tail = new UnboxValue(i.Param as Type);
                    /*!*/ head.setParent(currentBlock);
                    break;

                case InstructionCode.CONV:
                    head = tail = new ConvertValue(i.TypeBySuffixOrParam(), i.OverflowFlag, i.UnsignedFlag);
                    /*!*/ head.setParent(currentBlock);
                    break;

                case InstructionCode.POP:
                    head = tail = new RemoveStackTop();
                    /*!*/ head.setParent(currentBlock);
                    break;

                case InstructionCode.BEQ:
                    head = new BinaryOp(BinaryOp.ArithOp.CEQ, false, false);
                    /*!*/ head.setParent(currentBlock);
                    tail = new Branch();
                    /*!*/ tail.setParent(currentBlock);
                    head.Next = tail;
                    break;

                case InstructionCode.BNE:
                    head = new BinaryOp(BinaryOp.ArithOp.CEQ, false, false);
                    /*!*/ head.setParent(currentBlock);
                    tail = new Branch();
                    /*!*/ tail.setParent(currentBlock);
                    head.Next = tail;
                    break;

                case InstructionCode.BGE:
                    if (TypeFixer.IsFloatOrCompatible(i.Stack.Top()))
                    {
                        head = new BinaryOp(BinaryOp.ArithOp.CLT, false, !i.UnsignedFlag);
                    }
                    else
                    {
                        head = new BinaryOp(BinaryOp.ArithOp.CLT, false, i.UnsignedFlag);
                    }
                    tail = new Branch();
                    /*!*/ head.setParent(currentBlock);
                    /*!*/ tail.setParent(currentBlock);
                    head.Next = tail;
                    break;

                case InstructionCode.BGT:
                    head = new BinaryOp(BinaryOp.ArithOp.CGT, false, i.UnsignedFlag);
                    tail = new Branch();
                    /*!*/ head.setParent(currentBlock);
                    /*!*/ tail.setParent(currentBlock);
                    head.Next = tail;
                    break;

                case InstructionCode.BLE:
                    if (TypeFixer.IsFloatOrCompatible(i.Stack.Top()))
                    {
                        head = new BinaryOp(BinaryOp.ArithOp.CGT, false, !i.UnsignedFlag);
                    }
                    else
                    {
                        head = new BinaryOp(BinaryOp.ArithOp.CGT, false, i.UnsignedFlag);
                    }
                    tail = new Branch();
                    /*!*/ head.setParent(currentBlock);
                    /*!*/ tail.setParent(currentBlock);
                    head.Next = tail;
                    break;

                case InstructionCode.BLT:
                    head = new BinaryOp(BinaryOp.ArithOp.CLT, false, i.UnsignedFlag);
                    tail = new Branch();
                    /*!*/ head.setParent(currentBlock);
                    /*!*/ tail.setParent(currentBlock);
                    head.Next = tail;
                    break;

                case InstructionCode.BRTRUE:
                    head = tail = new Branch();
                    /*!*/ head.setParent(currentBlock);
                    break;

                case InstructionCode.BRFALSE:
                    head = tail = new Branch();
                    /*!*/ head.setParent(currentBlock);
                    break;

                case InstructionCode.SWITCH:
                    head = tail = new Switch((i.Param as int[]).Length);
                    /*!*/ head.setParent(currentBlock);
                    break;

                case InstructionCode.BR:
                case InstructionCode.NOP:
                case InstructionCode.BREAK:
                case InstructionCode.LDFTN:                             // Expecting further delegate construction...
                case InstructionCode.LDVIRTFTN:                         //
                    head = tail = new DummyNode();
                    /*!*/ head.setParent(currentBlock);
                    break;

                case InstructionCode.THROW:
                    head = tail = new ThrowException();
                    /*!*/ head.setParent(currentBlock);
                    break;


                case InstructionCode.RET:
                case InstructionCode.ENDFINALLY:
                case InstructionCode.ENDFILTER:
                case InstructionCode.LEAVE:
                    head = tail = new Leave();
                    /*!*/ head.setParent(currentBlock);
                    break;

                default:
                    throw new ConvertionException();
                }
                if (head != null)
                {
                    head.Options["StackTypes"] = i.Stack.Clone() as StackTypes;
                }
                if (head != tail)                //=>   head :: BinaryOp, tail :: Branch
                //||   head :: LoadIndirect, tail :: StoreIndirect
                {
                    if (head is BinaryOp && tail is Branch)
                    {
                        StackTypes stack = i.Stack.Clone() as StackTypes;
                        stack.Pop();
                        stack.Pop();
                        stack.Push(typeof(int));
                        tail.Options["StackTypes"] = stack;
                    }
                    else if (head is LoadIndirect && tail is StoreIndirect)
                    {
                        StackTypes stack = i.Stack.Clone() as StackTypes;
                        TypeEx     type  = stack.Pop();                    //type == S&
                        stack.Push(type.type.GetElementType());
                        tail.Options["StackTypes"] = stack;
                    }
                }
                if (firstBlock != null)
                {
                    lastBlock.Next = head;
                    for (Node n = firstBlock; n != head; n = n.Next)
                    {
                        n.Options["StackTypes"] = i.Stack.Clone() as StackTypes;
                    }
                    head = firstBlock;
                    if (tail == null)
                    {
                        tail = lastBlock;                         //This may occure what the NOP instruction starts some block
                    }
                }
                heads[iNum] = head;
                tails[iNum] = tail;
            }            //for
            mainBlock.Next = heads[0];
            //Control flow linkage
            for (iNum = 0; iNum < method.Count; iNum++)
            {
                if (heads[iNum] == null)
                {
                    throw new ConvertionException();                     //impossible :)
                }
                Instruction i = method[iNum];

                switch (i.Code)
                {
                case InstructionCode.BR:
                case InstructionCode.LEAVE:
                    tails[iNum].Next = heads[(int)i.Param];
                    break;

                case InstructionCode.RET:
                case InstructionCode.ENDFINALLY:
                case InstructionCode.ENDFILTER:
                case InstructionCode.THROW:
                case InstructionCode.RETHROW:
                    break;

                case InstructionCode.BRFALSE:                     //false
                case InstructionCode.BGE:                         //false
                case InstructionCode.BLE:                         //false
                case InstructionCode.BNE:                         //false
                    tails[iNum].Next            = heads[(int)i.Param];
                    (tails[iNum] as Branch).Alt = heads[iNum + 1];
                    break;

                case InstructionCode.BRTRUE:                      //true
                case InstructionCode.BEQ:                         //true
                case InstructionCode.BGT:                         //true
                case InstructionCode.BLT:                         //true
                    tails[iNum].Next            = heads[iNum + 1];
                    (tails[iNum] as Branch).Alt = heads[(int)i.Param];
                    break;

                case InstructionCode.SWITCH:
                    tails[iNum].Next = heads[iNum + 1];
                    Switch node = tails[iNum] as Switch;
                    int[]  alt  = i.Param as int[];
                    for (int j = 0; j < node.Count; j++)
                    {
                        node[j] = heads[alt[j]];
                    }
                    break;

                default:
                    tails[iNum].Next = heads[iNum + 1];
                    break;
                }
            }

            //Removing DummyNodes
            for (iNum = 0; iNum < method.Count; iNum++)
            {
                if (heads[iNum] is DummyNode)
                {
                    Node   dummy = heads[iNum];
                    Node[] prev  = new Node[dummy.PrevArray.Count];
                    for (int j = 0; j < prev.Length; j++)
                    {
                        prev[j] = dummy.PrevArray[j];
                    }
                    for (int j = 0; j < prev.Length; j++)
                    {
                        prev[j].NextArray[prev[j].NextArray.IndexOf(dummy)] = dummy.Next;
                    }
                    dummy.RemoveFromGraph();
                }
            }


            return(mainBlock);
        }