public static void If <T, TT>(this IIsPossibly <T> self, Func <T, TT> func) { if (self is IIsDefinately <T> isYes) { func(isYes.Value); } }
public static IEnumerable <T> AsEnumerable <T>(this IIsPossibly <T> self) { if (self is IIsDefinately <T> definate) { yield return(definate.Value); } }
public static void If <T>(this IIsPossibly <T> self, Action <T> action) { if (self is IIsDefinately <T> isYes) { action(isYes.Value); } }
public static T GetOrThrow <T>(this IIsPossibly <T> self) { if (self is IIsDefinately <T> isYes) { return(isYes.Value); } throw new Exception(); }
public static IIsPossibly <TT> IfIsReturns <T, TT>(this IIsPossibly <T> self, Func <T, IIsPossibly <TT> > func) { if (self is IIsDefinately <T> isYes) { return(func(isYes.Value)); } return(Possibly.IsNot <TT>()); }
public static IIsPossibly <TT> TransformInner <T, TT>(this IIsPossibly <T> self, Func <T, TT> func) { if (self is IIsDefinately <T> isYes) { return(Possibly.Is <TT>(func(isYes.Value))); } return(Possibly.IsNot <TT>()); }
public void Set(T t) { if (t is IIsPossibly <T> && !(t is IIsDefinately <T>)) { throw new ApplicationException(); } this.t = Possibly.Is(t); }
public WeakGenericTypeDefinition( IIsPossibly <NameKey> key, IResolvableScope scope, IIsPossibly <IGenericTypeParameterPlacholder>[] TypeParameterDefinitions) { this.TypeParameterDefinitions = TypeParameterDefinitions ?? throw new ArgumentNullException(nameof(TypeParameterDefinitions)); Key = key ?? throw new ArgumentNullException(nameof(key)); Scope = scope ?? throw new ArgumentNullException(nameof(scope)); }
public WeakGenericTypeDefinition( IIsPossibly <IOrType <NameKey, ImplicitKey> > key, IOrType <HasMembersType, IError> type, IOrType <IGenericTypeParameterPlacholder, IError>[] TypeParameterDefinitions) { this.TypeParameterDefinitions = TypeParameterDefinitions ?? throw new ArgumentNullException(nameof(TypeParameterDefinitions)); Key = key ?? throw new ArgumentNullException(nameof(key)); this.type = type ?? throw new ArgumentNullException(nameof(type)); Scope = type.TransformInner(x => x.weakScope); }
public PopulatableScope(PopulatableScope parent) { if (parent == null) { throw new ArgumentNullException(nameof(parent)); } Parent = Possibly.Is(parent); finalizableScope = new FinalizableScope(this); }
public static IMemberDefinition Convert(IIsPossibly <IWeakTypeReference> Type, IConversionContext context, bool ReadOnly, IKey Key) { var(def, builder) = MemberDefinition.Create(); var buildIntention = Type.GetOrThrow().TypeDefinition.GetOrThrow().GetValue().GetOrThrow().Cast <IConvertable <IVerifiableType> >().GetBuildIntention(context); buildIntention.Build(); builder.Build(Key, buildIntention.Tobuild, ReadOnly); return(def); }
public static IBuildIntention <IVerifiableType> GetBuildIntention(IIsPossibly <IBox <IIsPossibly <IFrontendType> > > TypeDefinition, IConversionContext context) { if (TypeDefinition.GetOrThrow().GetValue().GetOrThrow() is IConvertableFrontendType <IVerifiableType> convertableType) { return(convertableType.GetBuildIntention(context)); } else { throw new Exception("can not be built, type is not convertable"); } }
public static bool IsNot <T>(this IIsPossibly <T> self) { if (self is IIsDefinately <T> ) { return(false); } else { return(true); } }
public static TT IfElseReturn <T, TT>(this IIsPossibly <T> self, Func <T, TT> ifIs, Func <TT> ifNot) { if (self is IIsDefinately <T> isYes) { return(ifIs(isYes.Value)); } else { return(ifNot()); } }
public static IBuildIntention <IMemberDefinition> GetBuildIntention(IIsPossibly <IWeakTypeReference> Type, IConversionContext context, bool ReadOnly, IKey Key) { var(toBuild, maker) = MemberDefinition.Create(); return(new BuildIntention <IMemberDefinition>(toBuild, () => { maker.Build( Key, Type.GetOrThrow().TypeDefinition.GetOrThrow().GetValue().GetOrThrow().ConvertTypeOrThrow(context), ReadOnly); })); }
public static void IfElse <T>(this IIsPossibly <T> self, Action <T> ifIs, Action ifNot) { if (self is IIsDefinately <T> isYes) { ifIs(isYes.Value); } else { ifNot(); } }
public WeakMethodDefinition( IIsPossibly <IWeakTypeReference> outputType, IIsPossibly <IBox <IIsPossibly <IWeakMemberDefinition> > > parameterDefinition, IIsPossibly <IFrontendCodeElement>[] body, IResolvableScope scope, IEnumerable <IIsPossibly <IConvertableFrontendCodeElement <ICodeElement> > > staticInitializers, bool isEntryPoint) : base(scope ?? throw new ArgumentNullException(nameof(scope)), body, staticInitializers) { OutputType = outputType ?? throw new ArgumentNullException(nameof(outputType)); ParameterDefinition = parameterDefinition ?? throw new ArgumentNullException(nameof(parameterDefinition)); IsEntryPoint = isEntryPoint; }
public static bool Is <T>(this IIsPossibly <T> self, out T t) { if (self is IIsDefinately <T> isYes) { t = isYes.Value; return(true); } else { t = default; return(false); } }
public FrontEndOrType( IBox <IOrType <IFrontendType <IVerifiableType>, IError> > left, IBox <IOrType <IFrontendType <IVerifiableType>, IError> > right, IOrType <IReadOnlyList <WeakMemberDefinition>, IError> members, IIsPossibly <IBox <IOrType <IFrontendType <IVerifiableType>, IError> > > input, IIsPossibly <IBox <IOrType <IFrontendType <IVerifiableType>, IError> > > output) { this.left = left ?? throw new ArgumentNullException(nameof(left)); this.right = right ?? throw new ArgumentNullException(nameof(right)); this.members = members ?? throw new ArgumentNullException(nameof(members)); this.input = input ?? throw new ArgumentNullException(nameof(input)); this.output = output ?? throw new ArgumentNullException(nameof(output)); }
public WeakImplementationDefinition( IIsPossibly <IBox <IIsPossibly <IWeakMemberDefinition> > > contextDefinition, IIsPossibly <IBox <IIsPossibly <IWeakMemberDefinition> > > parameterDefinition, IIsPossibly <IWeakTypeReference> outputType, IEnumerable <IIsPossibly <IFrontendCodeElement> > metohdBody, IResolvableScope scope, IEnumerable <IFrontendCodeElement> staticInitializers) { ContextDefinition = contextDefinition ?? throw new ArgumentNullException(nameof(contextDefinition)); OutputType = outputType ?? throw new ArgumentNullException(nameof(outputType)); ParameterDefinition = parameterDefinition ?? throw new ArgumentNullException(nameof(parameterDefinition)); MethodBody = metohdBody ?? throw new ArgumentNullException(nameof(metohdBody)); Scope = scope ?? throw new ArgumentNullException(nameof(scope)); StaticInitialzers = staticInitializers ?? throw new ArgumentNullException(nameof(staticInitializers)); }
public PopulatableScope() { this.Parent = Possibly.IsNot <PopulatableScope>(); finalizableScope = new FinalizableScope(this); // do these really belong here or should they be defined in some sort of 'standard library' // here for now I think TryAddType(new NameKey("int"), new Box <IIsPossibly <IFrontendType> >(Possibly.Is <IFrontendType>(PrimitiveTypes.CreateNumberType()))); TryAddType(new NameKey("string"), new Box <IIsPossibly <IFrontendType> >(Possibly.Is <IFrontendType>(PrimitiveTypes.CreateStringType()))); TryAddType(new NameKey("any"), new Box <IIsPossibly <IFrontendType> >(Possibly.Is <IFrontendType>(PrimitiveTypes.CreateAnyType()))); TryAddType(new NameKey("empty"), new Box <IIsPossibly <IFrontendType> >(Possibly.Is <IFrontendType>(PrimitiveTypes.CreateEmptyType()))); TryAddType(new NameKey("bool"), new Box <IIsPossibly <IFrontendType> >(Possibly.Is <IFrontendType>(PrimitiveTypes.CreateBooleanType()))); TryAddGeneric( new NameKey("method"), new Box <IIsPossibly <IFrontendGenericType> >(Possibly.Is <IFrontendGenericType>(PrimitiveTypes.CreateGenericMethodType()))); TryAddGeneric( new NameKey("implementation"), new Box <IIsPossibly <IFrontendGenericType> >(Possibly.Is <IFrontendGenericType>(PrimitiveTypes.CreateGenericImplementationType()))); }
public WeakReturnOperation(IIsPossibly <IFrontendCodeElement> result) { Result = result; }
public WeakConstantString(IIsPossibly <string> value) { Value = value; }
public WeakConstantNumber(IIsPossibly <double> value) { Value = value; }
public WeakConstantBool(IIsPossibly <bool> value) { Value = value; }
public Type CreateType(IStaticScope parent, IOrType <NameKey, ImplicitKey> key, IConvertTo <Type, IOrType <WeakTypeDefinition, WeakGenericTypeDefinition, Tac.SyntaxModel.Elements.AtomicTypes.IPrimitiveType> > converter, IIsPossibly <Guid> primitive) { var res = new Type(this, key.ToString() !, Possibly.Is(key), converter, primitive, Possibly.IsNot <IInterfaceType>()); IsChildOf(parent, res); HasType(parent, key.SwitchReturns <IKey>(x => x, x => x), res); return(res); }
public WeakTypeDefinition(IResolvableScope scope, IIsPossibly <IKey> key) { Key = key ?? throw new ArgumentNullException(nameof(key)); Scope = scope ?? throw new ArgumentNullException(nameof(scope)); }
public WeakMemberDefinition(bool readOnly, IKey key, IIsPossibly <IWeakTypeReference> type) { Type = type ?? throw new ArgumentNullException(nameof(type)); ReadOnly = readOnly; Key = key ?? throw new ArgumentNullException(nameof(key)); }
// right should have more validation public WeakIfTrueOperation(IIsPossibly <IFrontendCodeElement> left, IIsPossibly <IFrontendCodeElement> right) : base(left, right) { }
private SetUpContext(Tpn.TypeProblem2.Builder typeProblem, IIsPossibly <ISetUpContext> parent, IIsPossibly <ISetUp> enclosingSetUp) { TypeProblem = typeProblem ?? throw new ArgumentNullException(nameof(typeProblem)); Parent = parent ?? throw new ArgumentNullException(nameof(parent)); EnclosingSetUp = enclosingSetUp ?? throw new ArgumentNullException(nameof(enclosingSetUp)); }