示例#1
0
void Object::printToFd(int fd) {
  RawObject *raw = unTag<RawObject>();
  switch (getTag()) {
  case RawObject::kPairTag:
    dprintf(fd, "<Pair @%p>", raw);
    break;

  case RawObject::kSymbolTag:
    dprintf(fd, "<Symbol %s>", raw->as<const char *>());
    break;

  case RawObject::kSingletonTag:
    if (this == newNil()) {
      dprintf(fd, "<Nil>");
    }
    else {
      dprintf(fd, "<Unknown-singleton %p>", this);
    }
    break;

  case RawObject::kFixnumTag:
    dprintf(fd, "<Fixnum %ld>", fromFixnum());
    break;

  case RawObject::kClosureTag:
    dprintf(fd, "<Closure ");
    raw->cloInfo()->funcName()->printToFd(fd);
    dprintf(fd, " @%p>", raw);
    break;

  case RawObject::kVectorTag:
    dprintf(fd, "<Vector %p>", raw);
    break;

  default:
    dprintf(fd, "<Unknown-ptr %p>", this);
    break;
  }
}
示例#2
0
void Object::displayDetail(int fd) {
  RawObject *raw = unTag<RawObject>();
  switch (getTag()) {
  case RawObject::kPairTag:
    dprintf(fd, "(");
    displayListDetail(fd);
    dprintf(fd, ")");
    break;

  case RawObject::kSymbolTag:
    dprintf(fd, "%s", raw->as<const char *>());
    break;

  case RawObject::kSingletonTag:
    if (this == newNil()) {
      dprintf(fd, "()");
    }
    else if (this == newTrue()) {
      dprintf(fd, "#t");
    }
    else if (this == newFalse()) {
      dprintf(fd, "#f");
    }
    else if (this == newVoid()) {
      dprintf(fd, "<void>");
    }
    else {
      dprintf(fd, "<Unknown-singleton %p>", this);
    }
    break;

  case RawObject::kFixnumTag:
    dprintf(fd, "%ld", fromFixnum());
    break;

  case RawObject::kClosureTag:
    if (raw->cloInfo()) {
      dprintf(fd, "<Closure ");
      raw->cloInfo()->funcName()->displayDetail(fd);
      dprintf(fd, ">");
    }
    else {
      // info table is null during compilation
      dprintf(fd, "<Semi-Closure %p>", raw);
    }
    break;

  case RawObject::kVectorTag:
  {
    dprintf(fd, "(#");
    for (intptr_t i = 0, len = raw->vectorSize(); i < len; ++i) {
      dprintf(fd, " ");
      raw->vectorAt(i)->displayDetail(fd);
    }
    dprintf(fd, ")");
    break;
  }

  default:
    dprintf(fd, "<Unknown-ptr %p>", this);
    break;
  }
}