コード例 #1
0
        protected NIType DefineGenericOutputFunctionSignature()
        {
            NIFunctionBuilder functionBuilder = PFTypes.Factory.DefineFunction("genericOutput");
            NIType            typeParameter   = Signatures.AddGenericDataTypeParameter(functionBuilder, "TData");

            Signatures.AddOutputParameter(functionBuilder, typeParameter, "out");
            return(functionBuilder.CreateType());
        }
コード例 #2
0
        static AutomaticNodeInsertionTests()
        {
            NIFunctionBuilder signatureBuilder = PFTypes.Factory.DefineFunction("outputOwner");

            Signatures.AddOutputParameter(signatureBuilder, PFTypes.Int32, "owner");
            _outputOwnerSignature = signatureBuilder.CreateType();
            signatureBuilder      = PFTypes.Factory.DefineFunction("outputString");
            Signatures.AddOutputParameter(signatureBuilder, PFTypes.String, "owner");
            _outputOwnerStringSignature = signatureBuilder.CreateType();
            signatureBuilder            = PFTypes.Factory.DefineFunction("stringSlicePassthrough");
            Signatures.AddInputOutputParameter(
                signatureBuilder,
                DataTypes.StringSliceType.CreateImmutableReference(Signatures.AddGenericLifetimeTypeParameter(signatureBuilder, "TLife")),
                "stringSlice");
            _stringSlicePassthroughSignature = signatureBuilder.CreateType();
        }
コード例 #3
0
        public void LifetimeWithLiveVariablesOnMainAndNestedDiagrams_ValidateVariableUsages_TerminateLifetimeNodeHasCorrectInputTerminalCount()
        {
            var signatureBuilder = PFTypes.Factory.DefineFunction("outputString");

            Signatures.AddOutputParameter(signatureBuilder, PFTypes.String, "owner");
            NIType outputOwnerStringSignature = signatureBuilder.CreateType();

            DfirRoot           function     = DfirRoot.Create();
            var                outputString = new FunctionalNode(function.BlockDiagram, outputOwnerStringSignature);
            ExplicitBorrowNode borrow       = new ExplicitBorrowNode(function.BlockDiagram, BorrowMode.Immutable, 1, true, true);

            Wire.Create(function.BlockDiagram, outputString.OutputTerminals[0], borrow.InputTerminals[0]);
            Frame  outerFrame            = Frame.Create(function.BlockDiagram);
            Tunnel outerFrameInputTunnel = CreateInputTunnel(outerFrame);

            Wire.Create(function.BlockDiagram, borrow.OutputTerminals[0], outerFrameInputTunnel.InputTerminals[0]);
            Frame          innerFrame = Frame.Create(outerFrame.Diagram);
            Tunnel         innerFrameInputTunnel = CreateInputTunnel(innerFrame), innerFrameOutputTunnel = CreateOutputTunnel(innerFrame);
            FunctionalNode outerStringToSlice = new FunctionalNode(outerFrame.Diagram, Signatures.StringToSliceType);

            Wire.Create(outerFrame.Diagram, outerFrameInputTunnel.OutputTerminals[0], innerFrameInputTunnel.InputTerminals[0], outerStringToSlice.InputTerminals[0]);
            FunctionalNode innerStringToSlice = new FunctionalNode(innerFrame.Diagram, Signatures.StringToSliceType);

            Wire.Create(innerFrame.Diagram, innerFrameInputTunnel.OutputTerminals[0], innerStringToSlice.InputTerminals[0]);
            Wire.Create(innerFrame.Diagram, innerStringToSlice.OutputTerminals[0], innerFrameOutputTunnel.InputTerminals[0]);
            Tunnel outerFrameOutputTunnel = CreateOutputTunnel(outerFrame);

            Wire.Create(outerFrame.Diagram, outerStringToSlice.OutputTerminals[0], outerFrameOutputTunnel.InputTerminals[0]);
            TerminateLifetimeNode terminateLifetime = new TerminateLifetimeNode(function.BlockDiagram, 1, 1);

            Wire.Create(function.BlockDiagram, outerFrameOutputTunnel.OutputTerminals[0], terminateLifetime.InputTerminals[0]);

            RunSemanticAnalysisUpToValidation(function);

            Assert.AreEqual(2, terminateLifetime.InputTerminals.Count);
        }