Exemplo n.º 1
0
        public void LiteralTypeAndConstructorType_Unify_TypeMismatchReported()
        {
            TypeVariableSet       typeVariableSet      = new TypeVariableSet();
            TypeVariableReference literalReference     = typeVariableSet.CreateTypeVariableReferenceFromNIType(NITypes.Int32),
                                  constructorReference = typeVariableSet.CreateTypeVariableReferenceFromNIType(NITypes.Int32.CreateVector());
            var testTypeUnificationResult = new TestTypeUnificationResult();

            typeVariableSet.Unify(constructorReference, literalReference, testTypeUnificationResult);

            Assert.IsTrue(testTypeUnificationResult.TypeMismatch);
        }
Exemplo n.º 2
0
        public void TwoDifferentLiteralTypes_Unify_TypeMismatchReported()
        {
            TypeVariableSet       typeVariableSet   = new TypeVariableSet();
            TypeVariableReference literalReference1 = typeVariableSet.CreateTypeVariableReferenceFromNIType(NITypes.Int32),
                                  literalReference2 = typeVariableSet.CreateTypeVariableReferenceFromNIType(NITypes.Boolean);
            var testTypeUnificationResult           = new TestTypeUnificationResult();

            typeVariableSet.Unify(literalReference2, literalReference1, testTypeUnificationResult);

            Assert.IsTrue(testTypeUnificationResult.TypeMismatch);
        }
Exemplo n.º 3
0
        public void TwoConstructorTypesWithDifferentConstructorNames_Unify_TypeMismatchReported()
        {
            TypeVariableSet       typeVariableSet  = new TypeVariableSet();
            TypeVariableReference constructorType1 = typeVariableSet.CreateReferenceToOptionType(
                typeVariableSet.CreateTypeVariableReferenceFromNIType(NITypes.Int32));
            TypeVariableReference constructorType2 = typeVariableSet.CreateReferenceToLockingCellType(
                typeVariableSet.CreateTypeVariableReferenceFromNIType(NITypes.Int32));
            var typeUnificationResult = new TestTypeUnificationResult();

            typeVariableSet.Unify(constructorType1, constructorType2, typeUnificationResult);

            Assert.IsTrue(typeUnificationResult.TypeMismatch);
        }
Exemplo n.º 4
0
        protected override void VisitNode(Node node)
        {
            TypeVariableSet      typeVariableSet = node.GetTypeVariableSet();
            AutoBorrowNodeFacade nodeFacade      = AutoBorrowNodeFacade.GetNodeFacade(node);
            var primitive    = node as PrimitiveTypeNode;
            var selfTypeNode = node as SelfTypeNode;

            if (primitive != null)
            {
                nodeFacade[primitive.OutputTerminal] = new SimpleTerminalFacade(
                    primitive.OutputTerminal,
                    typeVariableSet.CreateTypeVariableReferenceFromNIType(primitive.Type));
                return;
            }
            if (selfTypeNode != null)
            {
                foreach (Terminal inputTerminal in selfTypeNode.InputTerminals)
                {
                    TypeVariableReference typeVariable = typeVariableSet.CreateReferenceToNewTypeVariable();
                    nodeFacade[inputTerminal] = new SimpleTerminalFacade(inputTerminal, typeVariable);
                }
                return;
            }
            throw new NotSupportedException($"Unsupported node type: {node.GetType().Name}");
        }
Exemplo n.º 5
0
        public void CreateTypeVariableReferenceFromVectorOfCopyType_TypeVariableHasCloneTrait()
        {
            var typeVariableSet = new TypeVariableSet();
            TypeVariableReference vectorType = typeVariableSet.CreateTypeVariableReferenceFromNIType(NITypes.Int32.CreateVector());

            AssertTypeVariableReferenceHasParameterlessTrait(typeVariableSet, vectorType, "Clone");
        }
