Exemplo n.º 1
0
        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!");
        }
Exemplo n.º 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)));
            }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
        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!");
        }
Exemplo n.º 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!");
            }
Exemplo n.º 7
0
            public IInterpetedResult <IInterpetedMember> Invoke(IInterpetedMember input)
            {
                var thing = Backing(input.Value);

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