Example #1
0
        public void UpdateInputTerminals(int inputTerminalCount)
        {
            AutoBorrowNodeFacade nodeFacade = AutoBorrowNodeFacade.GetNodeFacade(this);
            var immutableReferenceType      = NITypes.Void.CreateImmutableReference();
            int currentInputTerminalCount   = InputTerminals.Count();

            if (currentInputTerminalCount < inputTerminalCount)
            {
                for (; currentInputTerminalCount < inputTerminalCount; ++currentInputTerminalCount)
                {
                    var terminal = CreateTerminal(Direction.Input, immutableReferenceType, "inner lifetime");
                    nodeFacade[terminal] = new SimpleTerminalFacade(terminal, terminal.GetTypeVariableSet().CreateReferenceToNewTypeVariable());
                    MoveTerminalToIndex(terminal, currentInputTerminalCount);
                }
            }
            else if (currentInputTerminalCount > inputTerminalCount)
            {
                int i = currentInputTerminalCount - 1;
                while (i >= 0 && currentInputTerminalCount > inputTerminalCount)
                {
                    Terminal inputTerminal = InputTerminals.ElementAt(i);
                    if (!inputTerminal.IsConnected)
                    {
                        RemoveTerminalAtIndex(inputTerminal.Index);
                        --currentInputTerminalCount;
                    }
                    --i;
                }
            }
        }
Example #2
0
        public void UpdateTerminals(int inputTerminalCount, int outputTerminalCount)
        {
            var immutableReferenceType    = NITypes.Void.CreateImmutableReference();
            int currentInputTerminalCount = InputTerminals.Count();

            if (currentInputTerminalCount < inputTerminalCount)
            {
                for (; currentInputTerminalCount < inputTerminalCount; ++currentInputTerminalCount)
                {
                    var inputTerminal = new NodeTerminal(Direction.Input, immutableReferenceType, "nested scope");
                    InsertComponent(currentInputTerminalCount, inputTerminal);
                }
            }
            else if (currentInputTerminalCount > inputTerminalCount)
            {
                int i = currentInputTerminalCount - 1;
                while (i >= 0 && currentInputTerminalCount > inputTerminalCount)
                {
                    Terminal inputTerminal = InputTerminals.ElementAt(i);
                    if (!inputTerminal.Connected)
                    {
                        RemoveComponent(inputTerminal);
                        --currentInputTerminalCount;
                    }
                    --i;
                }
            }

            int currentOutputTerminalCount = OutputTerminals.Count();

            if (currentOutputTerminalCount < outputTerminalCount)
            {
                for (; currentOutputTerminalCount < outputTerminalCount; ++currentOutputTerminalCount)
                {
                    var outputTerminal = new NodeTerminal(Direction.Output, immutableReferenceType, "outer scope");
                    InsertComponent(currentInputTerminalCount + currentOutputTerminalCount, outputTerminal);
                }
            }
            else if (currentOutputTerminalCount > outputTerminalCount)
            {
                int i = currentOutputTerminalCount - 1;
                while (i >= 0 && currentOutputTerminalCount > outputTerminalCount)
                {
                    Terminal outputTerminal = OutputTerminals.ElementAt(i);
                    if (!outputTerminal.Connected)
                    {
                        RemoveComponent(outputTerminal);
                        --currentOutputTerminalCount;
                    }
                    --i;
                }
            }

            SetIconViewGeometry();
        }