Exemplo n.º 6
0
            protected override TypeVariableReference ComputeTypeToUnifyWith(VariableReference inputFacadeVariable, out bool setExpectedMutable)
            {
                setExpectedMutable = false;
                TypeVariableReference other = inputFacadeVariable.TypeVariableReference;
                TypeVariableReference u, l;
                bool otherIsMutableReference;
                bool otherIsReference                = TypeVariableSet.TryDecomposeReferenceType(other, out u, out l, out otherIsMutableReference);
                TypeVariableReference underlyingType = otherIsReference ? u : other;

                string typeName = TypeVariableSet.GetTypeName(underlyingType);
                bool   underlyingTypeIsStringSlice = typeName == DataTypes.StringSliceType.GetName(),
                       underlyingTypeIsString      = typeName == NITypes.String.GetName();
                bool inputCoercesToStringSlice     = underlyingTypeIsString || underlyingTypeIsStringSlice;
                bool needsBorrow = !otherIsReference || !underlyingTypeIsStringSlice;
                TypeVariableReference lifetimeType = otherIsReference
                    ? l
                    : TypeVariableSet.CreateReferenceToLifetimeType(_group.BorrowLifetime);

                if (needsBorrow)
                {
                    _stringToSliceNeeded = true;
                    _group.SetBorrowRequired(false);
                }
                // If the input is allowed to coerce to a str, we can unify with str;
                // otherwise, unify with the underlying type to get a type mismatch.
                TypeVariableReference toUnifyUnderlyingType = inputCoercesToStringSlice
                    ? TypeVariableSet.CreateTypeVariableReferenceFromNIType(DataTypes.StringSliceType)
                    : underlyingType;

                return(TypeVariableSet.CreateReferenceToReferenceType(
                           false,
                           toUnifyUnderlyingType,
                           lifetimeType));
            }
Exemplo n.º 7
0
        public void CreateTypeVariableReferenceFromVectorOfNonCopyNonCloneType_TypeVariableDoesNotHaveCloneTrait()
        {
            var typeVariableSet = new TypeVariableSet();
            TypeVariableReference vectorType = typeVariableSet.CreateTypeVariableReferenceFromNIType(DataTypes.FileHandleType.CreateVector());

            AssertTypeVariableReferenceDoesNotHaveParameterlessTrait(typeVariableSet, vectorType, "Clone");
        }
Exemplo n.º 8
0
        public void CreateTypeVariableReferenceFromOptionOfNonCopyType_TypeVariableReferenceDoesNotHaveCopyTrait()
        {
            var typeVariableSet = new TypeVariableSet();
            TypeVariableReference optionType = typeVariableSet.CreateTypeVariableReferenceFromNIType(NITypes.String.CreateOption());

            AssertTypeVariableReferenceDoesNotHaveParameterlessTrait(typeVariableSet, optionType, "Copy");
        }
Exemplo n.º 9
0
        private static void CreateFacadesForInoutReferenceParameter(
            TypeVariableSet typeVariableSet,
            AutoBorrowNodeFacade nodeFacade,
            NIType parameterDataType,
            Terminal inputTerminal,
            Terminal outputTerminal,
            Dictionary <NIType, TypeVariableReference> genericTypeParameters,
            Dictionary <NIType, ReferenceInputTerminalLifetimeGroup> lifetimeFacadeGroups,
            Dictionary <NIType, LifetimeTypeVariableGroup> lifetimeVariableGroups)
        {
            NIType lifetimeType = parameterDataType.GetReferenceLifetimeType();
            bool   isMutable    = parameterDataType.IsMutableReferenceType();
            InputReferenceMutability mutability = parameterDataType.GetInputReferenceMutabilityFromType();
            var lifetimeGroup = lifetimeVariableGroups[lifetimeType];
            ReferenceInputTerminalLifetimeGroup facadeGroup;

            if (!lifetimeFacadeGroups.TryGetValue(lifetimeType, out facadeGroup))
            {
                facadeGroup = nodeFacade.CreateInputLifetimeGroup(mutability, lifetimeGroup.LazyNewLifetime, lifetimeGroup.LifetimeType);
            }
            // TODO: should not add outputTerminal here if borrow cannot be auto-terminated
            // i.e., if there are in-only or out-only parameters that share lifetimeType
            TypeVariableReference referentTypeVariableReference   = typeVariableSet.CreateTypeVariableReferenceFromNIType(parameterDataType.GetReferentType(), genericTypeParameters);
            TypeVariableReference mutabilityTypeVariableReference = mutability == InputReferenceMutability.Polymorphic
                ? genericTypeParameters[parameterDataType.GetReferenceMutabilityType()]
                : default(TypeVariableReference);

            facadeGroup.AddTerminalFacade(inputTerminal, referentTypeVariableReference, mutabilityTypeVariableReference, outputTerminal);
        }
