Exemplo n.º 1
0
        public PointObject()
        {
            var keyX   = new NameKey("x");
            var localX = MemberDefinition.CreateAndBuild(keyX, new AnyType(), Access.ReadWrite);
            var keyY   = new NameKey("y");
            var localY = MemberDefinition.CreateAndBuild(keyY, new AnyType(), Access.ReadWrite);

            RootScope = Model.Instantiated.RootScope.CreateAndBuild(
                Scope.CreateAndBuild(
                    new List <IsStatic>()
            {
                new IsStatic(MemberDefinition.CreateAndBuild(new NameKey("point"), new AnyType(), Access.ReadWrite), false)
            }),
                new[] {
                AssignOperation.CreateAndBuild(
                    ObjectDefiniton.CreateAndBuild(
                        Scope.CreateAndBuild(
                            new List <IsStatic> {
                    new IsStatic(localX, false),
                    new IsStatic(localY, false)
                }),
                        new IAssignOperation[] {
                    AssignOperation.CreateAndBuild(
                        ConstantNumber.CreateAndBuild(5),
                        MemberReference.CreateAndBuild(localX)),
                    AssignOperation.CreateAndBuild(
                        ConstantNumber.CreateAndBuild(2),
                        MemberReference.CreateAndBuild(localY))
                },
                        InterfaceType.CreateAndBuild(new [] { localX, localY })),
                    MemberReference.CreateAndBuild(MemberDefinition.CreateAndBuild(new NameKey("point"), new AnyType(), Access.ReadWrite)))
            },
                EntryPointDefinition.CreateAndBuild(new EmptyType(), MemberDefinition.CreateAndBuild(new NameKey("input"), new NumberType(), Access.ReadWrite), Scope.CreateAndBuild(Array.Empty <IsStatic>()), Array.Empty <ICodeElement>(), Array.Empty <ICodeElement>()));
        }
Exemplo n.º 2
0
        public PairType()
        {
            var pairTypeNumber =
                InterfaceType.CreateAndBuild(
                    new List <IMemberDefinition> {
                MemberDefinition.CreateAndBuild(new NameKey("x"), new NumberType(), false),
                MemberDefinition.CreateAndBuild(new NameKey("y"), new NumberType(), false)
            });

            var inputKey = new NameKey("input");
            var input    = MemberDefinition.CreateAndBuild(inputKey, new NumberType(), false);

            var methodScope = Scope.CreateAndBuild(new List <Scope.IsStatic> {
                new Scope.IsStatic(input, false)
            });

            var localX = MemberDefinition.CreateAndBuild(new NameKey("x"), new NumberType(), false);
            var localY = MemberDefinition.CreateAndBuild(new NameKey("y"), new NumberType(), false);

            var pairifyKey = new NameKey("pairify");
            var pairify    = MemberDefinition.CreateAndBuild(pairifyKey, MethodType.CreateAndBuild(new NumberType(), pairTypeNumber), false);

            Module = ModuleDefinition.CreateAndBuild(
                Scope.CreateAndBuild(
                    new List <Scope.IsStatic> {
                new Scope.IsStatic(MemberDefinition.CreateAndBuild(pairifyKey, MethodType.CreateAndBuild(new NumberType(), pairTypeNumber), false), false)
            }),
                new ICodeElement[] {
                AssignOperation.CreateAndBuild(
                    MethodDefinition.CreateAndBuild(
                        new NumberType(),
                        pairTypeNumber,
                        input,
                        methodScope,
                        new ICodeElement[] {
                    ReturnOperation.CreateAndBuild(
                        ObjectDefiniton.CreateAndBuild(
                            Scope.CreateAndBuild(
                                new List <Scope.IsStatic> {
                        new Scope.IsStatic(localX, false),
                        new Scope.IsStatic(localY, false)
                    }),
                            new IAssignOperation[] {
                        AssignOperation.CreateAndBuild(
                            MemberReference.CreateAndBuild(input),
                            MemberReference.CreateAndBuild(localX)),
                        AssignOperation.CreateAndBuild(
                            MemberReference.CreateAndBuild(input),
                            MemberReference.CreateAndBuild(localY))
                    }))
                },
                        new ICodeElement[0],
                        false),
                    MemberReference.CreateAndBuild(pairify))
            },
                new NameKey("pair-type"));
        }
Exemplo n.º 3
0
        public PairType()
        {
            var pairTypeNumber =
                InterfaceType.CreateAndBuild(
                    new List <IMemberDefinition> {
                MemberDefinition.CreateAndBuild(new NameKey("x"), new NumberType(), Access.ReadWrite),
                MemberDefinition.CreateAndBuild(new NameKey("y"), new NumberType(), Access.ReadWrite)
            });

            var inputKey = new NameKey("input");
            var input    = MemberDefinition.CreateAndBuild(inputKey, new NumberType(), Access.ReadWrite);

            var methodScope = Scope.CreateAndBuild(new List <IsStatic> {
                new IsStatic(input, false)
            });

            var localX = MemberDefinition.CreateAndBuild(new NameKey("x"), new NumberType(), Access.ReadWrite);
            var localY = MemberDefinition.CreateAndBuild(new NameKey("y"), new NumberType(), Access.ReadWrite);

            var pairifyKey = new NameKey("pairify");
            var pairify    = MemberDefinition.CreateAndBuild(pairifyKey, MethodType.CreateAndBuild(new NumberType(), pairTypeNumber), Access.ReadWrite);

            RootScope = Model.Instantiated.RootScope.CreateAndBuild(
                Scope.CreateAndBuild(
                    new List <IsStatic> {
                new IsStatic(MemberDefinition.CreateAndBuild(pairifyKey, MethodType.CreateAndBuild(new NumberType(), pairTypeNumber), Access.ReadWrite), false)
            }),
                new [] {
                AssignOperation.CreateAndBuild(
                    MethodDefinition.CreateAndBuild(
                        pairTypeNumber,
                        input,
                        methodScope,
                        new ICodeElement[] {
                    ReturnOperation.CreateAndBuild(
                        ObjectDefiniton.CreateAndBuild(
                            Scope.CreateAndBuild(
                                new List <IsStatic> {
                        new IsStatic(localX, false),
                        new IsStatic(localY, false)
                    }),
                            new IAssignOperation[] {
                        AssignOperation.CreateAndBuild(
                            MemberReference.CreateAndBuild(input),
                            MemberReference.CreateAndBuild(localX)),
                        AssignOperation.CreateAndBuild(
                            MemberReference.CreateAndBuild(input),
                            MemberReference.CreateAndBuild(localY))
                    },
                            InterfaceType.CreateAndBuild(new [] { localX, localY })))
                },
                        Array.Empty <ICodeElement>()),
                    MemberReference.CreateAndBuild(pairify))
            },
                EntryPointDefinition.CreateAndBuild(new EmptyType(), MemberDefinition.CreateAndBuild(new NameKey("input"), new NumberType(), Access.ReadWrite), Scope.CreateAndBuild(Array.Empty <IsStatic>()), Array.Empty <ICodeElement>(), Array.Empty <ICodeElement>()));
        }