Ejemplo n.º 1
0
        public static NIFunctionBuilder DefineMethodType(this string functionName)
        {
            NIFunctionBuilder functionBuilder = NITypes.Factory.DefineFunction(functionName);

            functionBuilder.IsStatic = true;
            return(functionBuilder);
        }
Ejemplo n.º 2
0
        protected NIType DefineGenericOutputFunctionSignature()
        {
            NIFunctionBuilder functionBuilder = NITypes.Factory.DefineFunction("genericOutput");
            NIType            typeParameter   = Signatures.AddGenericDataTypeParameter(functionBuilder, "TData");

            return(functionBuilder.AddOutput(typeParameter, "out").CreateType());
        }
Ejemplo n.º 3
0
        private static NIType AddGenericMutabilityTypeParameter(NIFunctionBuilder functionBuilder, string name)
        {
            var genericTypeParameters = functionBuilder.MakeGenericParameters(name);
            var parameterBuilder      = genericTypeParameters.ElementAt(0);

            SetMutabilityTypeAttribute((NIAttributedBaseBuilder)parameterBuilder);
            return(parameterBuilder.CreateType());
        }
Ejemplo n.º 4
0
        public static NIType AddGenericLifetimeTypeParameter(NIFunctionBuilder functionBuilder, string name)
        {
            var genericTypeParameters = functionBuilder.MakeGenericParameters(name);
            var parameterBuilder      = genericTypeParameters.ElementAt(0);

            DataTypes.SetLifetimeTypeAttribute((NIAttributedBaseBuilder)parameterBuilder);
            return(parameterBuilder.CreateType());
        }
Ejemplo n.º 5
0
        public static NIType AddGenericDataTypeParameter(NIFunctionBuilder functionBuilder, string name, params NITypeBuilder[] constraints)
        {
            var           genericTypeParameters = functionBuilder.MakeGenericParameters(name);
            NITypeBuilder typeBuilder           = genericTypeParameters.ElementAt(0);

            // HACK, but there seems to be no other public way to add constraints to an NITypeBuilder
            List <NITypeBuilder> builderConstraints = (List <NITypeBuilder>)((NIGenericTypeBuilder)typeBuilder).Constraints;

            builderConstraints.AddRange(constraints);

            return(typeBuilder.CreateType());
        }
Ejemplo n.º 6
0
        public void FunctionNodeWithNonGenericSignatureParameterAndIncorrectTypeWired_ValidateVariableUsages_ErrorCreated()
        {
            DfirRoot          dfirRoot             = DfirRoot.Create();
            NIFunctionBuilder signatureTypeBuilder = NITypes.Factory.DefineFunction("NonGenericInput");
            NIType            signatureType        = signatureTypeBuilder.AddInput(NITypes.Int32, "input").CreateType();
            FunctionalNode    functionalNode       = new FunctionalNode(dfirRoot.BlockDiagram, signatureType);

            ConnectConstantToInputTerminal(functionalNode.InputTerminals[0], NITypes.Boolean, false);

            RunSemanticAnalysisUpToValidation(dfirRoot);

            AssertTerminalHasTypeConflictMessage(functionalNode.InputTerminals[0]);
        }
Ejemplo n.º 7
0
        static AutomaticNodeInsertionTests()
        {
            NIFunctionBuilder signatureBuilder = NITypes.Factory.DefineFunction("outputOwner");

            _outputOwnerSignature       = signatureBuilder.AddOutput(NITypes.Int32, "owner").CreateType();
            signatureBuilder            = NITypes.Factory.DefineFunction("outputString");
            _outputOwnerStringSignature = signatureBuilder.AddOutput(NITypes.String, "owner").CreateType();
            signatureBuilder            = NITypes.Factory.DefineFunction("stringSlicePassthrough");
            signatureBuilder.AddInputOutput(
                DataTypes.StringSliceType.CreateImmutableReference(Signatures.AddGenericLifetimeTypeParameter(signatureBuilder, "TLife")),
                "stringSlice");
            _stringSlicePassthroughSignature = signatureBuilder.CreateType();
        }
Ejemplo n.º 8
0
 public static NIFunctionBuilder AddInputOutput(this NIFunctionBuilder functionBuilder, NIType parameterType, string name)
 {
     functionBuilder.DefineParameter(parameterType, name, NIParameterPassingRule.Required, NIParameterPassingRule.Optional);
     return(functionBuilder);
 }
Ejemplo n.º 9
0
 public static void AddInputOutputParameter(NIFunctionBuilder functionBuilder, NIType parameterType, string name)
 {
     functionBuilder.DefineParameter(parameterType, name, NIParameterPassingRule.Required, NIParameterPassingRule.Recommended);
 }