Exemplo n.º 10
0
        public void CreateTypeVariableReferenceFromOptionOfCopyType_TypeVariableReferenceHasCopyTrait()
        {
            var typeVariableSet = new TypeVariableSet();
            TypeVariableReference optionType = typeVariableSet.CreateTypeVariableReferenceFromNIType(NITypes.Int32.CreateOption());

            AssertTypeVariableReferenceHasParameterlessTrait(typeVariableSet, optionType, "Copy");
        }
Exemplo n.º 11
0
            private void InsertStringToSliceAheadOfTerminal(Terminal sliceReceiver, out VariableReference stringReferenceVariable, out Terminal stringReferenceTerminal)
            {
                FunctionalNode stringToSlice                = new FunctionalNode(sliceReceiver.ParentDiagram, Signatures.StringToSliceType);
                Terminal       stringToSliceInput           = stringToSlice.InputTerminals[0],
                               stringToSliceOutput          = stringToSlice.OutputTerminals[0];
                VariableReference sliceReceiverTrueVariable = sliceReceiver.GetTrueVariable();

                TypeVariableSet       typeVariableSet = stringToSliceInput.GetTypeVariableSet();
                TypeVariableReference stringSliceReferenceType = sliceReceiverTrueVariable.TypeVariableReference;
                TypeVariableReference u, lifetime;
                bool m;

                typeVariableSet.TryDecomposeReferenceType(stringSliceReferenceType, out u, out lifetime, out m);
                TypeVariableReference stringReferenceType = typeVariableSet.CreateReferenceToReferenceType(
                    false,
                    typeVariableSet.CreateTypeVariableReferenceFromNIType(NITypes.String),
                    lifetime);

                AutoBorrowNodeFacade stringToSliceFacade = AutoBorrowNodeFacade.GetNodeFacade(stringToSlice);

                stringToSliceFacade[stringToSliceInput]  = new SimpleTerminalFacade(stringToSliceInput, stringReferenceType);
                stringToSliceFacade[stringToSliceOutput] = new SimpleTerminalFacade(stringToSliceOutput, default(TypeVariableReference));

                sliceReceiver.ConnectedTerminal.ConnectTo(stringToSliceInput);
                stringToSliceOutput.WireTogether(sliceReceiver, SourceModelIdSource.NoSourceModelId);

                stringToSliceOutput.GetFacadeVariable().MergeInto(sliceReceiverTrueVariable);
                stringReferenceVariable = stringToSliceInput.GetFacadeVariable();
                stringReferenceTerminal = stringToSliceInput;
            }
Exemplo n.º 12
0
        public void CreateTypeVariableReferenceFromStringSliceType_TypeVariableReferenceHasExpectedTraits()
        {
            var typeVariableSet = new TypeVariableSet();
            TypeVariableReference stringSliceType = typeVariableSet.CreateTypeVariableReferenceFromNIType(DataTypes.StringSliceType);

            AssertTypeVariableReferenceHasParameterlessTrait(typeVariableSet, stringSliceType, "Display");
        }
Exemplo n.º 13
0
        public void CreateTypeVariableReferenceFromSharedType_TypeVariableHasCloneAndDropTraits()
        {
            var typeVariableSet = new TypeVariableSet();
            TypeVariableReference sharedType = typeVariableSet.CreateTypeVariableReferenceFromNIType(NITypes.String.CreateShared());

            AssertTypeVariableReferenceHasParameterlessTrait(typeVariableSet, sharedType, "Clone");
            AssertTypeVariableReferenceHasParameterlessTrait(typeVariableSet, sharedType, "Drop");
        }
