Esempio n. 1
0
  public static void do_trace(EProc proc, EAtom what, EObject info) throws Pausable {

    EPID pid = proc.get_trace_flags().tracer;

    EObject msg = ETuple4.make_tuple(am_trace, proc.self_handle(), what, info);

    pid.send(proc.self_handle(), msg);
  }
Esempio n. 2
0
 /** Shuts down currently running OTP */
 public static void shutdown() {
   EObject init_proc = whereis(am_init);
   ETuple tup = ETuple.make(am_stop, am_stop);
   EPID init_pid;
   if ((init_pid = init_proc.testPID()) != null) {
     init_pid.sendb(tup);
   }
 }
Esempio n. 3
0
  /**
   * Read an Erlang PID from the stream.
   *
   * @return the value of the PID.
   * @exception IOException if the next term in the stream is not an Erlang PID.
   */
  public EPID read_pid() throws IOException {
    EAtom node;
    int id;
    int serial;
    int creation;
    int tag;

    tag = read1skip_version();

    if (tag != EExternal.pidTag) {
      throw new IOException("Wrong tag encountered, expected " + EExternal.pidTag + ", got " + tag);
    }

    node = read_atom();
    id = read4BE() & 0x7fff; // 15 bits
    serial = read4BE() & 0x1fff; // 13 bits
    creation = read1() & 0x03; // 2 bits

    return EPID.make(node, id, serial, creation);
  }
Esempio n. 4
0
  /**
   * Read an arbitrary Erlang term from the stream.
   *
   * @return the Erlang term.
   * @exception IOException if the stream does not contain a known Erlang type at the next position.
   */
  public EObject read_any() throws IOException {
    // calls one of the above functions, depending on o
    final int tag = peek1skip_version();

    switch (tag) {
      case EExternal.smallIntTag:
      case EExternal.intTag:
      case EExternal.smallBigTag:
      case EExternal.largeBigTag:
        return EInteger.read(this);

      case EExternal.atomCacheRef:
      case EExternal.atomTag:
      case EExternal.smallAtomTag:
        return EAtom.read(this);

      case EExternal.floatTag:
      case EExternal.newFloatTag:
        return EDouble.read(this);

      case EExternal.refTag:
      case EExternal.newRefTag:
        return ERef.read(this);

      case EExternal.portTag:
        return EPort.read(this);

      case EExternal.pidTag:
        return EPID.read(this);

      case EExternal.stringTag:
        return EString.read(this);

      case EExternal.listTag:
      case EExternal.nilTag:
        if ((flags & DECODE_INT_LISTS_AS_STRINGS) != 0) {
          final int savePos = getPos();
          try {
            return EString.read(this);
          } catch (final IOException e) {
          }
          setPos(savePos);
        }
        return EList.read(this);

      case EExternal.smallTupleTag:
      case EExternal.largeTupleTag:
        return ETuple.read(this);

      case EExternal.binTag:
        return EBinary.read(this);

      case EExternal.bitBinTag:
        return EBitString.read(this);

      case EExternal.compressedTag:
        return read_compressed();

      case EExternal.newFunTag:
      case EExternal.funTag:
        return EFun.read(this);

      case EExternal.externalFunTag:
        return read_external_fun();

      default:
        throw new IOException("Unknown data type: " + tag + " at position " + getPos());
    }
  }