Example #1
0
        public static ITypeOr CreateAndBuild(IVerifiableType left, IVerifiableType right)
        {
            var res = new TypeOr();

            res.Build(left, right);
            return(res);
        }
Example #2
0
 public void Build(IFinalizedScope scope, IReadOnlyList <IAssignOperation> assignments, IEntryPointDefinition entryPoint)
 {
     buildableScope.Set(scope);
     buildableAssignments.Set(assignments);
     buildableEntryPoint.Set(entryPoint);
     type = InterfaceType.CreateAndBuild(scope.Members.Values.Select(x => MemberDefinition.CreateAndBuild(x.Value.Key, x.Value.Type, x.Value.Access)).ToList());
 }
Example #3
0
        internal static IInterpetedMember MakeMember(IVerifiableType type)
        {
            var method = typeof(TypeManager).GetMethods(BindingFlags.Public | BindingFlags.Static).Single(x =>
                                                                                                          x.Name == nameof(Member) && x.IsGenericMethod && x.GetParameters().Count() == 1);
            var made = method.MakeGenericMethod(new Type[] { TypeMap.MapType(type) });

            return(made.Invoke(null, new object[] { type }).Cast <IInterpetedMember>());
        }
Example #4
0
            public InterpetedMember(IVerifiableType verifiableType, T value, IRunTimeAnyRoot root) : base(root)
            {
                if (value == null)
                {
                    throw new ArgumentNullException(nameof(value));
                }

                Value = value;
                this.VerifiableType = verifiableType ?? throw new ArgumentNullException(nameof(verifiableType));
            }
Example #5
0
 public void Build(IVerifiableType inputType, IVerifiableType outputType, IVerifiableType contextType)
 {
     ImplementationInputType  = inputType ?? throw new ArgumentNullException(nameof(inputType));
     ImplementationOutputType = outputType ?? throw new ArgumentNullException(nameof(outputType));
     ContextType     = contextType ?? throw new ArgumentNullException(nameof(contextType));
     MethodInputType = contextType ?? throw new ArgumentNullException(nameof(contextType));
     var(outputMethod, outputMethodBuilder) = MethodType.Create();
     outputMethodBuilder.Build(inputType, outputType);
     MethodOutputType = outputMethod;
 }
Example #6
0
 protected static bool HasMember(IVerifiableType type)
 {
     if (type.SafeIs(out IInterfaceModuleType interfaceModuleType) && interfaceModuleType.Members.Any())
     {
         return(true);
     }
     if (type.SafeIs(out ITypeOr typeOr) && typeOr.Members.Any())
     {
         return(true);
     }
     return(false);
 }
Example #7
0
        public bool WeAreThem(IVerifiableType them, bool noTagBacks)
        {
            if (them is GemericTypeParameterPlacholder otherPlaceHolder)
            {
                return(Key.Equals(otherPlaceHolder.Key));
            }

            if (noTagBacks)
            {
                return(false);
            }

            return(this.WeAreThem(this, true));
        }
Example #8
0
        public bool WeAreThem(IVerifiableType them, bool noTagBacks)
        {
            if (them is IMethodType method)
            {
                return((this as IMethodType).InputType.WeAreThem(method.InputType, false) && (this as IMethodType).OutputType.TheyAreUs(method.OutputType, false));
            }

            if (noTagBacks)
            {
                return(false);
            }

            return(this.WeAreThem(this, true));
        }
Example #9
0
        public static bool WeAreThem <T>(IVerifiableType us, IVerifiableType them, bool noTagBacks)
        {
            if (them is T)
            {
                return(true);
            }

            if (noTagBacks)
            {
                return(false);
            }

            return(them.TheyAreUs(us, true));
        }
Example #10
0
        public static bool TheyAreUs <T>(IVerifiableType us, IVerifiableType they, bool noTagBacks)
        {
            if (they is T)
            {
                return(true);
            }

            if (noTagBacks)
            {
                return(false);
            }

            return(they.WeAreThem(us, true));
        }
Example #11
0
        public bool WeAreThem(IVerifiableType them, bool noTagBacks)
        {
            if (them is IInterfaceType otherObject)
            {
                // we have all their members
                return(otherObject.Members.All(otherMember => Members.Any(member => otherMember.Type.WeAreThem(member.Type, false))));
            }

            if (noTagBacks)
            {
                return(false);
            }

            return(this.WeAreThem(this, true));
        }