Exemplo n.º 14
0
        public void CreateTypeVariableReferenceFromIntegerType_TypeVariableReferenceHasExpectedTraits()
        {
            var typeVariableSet = new TypeVariableSet();
            TypeVariableReference integerType = typeVariableSet.CreateTypeVariableReferenceFromNIType(NITypes.Int32);

            AssertTypeVariableReferenceHasParameterlessTrait(typeVariableSet, integerType, "Display");
            AssertTypeVariableReferenceHasParameterlessTrait(typeVariableSet, integerType, "Clone");
            AssertTypeVariableReferenceHasParameterlessTrait(typeVariableSet, integerType, "Copy");
        }
Exemplo n.º 15
0
        public void CreateTypeVariableReferenceFromBooleanType_TypeVariableReferenceHasExpectedTraits()
        {
            var typeVariableSet = new TypeVariableSet();
            TypeVariableReference booleanType = typeVariableSet.CreateTypeVariableReferenceFromNIType(NITypes.Boolean);

            AssertTypeVariableReferenceHasParameterlessTrait(typeVariableSet, booleanType, "Display");
            AssertTypeVariableReferenceHasParameterlessTrait(typeVariableSet, booleanType, "Clone");
            AssertTypeVariableReferenceHasParameterlessTrait(typeVariableSet, booleanType, "Copy");
        }
Exemplo n.º 16
0
        public void CreateTypeVariableReferenceFromRangeIteratorType_TypeVariableReferenceHasExpectedIteratorTrait()
        {
            var typeVariableSet = new TypeVariableSet();
            TypeVariableReference rangeIteratorType = typeVariableSet.CreateTypeVariableReferenceFromNIType(DataTypes.RangeIteratorType);

            TypeVariableReference iteratorTraitType;

            Assert.IsTrue(typeVariableSet.TryGetImplementedTrait(rangeIteratorType, "Iterator", out iteratorTraitType));
            Assert.IsTrue(typeVariableSet.GetTypeParameters(iteratorTraitType).First().RenderNIType().IsInt32());
        }
Exemplo n.º 17
0
        public static DecomposeStructNode CreateDecomposeStructNodeWithFacades(Diagram parentDiagram, NIType structType)
        {
            var decomposeStructNode              = new DecomposeStructNode(parentDiagram, structType);
            AutoBorrowNodeFacade nodeFacade      = AutoBorrowNodeFacade.GetNodeFacade(decomposeStructNode);
            TypeVariableSet      typeVariableSet = parentDiagram.GetTypeVariableSet();

            foreach (var pair in decomposeStructNode.OutputTerminals.Zip(structType.GetFields()))
            {
                Terminal outputTerminal = pair.Key;
                NIType   elementType    = pair.Value.GetDataType();
                TypeVariableReference elementTypeVariable = typeVariableSet.CreateTypeVariableReferenceFromNIType(elementType);
                nodeFacade[outputTerminal] = new SimpleTerminalFacade(outputTerminal, elementTypeVariable);
            }

            TypeVariableReference structTypeVariable = typeVariableSet.CreateTypeVariableReferenceFromNIType(structType);
            Terminal inputTerminal = decomposeStructNode.InputTerminals[0];

            nodeFacade[inputTerminal] = new SimpleTerminalFacade(inputTerminal, structTypeVariable);
            return(decomposeStructNode);
        }
Exemplo n.º 18
0
        public void LiteralTypeAndTypeVariable_Unify_BothBecomeLiteralType()
        {
            TypeVariableSet       typeVariableSet  = new TypeVariableSet();
            TypeVariableReference literalReference = typeVariableSet.CreateTypeVariableReferenceFromNIType(NITypes.Int32);
            TypeVariableReference typeVariable     = typeVariableSet.CreateReferenceToNewTypeVariable();

            typeVariableSet.Unify(typeVariable, literalReference, new TestTypeUnificationResult());

            Assert.IsTrue(literalReference.RenderNIType().IsInt32());
            Assert.IsTrue(typeVariable.RenderNIType().IsInt32());
        }
