예제 #1
0
        public InvokeHelper(Invokee <T> target, T arguments, Action <EventArgs> freeArgumentCallback)
            : base(freeArgumentCallback)
        {
            Debug.Assert(target != null);

            Target    = target;
            Arguments = arguments;
        }
예제 #2
0
        public CompiledExpression Compile(Expression expression)
        {
            Invokee inv = expression.ToEvaluator(Symbols);

            return((ITypedElement focus, EvaluationContext ctx) =>
            {
                var closure = Closure.Root(focus, ctx);
                return inv(closure, InvokeeFactory.EmptyArgs);
            });
        }
예제 #3
0
        public CompiledExpression Compile(Expression expression)
        {
            Invokee inv = expression.ToEvaluator(Symbols);

            return((IElementNavigator focus, IElementNavigator containerResource) =>
            {
                var closure = Closure.Root(focus, containerResource);
                return inv(closure, InvokeeFactory.EmptyArgs);
            });
        }
예제 #4
0
 // Update is called once per frame
 void Update()
 {
     while (ToInvoke.Count > 0)
     {
         Invokee i = ToInvoke[0];
         i.Output = i.Method.Invoke(i.MethodInstance, null);
         i.Done   = true;
         ToInvoke.RemoveAt(0);
     }
 }
예제 #5
0
        void ClanMembershipStatusChanged(object sender, ClanMembershipEventArgs e)
        {
            m_isInClan = !string.IsNullOrEmpty(e.Tag);
            Invokee result = () => beginFormingANewClanToolStripMenuItem.Enabled = !m_isInClan;

            if (InvokeRequired)
            {
                Invoke(result);
            }
            else
            {
                result();
            }
        }
예제 #6
0
 public static Invokee Invoke(string functionName, IEnumerable <Invokee> arguments, Invokee invokee)
 {
     return((ctx, _) =>
     {
         try
         {
             return invokee(ctx, arguments);
         }
         catch (Exception e)
         {
             throw new InvalidOperationException("Invocation of '{0}' failed: {1}".FormatWith(functionName, e.Message));
         }
     });
 }
예제 #7
0
        public static Invokee Invoke(string functionName, IEnumerable <Invokee> arguments, Invokee invokee)
        {
            return((ctx, _) =>
            {
                try
                {
                    return invokee(ctx, arguments);
                }
                catch (Exception e)
                {
                    throw new InvalidOperationException(
                        $"Invocation of {formatFunctionName(functionName)} failed: {e.Message}");
                }
            });

            string formatFunctionName(string name)
            {
                if (name.StartsWith(BinaryExpression.BIN_PREFIX))
                {
                    return($"operator '{name.Substring(BinaryExpression.BIN_PREFIX_LEN)}'");
                }
                else if (name.StartsWith(UnaryExpression.URY_PREFIX))
                {
                    return($"operator '{name.Substring(UnaryExpression.URY_PREFIX_LEN)}'");
                }
                else
                {
                    return($"function '{name}'");
                }
            }
        }
예제 #8
0
 public TableEntry(CallSignature signature, Invokee body)
 {
     Signature = signature;
     Body      = body;
 }
예제 #9
0
 internal void Add(CallSignature signature, Invokee body)
 {
     _entries.Add(new TableEntry(signature, body));
 }
예제 #10
0
        public static Invokee Invoke(string functionName, IEnumerable <Invokee> arguments, Invokee invokee)
        {
            Func <Closure, IEnumerable <IElementNavigator> > boundFunc = (ctx) => invokee(ctx, arguments);
            IEnumerable <IElementNavigator> lastResult = null;

            return((ctx, _) =>
            {
                //  if (lastResult != null) return lastResult;

                try
                {
                    lastResult = boundFunc(ctx);
                    return lastResult;
                }
                catch (Exception e)
                {
                    throw new InvalidOperationException("Invocation of '{0}' failed: {1}".FormatWith(functionName, e.Message));
                }
            });
        }