コード例 #1
0
        public IEnumerable <ITypedElement> Dispatcher(Closure context, IEnumerable <Invokee> args)
        {
            var actualArgs = new List <IEnumerable <ITypedElement> >();

            var focus = args.First()(context, InvokeeFactory.EmptyArgs);

            if (!focus.Any())
            {
                return(ElementNode.EmptyList);
            }

            actualArgs.Add(focus);
            var newCtx = context.Nest(focus);

            actualArgs.AddRange(args.Skip(1).Select(a => a(newCtx, InvokeeFactory.EmptyArgs)));
            if (actualArgs.Any(aa => !aa.Any()))
            {
                return(ElementNode.EmptyList);
            }

            var entry = _scope.DynamicGet(_name, actualArgs);

            if (entry != null)
            {
                try
                {
                    // The Get() here should never fail, since we already know there's a (dynamic) matching candidate
                    // Need to clean up this duplicate logic later

                    var argFuncs = actualArgs.Select(arg => InvokeeFactory.Return(arg));
                    return(entry(context, argFuncs));
                }
                catch (TargetInvocationException tie)
                {
                    // Unwrap the very non-informative T.I.E, and throw the nested exception instead
                    throw tie.InnerException;
                }
            }
            else
            {
                //TODO: Make error reporting better
                throw Error.Argument(noMatchError(actualArgs));
            }
        }
コード例 #2
0
 public override Invokee VisitNewNodeListInit(FP.NewNodeListInitExpression expression, SymbolTable scope)
 {
     return(InvokeeFactory.Return(FhirValueList.Empty));
 }
コード例 #3
0
 public override Invokee VisitConstant(FP.ConstantExpression expression, SymbolTable scope)
 {
     return(InvokeeFactory.Return(new ConstantValue(expression.Value)));
 }
コード例 #4
0
 public static void AddVar(this SymbolTable table, string name, IElementNavigator value)
 {
     table.Add(new CallSignature(name, typeof(string)), InvokeeFactory.Return(value));
 }
コード例 #5
0
 public override Invokee VisitNewNodeListInit(FP.NewNodeListInitExpression expression, SymbolTable scope)
 {
     return(InvokeeFactory.Return(ElementNode.EmptyList));
 }
コード例 #6
0
 public override Invokee VisitConstant(FP.ConstantExpression expression, SymbolTable scope)
 {
     return(InvokeeFactory.Return(ElementNode.ForPrimitive(expression.Value)));
 }