public static ITypeOr CreateAndBuild(IVerifiableType left, IVerifiableType right) { var res = new TypeOr(); res.Build(left, right); return(res); }
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()); }
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>()); }
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)); }
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; }
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); }
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)); }
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)); }
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)); }
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)); }
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)); }
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); }
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)); }
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); }
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(); }
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(); }
public static IInterpetedMember <T> Member <T>(IVerifiableType type) where T : IInterpetedAnyType => Root(new Func <IRunTimeAnyRoot, RunTimeAnyRootEntry>[] { MemberIntention <T>(type) }).Has <IInterpetedMember <T> >();
public bool TheyAreUs(IVerifiableType they, bool noTagBacks) { return(Left.TheyAreUs(they, noTagBacks) && Left.TheyAreUs(they, noTagBacks)); }
public bool WeAreThem(IVerifiableType them, bool noTagBacks) { return(Left.WeAreThem(them, noTagBacks) || Left.WeAreThem(them, noTagBacks)); }
public bool TheyAreUs(IVerifiableType they, bool noTagBacks) => SimpleTypeHelp.TheyAreUs <IStringType>(this, they, noTagBacks);
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(); }
public bool TheyAreUs(IVerifiableType they, bool noTagBacks) => true;
public bool WeAreThem(IVerifiableType them, bool noTagBacks) => SimpleTypeHelp.WeAreThem <IAnyType>(this, them, noTagBacks);
public static IImplementationType CreateAndBuild(IVerifiableType inputType, IVerifiableType outputType, IVerifiableType contextType) { var(res, builder) = Create(); builder.Build(inputType, outputType, contextType); return(res); }
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);
public TypeData(IKey key, IVerifiableType type) { Key = key ?? throw new ArgumentNullException(nameof(key)); Type = type ?? throw new ArgumentNullException(nameof(type)); }
public InterpetedMemberDefinition <T> Init(IKey key, IVerifiableType type) { Type = type ?? throw new ArgumentNullException(nameof(type)); Key = key ?? throw new ArgumentNullException(nameof(key)); return(this); }
public void Build(IVerifiableType inputType, IVerifiableType outputType) { InputType = inputType ?? throw new ArgumentNullException(nameof(inputType)); OutputType = outputType ?? throw new ArgumentNullException(nameof(outputType)); }
public RunTimeAnyRootEntry(IInterpetedAnyType interpetedType, IVerifiableType compileTimeType) { InterpetedType = interpetedType ?? throw new ArgumentNullException(nameof(interpetedType)); CompileTimeType = compileTimeType ?? throw new ArgumentNullException(nameof(compileTimeType)); }
// 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); }