示例#1
0
文件: prims.cpp 项目: AdamSpitz/klein
oop_t string_canonicalize_prim (oop_t rcvr, oop_t* argsp, oop_t current_activation, oop_t* new_actp) {
    if (!is_byteVector(rcvr))
        return primitive_fail_string(BADTYPEERROR);

    ByteVectorObj* bv = ByteVectorObj::from(rcvr);
    return StringObj::intern(bv->bytes(), bv->indexableSize());
}
示例#2
0
oop_t ByteVectorObj::clone_for_C_string(char* cString, ByteVectorObj** addrp, fint length) {
  fint n = (length == -1) ? length_of_C_string(cString)
                          : length;
  
  ByteVectorObj* addr;
  oop_t new_bv = clone_and_resize(n, 0, &addr, false);
  if (addrp) *addrp = addr;
  
  char *srcp = cString, *dstp = addr->bytes(), *endp = cString + n;
  while (srcp != endp)
    *dstp++ = *srcp++;
  
  return new_bv;
}
示例#3
0
void ByteVectorObj::print_byteVector(oop_t oop) {
  printf("byte array: {");
  if (MemObj::from(oop)->is_map()) {
    printf("...");
  } else {
    ByteVectorObj* obj = ByteVectorObj::from(oop);
    bool first = true;
    char* p =         obj->bytes();
    char* end = p +   obj->indexableSize();
    char* end2 = p + VectorPrintLimit < end ? p + VectorPrintLimit : end;
    for (; p < end2; p ++) {
      if (first) first = false;
      else printf(", ");
      printf("%ld", long(*p));
    }
    if (end != end2) {
      printf(", ... (%d more elements) ", end - end2);
    }
  }
  printf("} ");
}