Beispiel #1
0
        public MirrorPointImplementation()
        {
            var keyX   = new NameKey("x");
            var localX = MemberDefinition.CreateAndBuild(keyX, new AnyType(), false);

            var keyY   = new NameKey("y");
            var localY = MemberDefinition.CreateAndBuild(keyY, new AnyType(), false);

            var contextKey = new NameKey("context");

            var context = MemberDefinition.CreateAndBuild(
                contextKey,
                InterfaceType.CreateAndBuild(
                    Scope.CreateAndBuild(
                        new List <Scope.IsStatic>()
            {
                new Scope.IsStatic(localX, false),
                new Scope.IsStatic(localY, false),
            }).Members),
                false);;

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

            var tempKey = new NameKey("temp");
            var temp    = MemberDefinition.CreateAndBuild(tempKey, new AnyType(), false);

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


            Module = ModuleDefinition.CreateAndBuild(
                Scope.CreateAndBuild(
                    new List <Scope.IsStatic>()
            {
                new Scope.IsStatic(MemberDefinition.CreateAndBuild(new NameKey("mirror"), new AnyType(), false), false)
            }),
                new[] {
                AssignOperation.CreateAndBuild(
                    ImplementationDefinition.CreateAndBuild(
                        new EmptyType(),
                        context,
                        input,
                        implementationScope,
                        new ICodeElement[] {
                    AssignOperation.CreateAndBuild(
                        PathOperation.CreateAndBuild(MemberReference.CreateAndBuild(context), MemberReference.CreateAndBuild(localX)),
                        MemberReference.CreateAndBuild(temp)
                        ),
                    AssignOperation.CreateAndBuild(
                        PathOperation.CreateAndBuild(MemberReference.CreateAndBuild(context), MemberReference.CreateAndBuild(localY)),
                        PathOperation.CreateAndBuild(MemberReference.CreateAndBuild(context), MemberReference.CreateAndBuild(localX))
                        ),
                    AssignOperation.CreateAndBuild(
                        MemberReference.CreateAndBuild(temp),
                        PathOperation.CreateAndBuild(MemberReference.CreateAndBuild(context), MemberReference.CreateAndBuild(localY))
                        )
                },
                        new ICodeElement[0]),
                    MemberReference.CreateAndBuild(MemberDefinition.CreateAndBuild(new NameKey("mirror"), new AnyType(), false)))
            },
                new NameKey("mirror-module"));
        }
        public MirrorPointImplementation()
        {
            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);

            var contextKey = new NameKey("context");

            var context = MemberDefinition.CreateAndBuild(
                contextKey,
                InterfaceType.CreateAndBuild(
                    Scope.CreateAndBuild(
                        new List <IsStatic>()
            {
                new IsStatic(localX, false),
                new IsStatic(localY, false),
            }).Members.Values.Select(x => x.Value).ToList()),
                Access.ReadWrite);;

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

            var tempKey = new NameKey("temp");
            var temp    = MemberDefinition.CreateAndBuild(tempKey, new AnyType(), Access.ReadWrite);

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

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


            RootScope = Model.Instantiated.RootScope.CreateAndBuild(
                Scope.CreateAndBuild(
                    new List <IsStatic>()
            {
                new IsStatic(MemberDefinition.CreateAndBuild(new NameKey("mirror"), new AnyType(), Access.ReadWrite), false)
            }),
                new[] {
                AssignOperation.CreateAndBuild(
                    ImplementationDefinition.CreateAndBuild(
                        new EmptyType(),
                        context,
                        input,
                        implementationScope,
                        new ICodeElement[] {
                    AssignOperation.CreateAndBuild(
                        PathOperation.CreateAndBuild(MemberReference.CreateAndBuild(context), MemberReference.CreateAndBuild(localX)),
                        MemberReference.CreateAndBuild(temp)
                        ),
                    AssignOperation.CreateAndBuild(
                        PathOperation.CreateAndBuild(MemberReference.CreateAndBuild(context), MemberReference.CreateAndBuild(localY)),
                        PathOperation.CreateAndBuild(MemberReference.CreateAndBuild(context), MemberReference.CreateAndBuild(localX))
                        ),
                    AssignOperation.CreateAndBuild(
                        MemberReference.CreateAndBuild(temp),
                        PathOperation.CreateAndBuild(MemberReference.CreateAndBuild(context), MemberReference.CreateAndBuild(localY))
                        )
                },
                        Array.Empty <ICodeElement>(),
                        intermediateScope),
                    MemberReference.CreateAndBuild(MemberDefinition.CreateAndBuild(new NameKey("mirror"), 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>()));
        }