public void TestDelegate()
        {
            // Create method
            Method delegateMethod = new Method("DelegateMethod")
            {
                Visibility = MemberVisibility.Public
            };

            List <TypeNode> returnTypeNodes = new List <TypeNode>()
            {
                new TypeNode(delegateMethod, TypeSpecifier.FromType <Func <int, string, float> >()),
            };

            for (int i = 0; i < returnTypeNodes.Count; i++)
            {
                delegateMethod.MainReturnNode.AddReturnType();
                GraphUtil.ConnectTypePins(returnTypeNodes[i].OutputTypePins[0], delegateMethod.MainReturnNode.InputTypePins[i]);
            }

            MethodSpecifier delegateMethodSpecifier = new MethodSpecifier("TestMethod",
                                                                          new MethodParameter[]
            {
                new MethodParameter("arg1", TypeSpecifier.FromType <int>(), MethodParameterPassType.Default),
                new MethodParameter("arg2", TypeSpecifier.FromType <string>(), MethodParameterPassType.Default)
            },
                                                                          new BaseType[] { TypeSpecifier.FromType <float>() },
                                                                          MethodModifiers.Static, MemberVisibility.Public,
                                                                          TypeSpecifier.FromType <double>(), Array.Empty <BaseType>());

            // Create nodes
            MakeDelegateNode makeDelegateNode = new MakeDelegateNode(delegateMethod, delegateMethodSpecifier);

            // Connect node execs
            GraphUtil.ConnectExecPins(delegateMethod.EntryNode.InitialExecutionPin, delegateMethod.ReturnNodes.First().ReturnPin);

            // Connect node data
            GraphUtil.ConnectDataPins(makeDelegateNode.OutputDataPins[0], delegateMethod.ReturnNodes.First().InputDataPins[0]);

            string translated = methodTranslator.Translate(delegateMethod, true);
        }
Beispiel #2
0
        public void TestDelegate()
        {
            List <TypeSpecifier> argumentTypes = new List <TypeSpecifier>()
            {
            };

            List <TypeSpecifier> returnTypes = new List <TypeSpecifier>()
            {
                typeof(Func <int, string, float>)
            };

            // Create method
            Method delegateMethod = new Method("DelegateMethod")
            {
                Modifiers = MethodModifiers.Public
            };

            delegateMethod.ArgumentTypes.AddRange(argumentTypes);
            delegateMethod.ReturnTypes.AddRange(returnTypes);

            MethodSpecifier delegateMethodSpecifier = new MethodSpecifier("TestMethod",
                                                                          new BaseType[] { typeof(int), typeof(string) },
                                                                          new BaseType[] { typeof(float) },
                                                                          MethodModifiers.Static,
                                                                          typeof(double),
                                                                          Array.Empty <BaseType>());

            // Create nodes
            MakeDelegateNode makeDelegateNode = new MakeDelegateNode(delegateMethod, delegateMethodSpecifier);

            // Connect node execs
            GraphUtil.ConnectExecPins(delegateMethod.EntryNode.InitialExecutionPin, delegateMethod.ReturnNode.ReturnPin);

            // Connect node data
            GraphUtil.ConnectDataPins(makeDelegateNode.OutputDataPins[0], delegateMethod.ReturnNode.InputDataPins[0]);

            string translated = methodTranslator.Translate(delegateMethod);
        }
Beispiel #3
0
        public void TestDelegate()
        {
            List <TypeSpecifier> argumentTypes = new List <TypeSpecifier>()
            {
            };

            List <TypeSpecifier> returnTypes = new List <TypeSpecifier>()
            {
                TypeSpecifier.FromType <Func <int, string, float> >(),
            };

            // Create method
            Method delegateMethod = new Method("DelegateMethod")
            {
                Modifiers = MethodModifiers.Public
            };

            delegateMethod.ArgumentTypes.AddRange(argumentTypes);
            delegateMethod.ReturnTypes.AddRange(returnTypes);

            MethodSpecifier delegateMethodSpecifier = new MethodSpecifier("TestMethod",
                                                                          new Named <BaseType>[] { new Named <BaseType>("arg1", TypeSpecifier.FromType <int>()), new Named <BaseType>("arg2", TypeSpecifier.FromType <string>()) },
                                                                          new BaseType[] { TypeSpecifier.FromType <float>() },
                                                                          MethodModifiers.Static,
                                                                          TypeSpecifier.FromType <double>(),
                                                                          Array.Empty <BaseType>());

            // Create nodes
            MakeDelegateNode makeDelegateNode = new MakeDelegateNode(delegateMethod, delegateMethodSpecifier);

            // Connect node execs
            GraphUtil.ConnectExecPins(delegateMethod.EntryNode.InitialExecutionPin, delegateMethod.ReturnNodes.First().ReturnPin);

            // Connect node data
            GraphUtil.ConnectDataPins(makeDelegateNode.OutputDataPins[0], delegateMethod.ReturnNodes.First().InputDataPins[0]);

            string translated = methodTranslator.Translate(delegateMethod);
        }
 public void TestStringLengthTranslation()
 {
     string translated = methodTranslator.Translate(stringLengthMethod);
 }