Beispiel #1
0
 internal virtual void PumpEventsForFilter(int id, Conditional cond, EventFilter filter)
 {
     AddEventFilter(filter);
     DoDispatch = true;
     while (DoDispatch && !Interrupted && cond.Evaluate())
     {
         PumpOneEventForFilters(id);
     }
     RemoveEventFilter(filter);
 }
Beispiel #2
0
 public void Execute(ExecEnvironment environment)
 {
     while (conditional.Evaluate(environment))
     {
         if (environment.ReturnFlag)
         {
             break;
         }
         statement.Execute(environment);
     }
 }
Beispiel #3
0
 public void Execute(ExecEnvironment environment)
 {
     for (first.Execute(environment); conditional.Evaluate(environment); second.Execute(environment))
     {
         if (environment.ReturnFlag)
         {
             break;
         }
         statement.Execute(environment);
     }
 }
        /// <summary>
        /// Evaluates the conditional using the supplied values.
        /// </summary>
        /// <param name="user">The User.</param>
        /// <param name="npc">The NPC.</param>
        /// <returns>The result of the conditional's evaluation.</returns>
        public bool Evaluate(object user, object npc)
        {
            var ret = Conditional.Evaluate(user, npc, Parameters.ToArray());

            if (Not)
            {
                ret = !ret;
            }

            return(ret);
        }
Beispiel #5
0
 public void Execute(ExecEnvironment environment)
 {
     if (conditional.Evaluate(environment))
     {
         statementIf.Execute(environment);
     }
     else
     {
         if (environment.ReturnFlag)
         {
             return;
         }
         statementElse?.Execute(environment);
     }
 }
Beispiel #6
0
        /// <summary>
        /// {@inheritDoc}
        /// </summary>
        public virtual bool Enter()
        {
            if (Log.isLoggable(PlatformLogger.Level.FINE))
            {
                Log.fine("enter(): blockingEDT=" + KeepBlockingEDT.Get() + ", blockingCT=" + KeepBlockingCT.Get());
            }

            if (!KeepBlockingEDT.CompareAndSet(false, true))
            {
                Log.fine("The secondary loop is already running, aborting");
                return(false);
            }

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final Runnable run = new Runnable()
            Runnable run = new RunnableAnonymousInnerClassHelper(this);

            // We have two mechanisms for blocking: if we're on the
            // dispatch thread, start a new event pump; if we're
            // on any other thread, call wait() on the treelock

            Thread currentThread = Thread.CurrentThread;

            if (currentThread == DispatchThread)
            {
                if (Log.isLoggable(PlatformLogger.Level.FINEST))
                {
                    Log.finest("On dispatch thread: " + DispatchThread);
                }
                if (Interval != 0)
                {
                    if (Log.isLoggable(PlatformLogger.Level.FINEST))
                    {
                        Log.finest("scheduling the timer for " + Interval + " ms");
                    }
                    Timer.Schedule(TimerTask = new TimerTaskAnonymousInnerClassHelper(this), Interval);
                }
                // Dispose SequencedEvent we are dispatching on the the current
                // AppContext, to prevent us from hang - see 4531693 for details
                SequencedEvent currentSE = KeyboardFocusManager.CurrentKeyboardFocusManager.CurrentSequencedEvent;
                if (currentSE != null)
                {
                    if (Log.isLoggable(PlatformLogger.Level.FINE))
                    {
                        Log.fine("Dispose current SequencedEvent: " + currentSE);
                    }
                    currentSE.Dispose();
                }
                // In case the exit() method is called before starting
                // new event pump it will post the waking event to EDT.
                // The event will be handled after the the new event pump
                // starts. Thus, the enter() method will not hang.
                //
                // Event pump should be privileged. See 6300270.
                AccessController.doPrivileged(new PrivilegedActionAnonymousInnerClassHelper(this, run));
            }
            else
            {
                if (Log.isLoggable(PlatformLogger.Level.FINEST))
                {
                    Log.finest("On non-dispatch thread: " + currentThread);
                }
                lock (TreeLock)
                {
                    if (Filter != null)
                    {
                        DispatchThread.AddEventFilter(Filter);
                    }
                    try
                    {
                        EventQueue eq = DispatchThread.EventQueue;
                        eq.PostEvent(new PeerEvent(this, run, PeerEvent.PRIORITY_EVENT));
                        KeepBlockingCT.Set(true);
                        if (Interval > 0)
                        {
                            long currTime = DateTimeHelperClass.CurrentUnixTimeMillis();
                            while (KeepBlockingCT.Get() && ((ExtCondition != null) ? ExtCondition.Evaluate() : true) && (currTime + Interval > DateTimeHelperClass.CurrentUnixTimeMillis()))
                            {
                                Monitor.Wait(TreeLock, TimeSpan.FromMilliseconds(Interval));
                            }
                        }
                        else
                        {
                            while (KeepBlockingCT.Get() && ((ExtCondition != null) ? ExtCondition.Evaluate() : true))
                            {
                                TreeLock.Wait();
                            }
                        }
                        if (Log.isLoggable(PlatformLogger.Level.FINE))
                        {
                            Log.fine("waitDone " + KeepBlockingEDT.Get() + " " + KeepBlockingCT.Get());
                        }
                    }
                    catch (InterruptedException e)
                    {
                        if (Log.isLoggable(PlatformLogger.Level.FINE))
                        {
                            Log.fine("Exception caught while waiting: " + e);
                        }
                    }
                    finally
                    {
                        if (Filter != null)
                        {
                            DispatchThread.RemoveEventFilter(Filter);
                        }
                    }
                    // If the waiting process has been stopped because of the
                    // time interval passed or an exception occurred, the state
                    // should be changed
                    KeepBlockingEDT.Set(false);
                    KeepBlockingCT.Set(false);
                }
            }

            return(true);
        }
Beispiel #7
0
 public bool Evaluate(ExecEnvironment environment)
 => isNegated ? !parenConditional.Evaluate(environment) : parenConditional.Evaluate(environment);
Beispiel #8
0
 public bool Evaluate(ExecEnvironment environment)
 => leftConditional.Evaluate(environment) || rightConditional.Evaluate(environment);