示例#1
0
            public IInterpetedResult <IInterpetedMember <TOut> > Invoke(IInterpetedMember <TIn> input)
            {
                var res = Scope.Create();

                res.GetMember <TIn>(ParameterDefinition.Key).Cast <IInterpetedMemberSet <TIn> >().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.Cast <IInterpetedMember <TOut> >()));
                    }
                }

                // does this work??
                // wierd stuff around the way I am doing types
                // life would be so much simpler if I just pulled it all out
                // I should just pull it all out
                // clearly I should
                //
                if (typeof(IInterpedEmpty).IsAssignableFrom(typeof(TOut)))
                {
                    var hack = TypeManager.Empty();
                    return(InterpetedResult.Create(Member <TOut>(hack.Convert(TransformerExtensions.NewConversionContext()), hack.Cast <TOut>())));
                }

                throw new System.Exception("method did not return!");
            }
 public static IInterpetedResult <IInterpetedMember <IInterpedEmpty> > Create()
 {
     return(new NotReturn <IInterpetedMember <IInterpedEmpty> >(TypeManager.EmptyMember(TypeManager.Empty())));
 }
        //public T GetAndUnwrapMemberWhenNeeded(InterpetedContext context)
        //{
        //    if (Value is IInterpetedMember<T> member)
        //    {
        //        return member.Value;
        //    }
        //    if (Value is InterpetedMemberDefinition memberDefinition)
        //    {
        //        return context.GetMember(memberDefinition.Key).Value.Cast<T>();
        //    }
        //    return Value;
        //}


        public static IInterpetedResultReturn <T> Return <T>()
            where T : IInterpetedAnyType
        {
            return(new IsReturn <T>(TypeManager.Empty()));
        }
 public IInterpetedResult <IInterpetedMember <IInterpedEmpty> > Interpet(InterpetedContext interpetedContext)
 {
     return(InterpetedResult.Create(TypeManager.EmptyMember(TypeManager.Empty())));
 }