Exemplo n.º 19
0
        public void TwoConstructorTypesWithSameConstructorName_Unify_InnerTypesAreUnified()
        {
            TypeVariableSet       typeVariableSet   = new TypeVariableSet();
            TypeVariableReference innerTypeVariable = typeVariableSet.CreateReferenceToNewTypeVariable();
            TypeVariableReference constructorType1  = typeVariableSet.CreateReferenceToOptionType(innerTypeVariable);
            TypeVariableReference constructorType2  = typeVariableSet.CreateReferenceToOptionType(
                typeVariableSet.CreateTypeVariableReferenceFromNIType(NITypes.Int32));

            typeVariableSet.Unify(constructorType1, constructorType2, new TestTypeUnificationResult());

            Assert.IsTrue(innerTypeVariable.RenderNIType().IsInt32());
        }
Exemplo n.º 20
0
        public void TwoTypeVariables_Unify_BothBecomeSingleTypeVariable()
        {
            TypeVariableSet       typeVariableSet  = new TypeVariableSet();
            TypeVariableReference literalReference = typeVariableSet.CreateTypeVariableReferenceFromNIType(NITypes.Int32);
            TypeVariableReference typeVariable1    = typeVariableSet.CreateReferenceToNewTypeVariable(),
                                  typeVariable2    = typeVariableSet.CreateReferenceToNewTypeVariable();

            typeVariableSet.Unify(typeVariable2, typeVariable1, new TestTypeUnificationResult());
            typeVariableSet.Unify(typeVariable1, literalReference, new TestTypeUnificationResult());

            Assert.IsTrue(typeVariable1.RenderNIType().IsInt32());
            Assert.IsTrue(typeVariable2.RenderNIType().IsInt32());
        }
Exemplo n.º 21
0
        public void TypeVariableWithCopyConstraintAndNonCopyableType_Unify_FailedConstraintReported()
        {
            TypeVariableSet       typeVariableSet  = new TypeVariableSet();
            TypeVariableReference literalReference = typeVariableSet.CreateReferenceToReferenceType(
                true,
                typeVariableSet.CreateTypeVariableReferenceFromNIType(NITypes.Int32),
                typeVariableSet.CreateReferenceToLifetimeType(Lifetime.Static));
            var constraint = new SimpleTraitConstraint("Copy");
            TypeVariableReference typeVariable = typeVariableSet.CreateReferenceToNewTypeVariable(constraint.ToEnumerable());
            var testTypeUnificationResult      = new TestTypeUnificationResult();

            typeVariableSet.Unify(typeVariable, literalReference, testTypeUnificationResult);

            Assert.IsTrue(testTypeUnificationResult.FailedConstraints.Contains(constraint));
        }
Exemplo n.º 22
0
        protected override void VisitDfirRoot(DfirRoot dfirRoot)
        {
            base.VisitDfirRoot(dfirRoot);
            _typeVariableSet = dfirRoot.GetTypeVariableSet();
            var variableSet = new VariableSet(_typeVariableSet);

            dfirRoot.SetVariableSet(variableSet);

            int rootDiagramLifetimeId = 0;

            foreach (DataItem dataItem in dfirRoot.DataItems)
            {
                // TODO: eventually we want to reuse each DataItem's variable for its DataAccessors' terminals.
                TypeVariableReference dataTypeVariable = _typeVariableSet.CreateTypeVariableReferenceFromNIType(dataItem.DataType);
                dataItem.SetVariable(variableSet.CreateNewVariable(rootDiagramLifetimeId, dataTypeVariable, true));
            }
        }
