Ejemplo n.º 1
0
        public void Assign_To_FieldOperand_Test()
        {
            var typeName        = Guid.NewGuid().ToString("N");
            var methodName1     = Guid.NewGuid().ToString("N");
            var fieldName1		= Guid.NewGuid().ToString("N");

            var assembly = new AssemblyLambda().Assembly();
            {
                var module = assembly.Module();
                {
                    var type = module.Class(typeName);
                    {
                        var field1 = type.Public.Field(typeof(string), "field1");

                        var method1 = type.Public.Method(methodName1);
                        {
                            method1.AssignValue(field1, "Junil Um");

                            var consolewrite = typeof(Console).GetMethod("WriteLine", new Type[] { typeof(string) });
                            method1.Call(consolewrite, field1);

                            method1.Return();
                        };
                    };

                    var releaseType = type.ReleaseType();

                    var obj = Activator.CreateInstance(releaseType);
                    releaseType.GetMethod(methodName1).Invoke(obj, null);
                };
            };

            assembly.AssemblyLambda.Save();
        }
Ejemplo n.º 2
0
        public void Assign_To_FieldOperand_Test()
        {
            var typeName    = Guid.NewGuid().ToString("N");
            var methodName1 = Guid.NewGuid().ToString("N");
            var fieldName1  = Guid.NewGuid().ToString("N");

            var assembly = new AssemblyLambda().Assembly();

            {
                var module = assembly.Module();
                {
                    var type = module.Class(typeName);
                    {
                        var field1 = type.Public.Field(typeof(string), "field1");

                        var method1 = type.Public.Method(methodName1);
                        {
                            method1.AssignValue(field1, "Junil Um");

                            var consolewrite = typeof(Console).GetMethod("WriteLine", new Type[] { typeof(string) });
                            method1.Call(consolewrite, field1);

                            method1.Return();
                        };
                    };

                    var releaseType = type.ReleaseType();

                    var obj = Activator.CreateInstance(releaseType);
                    releaseType.GetMethod(methodName1).Invoke(obj, null);
                };
            };

            assembly.AssemblyLambda.Save();
        }
Ejemplo n.º 3
0
        public void Assign_To_LocalOperand_Test()
        {
            var typeName        = Guid.NewGuid().ToString("N");
            var methodName1     = Guid.NewGuid().ToString("N");
            var methodName2     = Guid.NewGuid().ToString("N");
            var localFieldName1 = Guid.NewGuid().ToString("N");
            var localFieldName2 = Guid.NewGuid().ToString("N");

            var assembly = new AssemblyLambda().Assembly();

            {
                var module = assembly.Module();
                {
                    var type = module.Class(typeName);
                    {
                        var method1 = type.Public.Static.Method(methodName1);
                        {
                            var local1 = method1.Local(typeof(int), localFieldName1);
                            var local2 = method1.Local(typeof(int), localFieldName2);

                            method1.AssignValue(local1, 255);
                            method1.Assign(local2, local1);

                            var consolewrite = typeof(Console).GetMethod("WriteLine", new Type[] { typeof(int) });
                            method1.Call(consolewrite, local1);

                            method1.Return();
                        }

                        var method2 = type.Public.Static.Method(methodName2);
                        {
                            var local1 = method2.Local(typeof(string), localFieldName1);

                            method2.AssignValue(local1, "Junil Um");

                            var consolewrite = typeof(Console).GetMethod("WriteLine", new Type[] { typeof(string) });
                            method2.Call(consolewrite, local1);

                            method2.Return();
                        }
                    }

                    var releaseType = type.ReleaseType();

                    releaseType.GetMethod(methodName1).Invoke(null, null);
                    releaseType.GetMethod(methodName2).Invoke(null, null);
                }
            }

            assembly.AssemblyLambda.Save();
        }