Example #12
0
        public void Build(IVerifiableType left, IVerifiableType right)
        {
            if (left == null)
            {
                throw new ArgumentNullException(nameof(left));
            }

            if (right == null)
            {
                throw new ArgumentNullException(nameof(right));
            }

            this.left.Set(left);
            this.right.Set(right);
        }
Example #13
0
        public bool TheyAreUs(IVerifiableType they, bool noTagBacks)
        {
            if (they is IInterfaceType otherObject)
            {
                // they have all our members
                return(Members.All(member => otherObject.Members.Any(otherMember => otherMember.Type.TheyAreUs(member.Type, false))));
            }

            if (noTagBacks)
            {
                return(false);
            }

            return(they.WeAreThem(this, true));
        }
Example #14
0
        public void Build(/*IVerifiableType parent,*/ int index, IVerifiableType constraint)
        {
            //if (parent is null)
            //{
            //    throw new ArgumentNullException(nameof(parent));
            //}

            if (constraint is null)
            {
                throw new ArgumentNullException(nameof(constraint));
            }

            //buildableParent.Set(parent);
            buildableConstraint.Set(constraint);
            buildableIndex.Set(index);
        }
Example #15
0
        public static IConvertableFrontendType <IVerifiableType> MapType(IVerifiableType verifiableType)
        {
            if (verifiableType is INumberType)
            {
                return(PrimitiveTypes.CreateNumberType());
            }
            if (verifiableType is IBooleanType)
            {
                return(PrimitiveTypes.CreateBooleanType());
            }
            if (verifiableType is IStringType)
            {
                return(PrimitiveTypes.CreateStringType());
            }
            if (verifiableType is IBlockType)
            {
                return(PrimitiveTypes.CreateBlockType());
            }
            if (verifiableType is IEmptyType)
            {
                return(PrimitiveTypes.CreateEmptyType());
            }
            if (verifiableType is IAnyType)
            {
                return(PrimitiveTypes.CreateAnyType());
            }
            if (verifiableType is IMethodType method)
            {
                return(PrimitiveTypes.CreateMethodType(
                           MapType(method.InputType),
                           MapType(method.OutputType)
                           ));
            }
            if (verifiableType is IImplementationType implementation)
            {
                return(PrimitiveTypes.CreateImplementationType(
                           MapType(implementation.ContextType),
                           MapType(implementation.InputType),
                           MapType(implementation.OutputType)
                           ));
            }

            throw new NotImplementedException();
        }
Example #16
0
        public static IFrontendType <IVerifiableType> MapType(IVerifiableType verifiableType)
        {
            if (verifiableType is INumberType)
            {
                return(new NumberType());
            }
            if (verifiableType is IBooleanType)
            {
                return(new BooleanType());
            }
            if (verifiableType is IStringType)
            {
                return(new StringType());
            }
            if (verifiableType is IBlockType)
            {
                return(new BlockType());
            }
            if (verifiableType is IEmptyType)
            {
                return(new EmptyType());
            }
            if (verifiableType is IAnyType)
            {
                return(new AnyType());
            }
            if (verifiableType is IMethodType method)
            {
                return(new MethodType(
                           new Box <IOrType <IFrontendType <IVerifiableType>, IError> >(OrType.Make <IFrontendType <IVerifiableType>, IError>(MapType(method.InputType))),
                           new Box <IOrType <IFrontendType <IVerifiableType>, IError> >(OrType.Make <IFrontendType <IVerifiableType>, IError>(MapType(method.OutputType)))
                           ));
            }
            //if (verifiableType is IImplementationType implementation)
            //{
            //    return new ImplementationType(
            //        OrType.Make<IConvertableFrontendType<IVerifiableType>, IError>(MapType(implementation.ContextType)),
            //        OrType.Make<IConvertableFrontendType<IVerifiableType>, IError>(MapType(implementation.InputType)),
            //        OrType.Make<IConvertableFrontendType<IVerifiableType>, IError>(MapType(implementation.OutputType))
            //        );
            //}

            throw new NotImplementedException();
        }
Example #17
0
 public static IInterpetedMember <T> Member <T>(IVerifiableType type)
     where T : IInterpetedAnyType
 => Root(new Func <IRunTimeAnyRoot, RunTimeAnyRootEntry>[] { MemberIntention <T>(type) }).Has <IInterpetedMember <T> >();
Example #18
0
 public bool TheyAreUs(IVerifiableType they, bool noTagBacks)
 {
     return(Left.TheyAreUs(they, noTagBacks) && Left.TheyAreUs(they, noTagBacks));
 }