Exemplo n.º 23
0
        bool IDfirNodeVisitor <bool> .VisitConstant(Constant constant)
        {
            Terminal valueOutput = constant.OutputTerminals.ElementAt(0);
            TypeVariableReference constantTypeReference;

            if (constant.DataType.IsRebarReferenceType())
            {
                constantTypeReference = _typeVariableSet.CreateReferenceToReferenceType(
                    false,
                    // TODO: this is not always correct; need a more general way of turning NITypes into TypeVariableReferences
                    _typeVariableSet.CreateTypeVariableReferenceFromNIType(constant.DataType.GetReferentType()),
                    // Assume for now that the reference will be in Lifetime.Static
                    _typeVariableSet.CreateReferenceToLifetimeType(Lifetime.Static));
            }
            else
            {
                constantTypeReference = _typeVariableSet.CreateTypeVariableReferenceFromNIType(constant.DataType);
            }
            _nodeFacade[valueOutput] = new SimpleTerminalFacade(valueOutput, constantTypeReference);
            return(true);
        }
        bool IDfirNodeVisitor <bool> .VisitFunctionalNode(FunctionalNode functionalNode)
        {
            int inputIndex = 0, outputIndex = 0;
            var genericTypeParameters  = new Dictionary <NIType, TypeVariableReference>();
            var lifetimeFacadeGroups   = new Dictionary <NIType, ReferenceInputTerminalLifetimeGroup>();
            var lifetimeVariableGroups = new Dictionary <NIType, LifetimeTypeVariableGroup>();

            if (functionalNode.Signature.IsOpenGeneric())
            {
                Func <NIType, TypeVariableReference> createLifetimeTypeReference = type =>
                {
                    var group = LifetimeTypeVariableGroup.CreateFromNode(functionalNode);
                    lifetimeVariableGroups[type] = group;
                    return(group.LifetimeType);
                };
                genericTypeParameters = _typeVariableSet.CreateTypeVariablesForGenericParameters(functionalNode.Signature, createLifetimeTypeReference);
            }

            foreach (NIType parameter in functionalNode.Signature.GetParameters())
            {
                NIType parameterDataType = parameter.GetDataType();
                bool   isInput = parameter.GetInputParameterPassingRule() != NIParameterPassingRule.NotAllowed,
                       isOutput = parameter.GetOutputParameterPassingRule() != NIParameterPassingRule.NotAllowed;
                Terminal inputTerminal = null, outputTerminal = null;
                if (isInput)
                {
                    inputTerminal = functionalNode.InputTerminals[inputIndex];
                    ++inputIndex;
                }
                if (isOutput)
                {
                    outputTerminal = functionalNode.OutputTerminals[outputIndex];
                    ++outputIndex;
                }
                if (isInput && isOutput)
                {
                    if (parameterDataType.IsRebarReferenceType())
                    {
                        CreateFacadesForInoutReferenceParameter(
                            parameterDataType,
                            inputTerminal,
                            outputTerminal,
                            genericTypeParameters,
                            lifetimeFacadeGroups,
                            lifetimeVariableGroups);
                    }
                    else
                    {
                        throw new NotSupportedException("Inout parameters must be reference types.");
                    }
                }
                else if (isOutput)
                {
                    TypeVariableReference typeVariableReference = _typeVariableSet.CreateTypeVariableReferenceFromNIType(parameterDataType, genericTypeParameters);
                    _nodeFacade[outputTerminal] = new SimpleTerminalFacade(outputTerminal, typeVariableReference);
                }
                else if (isInput)
                {
                    if (parameterDataType.IsRebarReferenceType())
                    {
                        CreateFacadesForInoutReferenceParameter(
                            parameterDataType,
                            inputTerminal,
                            null,
                            genericTypeParameters,
                            lifetimeFacadeGroups,
                            lifetimeVariableGroups);
                    }
                    else
                    {
                        TypeVariableReference typeVariableReference = _typeVariableSet.CreateTypeVariableReferenceFromNIType(parameterDataType, genericTypeParameters);
                        _nodeFacade[inputTerminal] = new SimpleTerminalFacade(inputTerminal, typeVariableReference);
                    }
                }
                else
                {
                    throw new NotSupportedException("Parameter is neither input nor output");
                }
            }
            return(true);
        }
