public static IInterpetedResult <IInterpetedMember> Return <T>(this IInterpetedResult <T> self)
            where T : class, IInterpetedAnyType
        {
            if (self is IInterpetedResultNotReturn <T> notReturn)
            {
                return(InterpetedResult.Return <IInterpetedMember>(notReturn.Value));
            }

            if (self is IInterpetedResultReturn <T> toReturn)
            {
                return(InterpetedResult.Return <IInterpetedMember>(toReturn.Value));
            }

            throw new Exception("should be one!");
        }
Example #2
0
            public IInterpetedResult <IInterpetedMember> Invoke(IInterpetedMember input)
            {
                var context = InterpetedContext.Child(TypeManager.InstanceScope((contextDefinition.Key, input)));

                ImplementationType.OutputType.SafeIs(out MethodType outputMethod);
                var thing = InternalMethod(
                    ParameterDefinition,
                    Body,
                    context,
                    Scope,
                    Tac.Model.Instantiated.MethodType.CreateAndBuild(
                        outputMethod.InputType,
                        outputMethod.OutputType));

                return
                    (InterpetedResult.Create(
                         Member(
                             thing.Convert(TransformerExtensions.NewConversionContext()),
                             thing)));
            }
        public override IInterpetedResult <IInterpetedMember> Interpet(InterpetedContext interpetedContext)
        {
            var leftResult = Left.Interpet(interpetedContext);

            if (leftResult.IsReturn(out var leftReturned, out var leftValue))
            {
                return(InterpetedResult.Return <IInterpetedMember>(leftReturned !));
            }

            var rightResult = Right.Interpet(interpetedContext);

            if (rightResult.IsReturn(out var rightReturned, out var rightValue))
            {
                return(InterpetedResult.Return <IInterpetedMember>(rightReturned !));
            }

            rightValue.CastTo <IInterpetedMemberSet>().Set(leftValue !.Value);

            return(InterpetedResult.Create(leftValue));
        }
        public override IInterpetedResult <IInterpetedMember> Interpet(InterpetedContext interpetedContext)
        {
            var leftResult = Left.Interpet(interpetedContext);

            if (leftResult.IsReturn(out var leftReturned, out var leftValue))
            {
                return(InterpetedResult.Return <IInterpetedMember>(leftReturned !));
            }

            if (leftValue !.Value.Has <IBoxedBool>().Value)
            {
                return(InterpetedResult.Create(TypeManager.BoolMember(TypeManager.Bool(false))));
            }

            var rightResult = Right.Interpet(interpetedContext);

            if (rightResult.IsReturn(out var rightReturned, out var _))
            {
                return(InterpetedResult.Return <IInterpetedMember>(rightReturned !));
            }

            return(InterpetedResult.Create(TypeManager.BoolMember(TypeManager.Bool(true))));
        }
        public override IInterpetedResult <IInterpetedMember> Interpet(InterpetedContext interpetedContext)
        {
            var leftResult = Left.Interpet(interpetedContext);

            if (leftResult.IsReturn(out var leftReturned, out var leftValue))
            {
                return(InterpetedResult.Return <IInterpetedMember>(leftReturned !));
            }

            var rightResult = Right.Interpet(interpetedContext);

            if (rightResult.IsReturn(out var rightReturned, out var rightValue))
            {
                return(InterpetedResult.Return <IInterpetedMember>(rightReturned !));
            }

            if (leftValue !.Value.Has <IInterpetedMethod>().Invoke(rightValue !).IsReturn(out var returned, out var _) && returned is IInterpetedMember outReturned)
            {
                return(InterpetedResult.Create(outReturned));
            }

            throw new Exception("should never get here!");
        }
Example #6
0
            public IInterpetedResult <IInterpetedMember> Invoke(IInterpetedMember input)
            {
                var res = Scope.Create();

                res.GetMember(ParameterDefinition.Key).CastTo <IInterpetedMemberSet>().Set(input.Value);

                var scope = Context.Child(res);

                foreach (var line in Body)
                {
                    var result = line.Interpet(scope);
                    if (result.IsReturn(out var resMember, out var value))
                    {
                        return(InterpetedResult.Create(resMember.CastTo <IInterpetedMember>()));
                    }
                }

                if (MethodType.OutputType is EmptyType)
                {
                    return(InterpetedResult.Create(TypeManager.EmptyMember(TypeManager.Empty())));
                }

                throw new System.Exception("method did not return!");
            }
Example #7
0
            public IInterpetedResult <IInterpetedMember> Invoke(IInterpetedMember input)
            {
                var thing = Backing(input.Value);

                return(InterpetedResult.Create(Member(thing.Convert(TransformerExtensions.NewConversionContext()), thing)));
            }
 public IInterpetedResult <IInterpetedMember> Interpet(InterpetedContext interpetedContext)
 {
     return(InterpetedResult.Create(TypeManager.BoolMember(TypeManager.Bool(Value))));
 }
Example #9
0
 public IInterpetedResult <IInterpetedMember> Interpet(InterpetedContext interpetedContext)
 {
     return(InterpetedResult.Create(TypeManager.EmptyMember(TypeManager.Empty())));
 }