Example #19
0
 public bool WeAreThem(IVerifiableType them, bool noTagBacks)
 {
     return(Left.WeAreThem(them, noTagBacks) || Left.WeAreThem(them, noTagBacks));
 }
Example #20
0
 public bool TheyAreUs(IVerifiableType they, bool noTagBacks) => SimpleTypeHelp.TheyAreUs <IStringType>(this, they, noTagBacks);
Example #21
0
        public static Type MapType(IVerifiableType verifiableType)
        {
            if (verifiableType is INumberType)
            {
                return(typeof(IBoxedDouble));
            }
            if (verifiableType is IBooleanType)
            {
                return(typeof(IBoxedBool));
            }
            if (verifiableType is IStringType)
            {
                return(typeof(IBoxedString));
            }
            if (verifiableType is IBlockType)
            {
                return(typeof(IInterpedEmpty));
            }
            if (verifiableType is IEmptyType)
            {
                return(typeof(IInterpedEmpty));
            }
            if (verifiableType is IAnyType)
            {
                return(typeof(IInterpetedAnyType));
            }
            if (verifiableType is IModuleType || verifiableType is IInterfaceType || verifiableType is IObjectDefiniton)
            {
                return(typeof(IInterpetedScope));
            }
            if (verifiableType is IImplementationType implementation)
            {
                return(typeof(IInterpetedImplementation <, ,>).MakeGenericType(
                           MapType(implementation.ContextType),
                           MapType(implementation.InputType),
                           MapType(implementation.OutputType)
                           ));
            }
            if (verifiableType is IMethodType method)
            {
                return(typeof(IInterpetedMethod <,>).MakeGenericType(
                           MapType(method.InputType),
                           MapType(method.OutputType)
                           ));
            }
            if (verifiableType is IMemberReferance memberReferance)
            {
                return(MapType(memberReferance.MemberDefinition.Type));
            }
            if (verifiableType is ITypeOr)
            {
                // I am not really sure that is how it works over here...
                // it might just be a any type
                //return typeof(IInterpetedOrType<,>).MakeGenericType(
                //    MapType(orType.Left),
                //    MapType(orType.Right));
                return(typeof(IInterpetedAnyType));
            }

            throw new NotImplementedException();
        }
Example #22
0
 public bool TheyAreUs(IVerifiableType they, bool noTagBacks) => true;
Example #23
0
 public bool WeAreThem(IVerifiableType them, bool noTagBacks) => SimpleTypeHelp.WeAreThem <IAnyType>(this, them, noTagBacks);
Example #24
0
 public static IImplementationType CreateAndBuild(IVerifiableType inputType, IVerifiableType outputType, IVerifiableType contextType)
 {
     var(res, builder) = Create();
     builder.Build(inputType, outputType, contextType);
     return(res);
 }
Example #25
0
 public static Func <IRunTimeAnyRoot, RunTimeAnyRootEntry> MemberIntention <T>(IVerifiableType type, T t)
     where T : IInterpetedAnyType
 // TODO check that IVerifiableType is T
 => root => new RunTimeAnyRootEntry(new InterpetedMember <T>(type, t, root), type);
Example #26
0
 public TypeData(IKey key, IVerifiableType type)
 {
     Key  = key ?? throw new ArgumentNullException(nameof(key));
     Type = type ?? throw new ArgumentNullException(nameof(type));
 }
Example #27
0
 public InterpetedMemberDefinition <T> Init(IKey key, IVerifiableType type)
 {
     Type = type ?? throw new ArgumentNullException(nameof(type));
     Key  = key ?? throw new ArgumentNullException(nameof(key));
     return(this);
 }
Example #28
0
 public void Build(IVerifiableType inputType, IVerifiableType outputType)
 {
     InputType  = inputType ?? throw new ArgumentNullException(nameof(inputType));
     OutputType = outputType ?? throw new ArgumentNullException(nameof(outputType));
 }
Example #29
0
 public RunTimeAnyRootEntry(IInterpetedAnyType interpetedType, IVerifiableType compileTimeType)
 {
     InterpetedType  = interpetedType ?? throw new ArgumentNullException(nameof(interpetedType));
     CompileTimeType = compileTimeType ?? throw new ArgumentNullException(nameof(compileTimeType));
 }
Example #30
0
 // TOOD I am not sure I need to create and build any of these types...
 // good old constructors would do
 public static IMethodType CreateAndBuild(IVerifiableType inputType, IVerifiableType outputType)
 {
     var(x, y) = Create();
     y.Build(inputType, outputType);
     return(x);
 }