Exemplo n.º 25
0
        public static void CreateFacadesForFunctionSignatureNode(this Node node, NIType nodeFunctionSignature)
        {
            int inputIndex = 0, outputIndex = 0;
            var genericTypeParameters  = new Dictionary <NIType, TypeVariableReference>();
            var lifetimeFacadeGroups   = new Dictionary <NIType, ReferenceInputTerminalLifetimeGroup>();
            var lifetimeVariableGroups = new Dictionary <NIType, LifetimeTypeVariableGroup>();

            TypeVariableSet      typeVariableSet = node.GetTypeVariableSet();
            AutoBorrowNodeFacade nodeFacade      = AutoBorrowNodeFacade.GetNodeFacade(node);

            TypeVariableReference[] signatureTypeParameters;
            if (nodeFunctionSignature.IsOpenGeneric())
            {
                Func <NIType, TypeVariableReference> createLifetimeTypeReference = type =>
                {
                    var group = LifetimeTypeVariableGroup.CreateFromNode(node);
                    lifetimeVariableGroups[type] = group;
                    return(group.LifetimeType);
                };
                genericTypeParameters = typeVariableSet.CreateTypeVariablesForGenericParameters(nodeFunctionSignature, createLifetimeTypeReference);

                signatureTypeParameters = nodeFunctionSignature.GetGenericParameters().Select(p => genericTypeParameters[p]).ToArray();
            }
            else
            {
                signatureTypeParameters = new TypeVariableReference[0];
            }
            var functionalNode = node as FunctionalNode;

            if (functionalNode != null)
            {
                functionalNode.FunctionType = new FunctionType(nodeFunctionSignature, signatureTypeParameters);
            }

            foreach (NIType parameter in nodeFunctionSignature.GetParameters())
            {
                NIType parameterDataType = parameter.GetDataType();
                bool   isInput = parameter.GetInputParameterPassingRule() != NIParameterPassingRule.NotAllowed,
                       isOutput = parameter.GetOutputParameterPassingRule() != NIParameterPassingRule.NotAllowed;
                Terminal inputTerminal = null, outputTerminal = null;
                if (isInput)
                {
                    inputTerminal = node.InputTerminals[inputIndex];
                    ++inputIndex;
                }
                if (isOutput)
                {
                    outputTerminal = node.OutputTerminals[outputIndex];
                    ++outputIndex;
                }
                if (isInput && isOutput)
                {
                    if (parameterDataType.IsRebarReferenceType())
                    {
                        CreateFacadesForInoutReferenceParameter(
                            typeVariableSet,
                            nodeFacade,
                            parameterDataType,
                            inputTerminal,
                            outputTerminal,
                            genericTypeParameters,
                            lifetimeFacadeGroups,
                            lifetimeVariableGroups);
                    }
                    else
                    {
                        throw new NotSupportedException("Inout parameters must be reference types.");
                    }
                }
                else if (isOutput)
                {
                    TypeVariableReference typeVariableReference = typeVariableSet.CreateTypeVariableReferenceFromNIType(parameterDataType, genericTypeParameters);
                    nodeFacade[outputTerminal] = new SimpleTerminalFacade(outputTerminal, typeVariableReference);
                }
                else if (isInput)
                {
                    if (parameterDataType.IsRebarReferenceType())
                    {
                        CreateFacadesForInoutReferenceParameter(
                            typeVariableSet,
                            nodeFacade,
                            parameterDataType,
                            inputTerminal,
                            null,
                            genericTypeParameters,
                            lifetimeFacadeGroups,
                            lifetimeVariableGroups);
                    }
                    else
                    {
                        TypeVariableReference typeVariableReference = typeVariableSet.CreateTypeVariableReferenceFromNIType(parameterDataType, genericTypeParameters);
                        nodeFacade[inputTerminal] = new SimpleTerminalFacade(inputTerminal, typeVariableReference);
                    }
                }
                else
                {
                    throw new NotSupportedException("Parameter is neither input nor output");
                }
            }
        }