Ejemplo n.º 4
0
        public void Assign_To_LocalOperand_Test()
        {
            var typeName        = Guid.NewGuid().ToString("N");
            var methodName1     = Guid.NewGuid().ToString("N");
            var methodName2     = Guid.NewGuid().ToString("N");
            var localFieldName1 = Guid.NewGuid().ToString("N");
            var localFieldName2 = Guid.NewGuid().ToString("N");

            var assembly = new AssemblyLambda().Assembly();
            {
                var module = assembly.Module();
                {
                    var type = module.Class(typeName);
                    {
                        var method1 = type.Public.Static.Method(methodName1);
                        {
                            var local1 = method1.Local(typeof(int), localFieldName1);
                            var local2 = method1.Local(typeof(int), localFieldName2);

                            method1.AssignValue(local1, 255);
                            method1.Assign(local2, local1);

                            var consolewrite = typeof(Console).GetMethod("WriteLine", new Type[] { typeof(int) });
                            method1.Call(consolewrite, local1);

                            method1.Return();
                        }

                        var method2 = type.Public.Static.Method(methodName2);
                        {
                            var local1 = method2.Local(typeof(string), localFieldName1);

                            method2.AssignValue(local1, "Junil Um");

                            var consolewrite = typeof(Console).GetMethod("WriteLine", new Type[] { typeof(string) });
                            method2.Call(consolewrite, local1);

                            method2.Return();
                        }
                    }

                    var releaseType = type.ReleaseType();

                    releaseType.GetMethod(methodName1).Invoke(null, null);
                    releaseType.GetMethod(methodName2).Invoke(null, null);
                }
            }

            assembly.AssemblyLambda.Save();
        }
Ejemplo n.º 5
0
        public void Property_GetSet_Test()
        {
            var typeName = Guid.NewGuid().ToString("N");

            var assembly = new AssemblyLambda().Assembly();
            {
                var module = assembly.Module();
                {
                    var type = module.Public.Class(typeName);
                    {
                        type.Public.Property(typeof(string), "Name").GetSet();
                    }

                    type.ReleaseType();
                }
            }

            assembly.AssemblyLambda.Save();
        }
Ejemplo n.º 6
0
        public void Property_GetSet_Test()
        {
            var typeName = Guid.NewGuid().ToString("N");

            var assembly = new AssemblyLambda().Assembly();

            {
                var module = assembly.Module();
                {
                    var type = module.Public.Class(typeName);
                    {
                        type.Public.Property(typeof(string), "Name").GetSet();
                    }

                    type.ReleaseType();
                }
            }

            assembly.AssemblyLambda.Save();
        }
Ejemplo n.º 7
0
        public void Define_Field_Test()
        {
            var typeName    = Guid.NewGuid().ToString("N");
            var methodName1 = Guid.NewGuid().ToString("N");
            var fieldName1  = Guid.NewGuid().ToString("N");

            var assembly = new AssemblyLambda().Assembly();
            {
                var module = assembly.Module();
                {
                    var type = module.Class(typeName);
                    {
                        var field1 = type.Public.Field(typeof(string), fieldName1);
                    }

                    var releaseType = type.ReleaseType();

                    int fieldCount = releaseType.GetFields().Length;

                    Assert.IsTrue(fieldCount > 0, "동적 타입에 필드를 1개 생성하였지만 필드의 개수가 {0} 입니다.", fieldCount);
                }
            }
        }
Ejemplo n.º 8
0
        public void Define_Field_Test()
        {
            var typeName    = Guid.NewGuid().ToString("N");
            var methodName1 = Guid.NewGuid().ToString("N");
            var fieldName1  = Guid.NewGuid().ToString("N");

            var assembly = new AssemblyLambda().Assembly();
            {
                var module = assembly.Module();
                {
                    var type = module.Class(typeName);
                    {
                        var field1 = type.Public.Field(typeof(string), fieldName1);
                    }

                    var releaseType = type.ReleaseType();

                    int fieldCount = releaseType.GetFields().Length;

                    Assert.IsTrue(fieldCount > 0, "동적 타입에 필드를 1개 생성하였지만 필드의 개수가 {0} 입니다.", fieldCount);
                }
            }
        }