Esempio n. 1
0
    public void update(boolean how, ESeq flags, EPID self) {
      ETuple2 t;
      EPID p;
      while (!flags.isNil()) {
        EObject flag = flags.head();
        flags = flags.tail();

        if (flag == am_arity) {
          arity = how;
        } else if (flag == am_call) {
          call = how;
        } else if (flag == am_send) {
          send = how;
        } else if (flag == am_receive) {
          receive = how;
        } else if (flag == am_procs) {
          procs = how;
        } else if (flag == am_silent) {
          silent = how;
        } else if ((t = ETuple2.cast(flag)) != null && t.elem1 == am_tracer) {
          tracer = t.elem2.testPID();
        } else if (flag == am_all) {
          call = how;
          arity = how;
          send = how;
          receive = how;
        } else {
          throw ERT.badarg(flag);
        }
      }

      if (how == true && tracer == null) {
        tracer = self;
      }
    }
Esempio n. 2
0
 @Override
 public void encode(EOutputStream eos) {
   int len = this.length();
   eos.write_list_head(len);
   ESeq curr = this;
   while (!curr.isNil()) {
     eos.write_any(curr.head());
     curr = curr.tail();
   }
   eos.write_nil();
 }
Esempio n. 3
0
  @BIF
  public static EInteger trace(EProc self_proc, EObject arg0, EObject arg1, EObject arg2) {
    EInternalPID pid = arg0.testInternalPID();
    EAtom all = arg0.testAtom();
    EObject how = arg1.testBoolean();
    ESeq flags = arg2.testSeq();

    if ((pid == null && all != am_all) || how == null || flags == null) {
      throw ERT.badarg(arg0, arg1, arg2);
    }

    EInternalPID self = self_proc.self_handle();

    if (all == am_all) {
      ESeq allprocs = EProc.processes();
      int result = allprocs.length();
      global_trace_flags.update(how == ERT.TRUE, flags, self);
      while (!allprocs.isNil()) {
        EProc proc = allprocs.head().testInternalPID().task();
        allprocs = allprocs.tail();

        if (proc.trace_flags != null) {
          proc.trace_flags.update(how == ERT.TRUE, flags, self);
        }
      }

      return ERT.box(result);

    } else {
      EProc proc = pid.task();

      if (!proc.is_alive_dirtyread()) {
        return ESmall.ZERO;
      }

      if (proc.trace_flags == null) {
        proc.trace_flags = global_trace_flags.clone();
      }

      proc.trace_flags.update(how == ERT.TRUE, flags, self);

      return ESmall.ONE;
    }
  }
Esempio n. 4
0
  public ESeq getTrace() {
    ESeq trace = super.getTrace();

    if (args != null && !trace.isNil()) {

      ETuple4 first = ETuple4.cast(trace.head().testTuple());
      ESeq res = trace.tail().testSeq();

      ETuple4 fa = new ETuple4();
      fa.elem1 = first.elem1;
      fa.elem2 = first.elem2;
      fa.elem3 = args;
      fa.elem4 = first.elem4;

      trace = res.cons(fa);
    }

    return trace;
  }