Пример #1
0
            /// <inheritdoc />
            protected override Result <TypeReference, IError> GetGenericTypeParameter(
                TypeReference expectedTypeReference,
                FreezableStepData freezableStepData,
                TypeResolver typeResolver)
            {
                var left = freezableStepData
                           .TryGetStep(nameof(Left), StepType)
                           .Bind(x => x.TryGetOutputTypeReference(TypeReference.Any.Instance, typeResolver));

                if (left.IsFailure)
                {
                    return(left.ConvertFailure <TypeReference>());
                }

                var right = freezableStepData
                            .TryGetStep(nameof(Right), StepType)
                            .Bind(x => x.TryGetOutputTypeReference(TypeReference.Any.Instance, typeResolver));

                if (right.IsFailure)
                {
                    return(right.ConvertFailure <TypeReference>());
                }

                var r = TypeReference.Create(new[] { left.Value, right.Value });

                return(r);
            }
Пример #2
0
 /// <inheritdoc />
 protected override Result <TypeReference, IError> GetGenericTypeParameter(
     TypeReference expectedTypeReference,
     FreezableStepData freezableStepData,
     TypeResolver typeResolver) => freezableStepData
 .TryGetStep(nameof(Log <object> .Value), StepType)
 .Bind(x => x.TryGetOutputTypeReference(TypeReference.Any.Instance, typeResolver))
 .Map(x => x == TypeReference.Any.Instance ? TypeReference.Actual.String : x);
Пример #3
0
            /// <inheritdoc />
            protected override Result <TypeReference, IError> GetGenericTypeParameter(
                TypeReference expectedTypeReference,
                FreezableStepData freezableStepData,
                TypeResolver typeResolver)
            {
                var checkResult = expectedTypeReference
                                  .CheckAllows(TypeReference.Actual.Bool, StepType, typeResolver)
                                  .MapError(x => x.WithLocation(freezableStepData));

                if (checkResult.IsFailure)
                {
                    return(checkResult.ConvertFailure <TypeReference>());
                }

                var result = freezableStepData
                             .TryGetStep(nameof(Terms), StepType)
                             .Bind(
                    x => x.TryGetOutputTypeReference(
                        new TypeReference.Array(TypeReference.Any.Instance),
                        typeResolver
                        )
                    )
                             .Bind(
                    x => x.TryGetArrayMemberTypeReference(typeResolver)
                    .MapError(e => e.WithLocation(freezableStepData))
                    );

                return(result);
            }
Пример #4
0
 /// <inheritdoc />
 protected override Result <TypeReference, IError> GetGenericTypeParameter(
     TypeReference expectedTypeReference,
     FreezableStepData freezableStepData,
     TypeResolver typeResolver) => freezableStepData
 .TryGetStep(nameof(Then), StepType)
 .Compose(() => freezableStepData.TryGetStep(nameof(Else), StepType))
 .Bind(
     x => x.Item1.TryGetOutputTypeReference(TypeReference.Any.Instance, typeResolver)
     .Compose(
         () => x.Item2.TryGetOutputTypeReference(
             TypeReference.Any.Instance,
             typeResolver
             )
         )
     )
 .Map(x => TypeReference.Create(new[] { x.Item1, x.Item2 }));
Пример #5
0
 /// <inheritdoc />
 protected override Result <TypeReference, IError> GetGenericTypeParameter(
     TypeReference expectedTypeReference,
     FreezableStepData freezableStepData,
     TypeResolver typeResolver)
 {
     return(freezableStepData
            .TryGetStep(nameof(Repeat <object> .Element), StepType)
            .Bind(x => x.TryGetOutputTypeReference(TypeReference.Any.Instance, typeResolver)));
 }
Пример #6
0
            /// <inheritdoc />
            protected override Result <TypeReference, IError> GetGenericTypeParameter(
                TypeReference expectedTypeReference,
                FreezableStepData freezableStepData,
                TypeResolver typeResolver)
            {
                var r =
                    freezableStepData
                    .TryGetStep(nameof(SetVariable <object> .Value), StepType)
                    .Bind(
                        x => x.TryGetOutputTypeReference(TypeReference.Any.Instance, typeResolver)
                        );

                return(r);
            }
