public boolean forLoopHasNext(
     @Nullable XExpression before,
     @Nullable XExpression separator,
     @NonNull CharSequence indentation) {
   if (!ignore()) {
     if (forLoopStack.peek() != null) {
       int remaining = forLoopStack.peek();
       boolean first = false;
       if (remaining < 0) {
         first = true;
         remaining = remaining * -1;
       }
       if (remaining > 0) {
         forLoopStack.set(forLoopStack.size() - 1, remaining - 1);
         if (first) {
           if (before != null) acceptExpression(before, indentation);
         } else if (separator != null) {
           acceptExpression(separator, indentation, true);
         }
         return true;
       }
     }
   }
   return false;
 }
    public void downLevel(boolean atomic) {
      if (m_level > 0) {
        boolean last = m_last.peek();

        m_flags.pop();

        if (last) {
          m_flags.push(6); // 00110
        } else {
          m_flags.push(22); // 10110
        }

        for (int i = 0; i < m_level - 1; i++) {
          Integer flag = m_flags.get(i);
          int f = flag;

          if (flag == 6) { // 00110
            f = 0; // 00000
          } else if (flag == 22) { // 10110
            f = 20; // 10100
          }

          m_flags.set(i, f);
        }
      }

      boolean root = m_level == 0;

      if (atomic) {
        if (root) {
          m_flags.push(1); // 00001
        } else {
          m_flags.push(9); // 01001
        }
      } else {
        if (root) {
          m_flags.push(17); // 10001
        } else {
          m_flags.push(25); // 11001
        }
      }

      m_last.push(root ? true : false);
      m_level++;
    }
    void beginTask(TraceEntry te) {
      BdynCallback cb = bdyn_factory.getCallback(te.getEntryLocation());
      if (cb == null) return;

      if (trace_writer != null)
        trace_writer.println(
            "PROCESS " + te.getEntryLocation() + " " + te.isExit() + " " + te.getTime());

      if (current_transaction == null) {
        OutputTask ot = null;
        if (te.isExit()) return;
        int i0 = te.getObject1();
        int i1 = te.getObject2();
        if (i0 != 0) {
          ot = object_tasks.get(i0);
          if (ot == dummy_task) ot = null;
        }
        if (ot == null) {
          if (i1 != 0) {
            ot = object_tasks.get(i1);
            if (ot == dummy_task) ot = null;
          }
        }
        if (ot == null) {
          ot = new OutputTask(++task_counter, cb);
        }
        current_transaction = ot;
        nest_level = 0;
      }
      if (!te.isExit()) {
        OutputEntry oe = null;
        if (nest_level == 0) {
          oe = createOutputEntry(te);
        } else if (cb.getCallbackType() == CallbackType.KEY
            && BdynFactory.getOptions().useKeyCallback()) {
          for (int i = output_stack.size() - 1; i >= 0; --i) {
            OutputEntry poe = output_stack.get(i);
            if (poe != null) {
              poe.finishAt(te.getTime());
              if (trace_writer != null)
                trace_writer.println(
                    "FINISHINT "
                        + poe.getEntryTask().getId()
                        + " "
                        + nest_level
                        + " "
                        + poe.getTotalTime(0)
                        + " "
                        + poe.hashCode());
              break;
            }
          }
          oe = createOutputEntry(te);
        } else {
          if (trace_writer != null) trace_writer.println("IGNORE " + cb.getId() + " " + nest_level);
          // System.err.println("TRACE: Ignore " + cb.getDisplayName() + " " + nest_level);
        }
        output_stack.push(oe);
        active_threads.add(this);
        ++nest_level;
      } else {
        if (nest_level <= 0) {
          return;
        }
        --nest_level;
        OutputEntry oe = output_stack.pop();
        if (oe != null) {
          // TODO: max_delta doesn't take into account calls that haven't ended yet
          max_delta = Math.max(max_delta, te.getTime() - oe.getStartTime());
          oe.finishAt(te.getTime());
          if (trace_writer != null)
            trace_writer.println(
                "FINISH "
                    + oe.getEntryTask().getId()
                    + " "
                    + nest_level
                    + " "
                    + oe.getTotalTime(0)
                    + " "
                    + oe.hashCode());
          if (!oe.isRelevant()) {
            output_set.remove(oe);
            if (trace_writer != null)
              trace_writer.println("REMOVE KEY " + oe.getEntryTask().getId() + " " + nest_level);
            // System.err.println("REMOVE KEY " + oe.getEntryTask().getDisplayName());
            oe = null;
            for (int i = output_stack.size() - 1; i >= 0; --i) {
              OutputEntry poe = output_stack.get(i);
              if (poe != null) {
                poe.finishAt(0);
                if (trace_writer != null)
                  trace_writer.println(
                      "NO END "
                          + poe.getEntryTask().getId()
                          + " "
                          + nest_level
                          + " "
                          + poe.hashCode());
                break;
              }
            }
          }
        }

        if (last_entry != null
            && oe != null
            && last_entry.getEntryTask() == oe.getEntryTask()
            && (te.getTime() - last_entry.getStartTime()) < MERGE_TIME) {
          last_entry.mergeWith(oe);
          output_set.remove(oe);
          if (trace_writer != null)
            trace_writer.println("MERGE KEY " + oe.getEntryTask().getId() + " " + nest_level);
          // System.err.println("REMOVE " + oe.getEntryTask().getDisplayName());
        }

        if (oe != null) last_entry = oe;

        if (nest_level == 0) endTask();
        else if (oe != null) {
          for (int i = output_stack.size() - 1; i >= 0; --i) {
            OutputEntry poe = output_stack.get(i);
            if (poe != null) {
              if (!poe.isSignificant()) {
                output_set.remove(poe);
              }
              if (trace_writer != null)
                trace_writer.println(
                    "NEST KEY "
                        + poe.getEntryTask().getId()
                        + " "
                        + nest_level
                        + " "
                        + poe.isSignificant());
              oe = new OutputEntry(te.getTime(), 0, this, current_transaction, poe.getEntryTask());
              oe.setDeletable();
              output_set.add(oe);
              output_stack.set(i, oe);
              break;
            }
          }
        }
      }
    }