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(), 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>()));
        }
Exemplo n.º 3
0
        public IReadOnlyList <IMemberDefinition> RootScope(IRootScope co)
        {
            UpdateDefinedBy(co.Scope, OrType.Make <IInternalMethodDefinition, IImplementationDefinition, IEntryPointDefinition, IBlockDefinition, IRootScope, IObjectDefiniton>(co));

            foreach (var item in co.Assignments)
            {
                item.Convert(this);
            }
            co.EntryPoint.Convert(this);

            // this can't have a closure
            return(Array.Empty <IMemberDefinition>());
        }
Exemplo n.º 4
0
        public Nothing RootScope(IRootScope co)
        {
            foreach (var entry in co.Scope.Members.Values.Select(x => x.Value))
            {
                lookup.AddLocal(OrType.Make <IEntryPointDefinition, IImplementationDefinition, IInternalMethodDefinition, IRootScope>(co), entry);
            }
            var next = Push(co);

            next.Walk(co.Assignments);
            co.EntryPoint.Convert(next);

            return(new Nothing());
        }
Exemplo n.º 5
0
 public IInterpetedOperation RootScope(IRootScope co)
 {
     // you do need to do this
     if (backing.TryGetValue(co, out var res))
     {
         return(res);
     }
     else
     {
         var op = new InterpetedRootScope();
         backing.Add(co, op);
         op.Init(
             new InterpetedScopeTemplate(co.Scope, co.Scope.ToVerifiableType()),
             co.Assignments.Select(x => x.Convert(this).CastTo <IInterpetedAssignOperation>()).ToArray(),
             co.EntryPoint.Convert(this).CastTo <InterpetedEntryPointDefinition>());
         return(op);
     }
 }
Exemplo n.º 6
0
 public Project(IRootScope rootScope, IReadOnlyList <TAssembly> references, IFinalizedScope dependencyScope)
 {
     RootScope       = rootScope ?? throw new ArgumentNullException(nameof(rootScope));
     References      = references ?? throw new ArgumentNullException(nameof(references));
     DependencyScope = dependencyScope ?? throw new ArgumentNullException(nameof(dependencyScope));
 }
Exemplo n.º 7
0
        public static TOut BuildAndRun <Tin, TOut>(IRootScope scope, Tin input, IReadOnlyList <Assembly> assemblies)
        {
            var complitation = Build <Tin, TOut>(new Project <Assembly, object>(scope, assemblies, Scope.CreateAndBuild(Array.Empty <IsStatic>())));

            return(complitation.main(input));
        }