]> gitweb.factorcode.org Git - factor.git/blobdiff - vm/strings.cpp
Put brackets around ipv6 addresses in `inet6 present`
[factor.git] / vm / strings.cpp
index f73ae0802a080d8b5a6939fdf81ffbbc6d4d777c..bcde346294c19ddeacda45650a5e3136bd1fb832 100644 (file)
@@ -2,7 +2,7 @@
 
 namespace factor {
 
-/* Allocates memory */
+// Allocates memory
 string* factor_vm::allot_string_internal(cell capacity) {
   string* str = allot<string>(string_size(capacity));
 
@@ -13,13 +13,13 @@ string* factor_vm::allot_string_internal(cell capacity) {
   return str;
 }
 
-/* Allocates memory */
+// Allocates memory
 void factor_vm::fill_string(string* str_, cell start, cell capacity,
                             cell fill) {
   data_root<string> str(str_, this);
 
   if (fill <= 0x7f)
-    memset(&str->data()[start], (u8) fill, capacity - start);
+    memset(&str->data()[start], (uint8_t)fill, capacity - start);
   else {
     byte_array* aux;
     if (to_boolean(str->aux))
@@ -31,22 +31,22 @@ void factor_vm::fill_string(string* str_, cell start, cell capacity,
       write_barrier(&str->aux);
     }
 
-    u8 lo_fill = (u8)((fill & 0x7f) | 0x80);
-    u16 hi_fill = (u16)((fill >> 7) ^ 0x1);
+    uint8_t lo_fill = (uint8_t)((fill & 0x7f) | 0x80);
+    uint16_t hi_fill = (uint16_t)((fill >> 7) ^ 0x1);
     memset(&str->data()[start], lo_fill, capacity - start);
-    memset_2(&aux->data<u16>()[start], hi_fill,
-             (capacity - start) * sizeof(u16));
+    memset_2(&aux->data<uint16_t>()[start], hi_fill,
+             (capacity - start) * sizeof(uint16_t));
   }
 }
 
-/* Allocates memory */
+// Allocates memory
 string* factor_vm::allot_string(cell capacity, cell fill) {
   data_root<string> str(allot_string_internal(capacity), this);
   fill_string(str.untagged(), 0, capacity, fill);
   return str.untagged();
 }
 
-/* Allocates memory */
+// Allocates memory
 void factor_vm::primitive_string() {
   cell initial = to_cell(ctx->pop());
   cell length = unbox_array_size();
@@ -54,13 +54,13 @@ void factor_vm::primitive_string() {
 }
 
 bool factor_vm::reallot_string_in_place_p(string* str, cell capacity) {
-  return nursery.contains_p(str) &&
+  return data->nursery->contains_p(str) &&
          (!to_boolean(str->aux) ||
-          nursery.contains_p(untag<byte_array>(str->aux))) &&
+          data->nursery->contains_p(untag<byte_array>(str->aux))) &&
          capacity <= string_capacity(str);
 }
 
-/* Allocates memory */
+// Allocates memory
 string* factor_vm::reallot_string(string* str_, cell capacity) {
   data_root<string> str(str_, this);
 
@@ -88,7 +88,8 @@ string* factor_vm::reallot_string(string* str_, cell capacity) {
       write_barrier(&new_str->aux);
 
       byte_array* aux = untag<byte_array>(str->aux);
-      memcpy(new_aux->data<u16>(), aux->data<u16>(), to_copy * sizeof(u16));
+      memcpy(new_aux->data<uint16_t>(), aux->data<uint16_t>(),
+             to_copy * sizeof(uint16_t));
     }
 
     fill_string(new_str.untagged(), to_copy, capacity, '\0');
@@ -96,10 +97,10 @@ string* factor_vm::reallot_string(string* str_, cell capacity) {
   }
 }
 
-/* Allocates memory */
+// Allocates memory
 void factor_vm::primitive_resize_string() {
   data_root<string> str(ctx->pop(), this);
-  str.untag_check(this);
+  check_tagged(str);
   cell capacity = unbox_array_size();
   ctx->push(tag<string>(reallot_string(str.untagged(), capacity)));
 }
@@ -108,7 +109,7 @@ void factor_vm::primitive_set_string_nth_fast() {
   string* str = untag<string>(ctx->pop());
   cell index = untag_fixnum(ctx->pop());
   cell value = untag_fixnum(ctx->pop());
-  str->data()[index] = (u8) value;
+  str->data()[index] = (uint8_t)value;
 }
 
 }