Пример #7
0
            /// <inheritdoc />
            protected override Result <TypeReference, IError> GetGenericTypeParameter(
                TypeReference expectedTypeReference,
                FreezableStepData freezableStepData,
                TypeResolver typeResolver)
            {
                var expectedMemberType = expectedTypeReference
                                         .TryGetArrayMemberTypeReference(typeResolver)
                                         .MapError(x => x.WithLocation(freezableStepData));

                if (expectedMemberType.IsFailure)
                {
                    return(expectedMemberType.ConvertFailure <TypeReference>());
                }

                var arraysStep = freezableStepData.TryGetStep(
                    nameof(ArrayConcat <object> .Arrays),
                    StepType
                    );

                if (arraysStep.IsFailure)
                {
                    return(arraysStep.ConvertFailure <TypeReference>());
                }

                var expectedArraysStepType =
                    new TypeReference.Array(new TypeReference.Array(expectedMemberType.Value));

                var arraysStepGenericType = arraysStep.Value.TryGetOutputTypeReference(
                    expectedArraysStepType,
                    typeResolver
                    )
                                            .Bind(
                    x => x.TryGetArrayMemberTypeReference(typeResolver)
                    .MapError(e => e.WithLocation(freezableStepData))
                    )
                                            .Bind(
                    x => x.TryGetArrayMemberTypeReference(typeResolver)
                    .MapError(e => e.WithLocation(freezableStepData))
                    )
                ;

                if (arraysStepGenericType.IsFailure)
                {
                    return(arraysStepGenericType.ConvertFailure <TypeReference>());
                }

                return(arraysStepGenericType);
            }
Пример #8
0
            /// <inheritdoc />
            protected override Result <TypeReference, IError> GetGenericTypeParameter(
                TypeReference expectedTypeReference,
                FreezableStepData freezableStepData,
                TypeResolver typeResolver)
            {
                if (!expectedTypeReference.Allow(TypeReference.Actual.Entity, typeResolver))
                {
                    return(Result.Failure <TypeReference, IError>(
                               ErrorCode.WrongParameterType.ToErrorBuilder(
                                   StepType.Name,
                                   expectedTypeReference.Name,
                                   nameof(Entity)
                                   )
                               .WithLocation(freezableStepData)
                               ));
                }

                var r1 = freezableStepData.TryGetStep(nameof(EntitySetValue <object> .Value), StepType)
                         .Bind(x => x.TryGetOutputTypeReference(TypeReference.Any.Instance, typeResolver));

                return(r1);
            }
Пример #9
0
            GetVariablesSet(
                TypeReference expectedTypeReference,
                FreezableStepData freezableStepData,
                TypeResolver typeResolver)
            {
                var export = freezableStepData.TryGetStep(nameof(Export), StepType)
                             .Bind(
                    x => x.TryFreeze(
                        new TypeReference.Array(TypeReference.Actual.String),
                        typeResolver
                        )
                    )
                ;

                if (export.IsSuccess)
                {
                    var ev = export.Value.TryConvertToEntityValue();

                    if (ev.HasValue && ev.Value is EntityValue.NestedList nestedList)
                    {
                        foreach (var entityValue in nestedList.Value)
                        {
                            var name = entityValue.GetPrimitiveString();

                            yield return(new VariableName(name !), TypeReference.Any.Instance);
                        }
                    }
                }

                foreach (var pair in base.GetVariablesSet(
                             expectedTypeReference,
                             freezableStepData,
                             typeResolver
                             ))
                {
                    yield return(pair);
                }
            }
Пример #10
0
            /// <inheritdoc />
            protected override Result <TypeReference, IError> GetGenericTypeParameter(
                TypeReference expectedTypeReference,
                FreezableStepData freezableStepData,
                TypeResolver typeResolver)
            {
                var checkResult =
                    expectedTypeReference.CheckAllows(
                        TypeReference.Unit.Instance,
                        StepType,
                        typeResolver
                        );

                if (checkResult.IsFailure)
                {
                    return(checkResult.ConvertFailure <TypeReference>()
                           .MapError(x => x.WithLocation(freezableStepData)));
                }

                var stepTypeReference = freezableStepData.TryGetStep(nameof(Step), StepType)
                                        .Bind(x => x.TryGetOutputTypeReference(TypeReference.Any.Instance, typeResolver));

                return(stepTypeReference);
            }
Пример #11
0
 /// <inheritdoc />
 protected override Result <TypeReference, IError> GetGenericTypeParameter(
     TypeReference expectedTypeReference,
     FreezableStepData freezableStepData,
     TypeResolver typeResolver) => freezableStepData
 .TryGetStep(nameof(Sequence <object> .FinalStep), StepType)
 .Bind(x => x.TryGetOutputTypeReference(TypeReference.Any.Instance, typeResolver));