Permalink
Browse files

The great type renaming

  • Loading branch information...
1 parent 7f48eb2 commit 7c0a59f7a9b48b0098f8949075c9d5e774bc5112 Slava Pestov committed May 4, 2009
Showing with 2,226 additions and 2,245 deletions.
  1. +54 −54 vm/alien.cpp
  2. +6 −6 vm/alien.hpp
  3. +32 −32 vm/arrays.cpp
  4. +12 −12 vm/arrays.hpp
  5. +140 −140 vm/bignum.cpp
  6. +62 −62 vm/bignum.hpp
  7. +5 −5 vm/bignumint.hpp
  8. +1 −1 vm/booleans.cpp
  9. +2 −2 vm/booleans.hpp
  10. +22 −22 vm/byte_arrays.cpp
  11. +6 −6 vm/byte_arrays.hpp
  12. +59 −59 vm/callstack.cpp
  13. +13 −13 vm/callstack.hpp
  14. +137 −137 vm/code_block.cpp
  15. +21 −21 vm/code_block.hpp
  16. +55 −55 vm/code_gc.cpp
  17. +28 −28 vm/code_gc.hpp
  18. +49 −49 vm/code_heap.cpp
  19. +8 −8 vm/code_heap.hpp
  20. +48 −48 vm/contexts.cpp
  21. +15 −15 vm/contexts.hpp
  22. +6 −8 vm/cpu-arm.hpp
  23. +8 −8 vm/cpu-ppc.hpp
  24. +2 −2 vm/cpu-x86.32.hpp
  25. +2 −2 vm/cpu-x86.64.hpp
  26. +13 −13 vm/cpu-x86.hpp
  27. +125 −125 vm/data_gc.cpp
  28. +39 −31 vm/data_gc.hpp
  29. +124 −135 vm/data_heap.cpp
  30. +54 −63 vm/data_heap.hpp
  31. +76 −76 vm/debug.cpp
  32. +3 −3 vm/debug.hpp
  33. +62 −63 vm/dispatch.cpp
  34. +4 −4 vm/dispatch.hpp
  35. +14 −14 vm/errors.cpp
  36. +12 −12 vm/errors.hpp
  37. +24 −24 vm/factor.cpp
  38. +6 −6 vm/factor.hpp
  39. +8 −8 vm/float_bits.hpp
  40. +8 −8 vm/generic_arrays.hpp
  41. +60 −60 vm/image.cpp
  42. +21 −21 vm/image.hpp
  43. +64 −64 vm/inline_cache.cpp
  44. +2 −2 vm/inline_cache.hpp
  45. +12 −12 vm/io.cpp
  46. +22 −24 vm/jit.cpp
  47. +20 −20 vm/jit.hpp
  48. +113 −121 vm/layouts.hpp
  49. +4 −4 vm/local_roots.cpp
  50. +12 −12 vm/local_roots.hpp
  51. +3 −3 vm/mach_signal.cpp
  52. +1 −1 vm/master.hpp
  53. +77 −77 vm/math.cpp
  54. +36 −36 vm/math.hpp
  55. +1 −1 vm/os-genunix.cpp
  56. +1 −1 vm/os-genunix.hpp
  57. +1 −1 vm/os-linux-arm.cpp
  58. +1 −1 vm/os-linux-arm.hpp
  59. +1 −1 vm/os-linux-ppc.hpp
  60. +2 −2 vm/os-macosx-ppc.hpp
  61. +1 −1 vm/os-macosx-x86.32.hpp
  62. +1 −1 vm/os-macosx-x86.64.hpp
  63. +1 −1 vm/os-macosx.hpp
  64. +3 −3 vm/os-macosx.mm
  65. +17 −17 vm/os-unix.cpp
  66. +10 −10 vm/os-unix.hpp
  67. +2 −2 vm/os-windows-ce.cpp
  68. +3 −3 vm/os-windows-ce.hpp
  69. +3 −3 vm/os-windows-nt.cpp
  70. +2 −2 vm/os-windows-nt.hpp
  71. +18 −18 vm/os-windows.cpp
  72. +12 −12 vm/os-windows.hpp
  73. +0 −2 vm/primitives.hpp
  74. +7 −7 vm/profiler.cpp
  75. +1 −1 vm/profiler.hpp
  76. +65 −65 vm/quotations.cpp
  77. +14 −14 vm/quotations.hpp
  78. +21 −21 vm/run.cpp
  79. +5 −5 vm/run.hpp
  80. +4 −4 vm/segments.hpp
  81. +7 −7 vm/stacks.hpp
  82. +69 −71 vm/strings.cpp
  83. +8 −8 vm/strings.hpp
  84. +14 −14 vm/tagged.hpp
  85. +15 −15 vm/tuples.cpp
  86. +3 −14 vm/tuples.hpp
  87. +12 −12 vm/utilities.cpp
  88. +6 −6 vm/utilities.hpp
  89. +35 −38 vm/words.cpp
  90. +3 −3 vm/words.hpp
  91. +3 −3 vm/write_barrier.cpp
  92. +42 −18 vm/write_barrier.hpp
View
@@ -5,55 +5,55 @@ namespace factor
/* gets the address of an object representing a C pointer, with the
intention of storing the pointer across code which may potentially GC. */
-char *pinned_alien_offset(CELL object)
+char *pinned_alien_offset(cell obj)
{
- switch(tagged<F_OBJECT>(object).type())
+ switch(tagged<object>(obj).type())
{
case ALIEN_TYPE:
- F_ALIEN *alien = untag<F_ALIEN>(object);
- if(alien->expired != F)
- general_error(ERROR_EXPIRED,object,F,NULL);
- return pinned_alien_offset(alien->alien) + alien->displacement;
+ alien *ptr = untag<alien>(obj);
+ if(ptr->expired != F)
+ general_error(ERROR_EXPIRED,obj,F,NULL);
+ return pinned_alien_offset(ptr->alien) + ptr->displacement;
case F_TYPE:
return NULL;
default:
- type_error(ALIEN_TYPE,object);
+ type_error(ALIEN_TYPE,obj);
return NULL; /* can't happen */
}
}
/* make an alien */
-CELL allot_alien(CELL delegate_, CELL displacement)
+cell allot_alien(cell delegate_, cell displacement)
{
- gc_root<F_OBJECT> delegate(delegate_);
- gc_root<F_ALIEN> alien(allot<F_ALIEN>(sizeof(F_ALIEN)));
+ gc_root<object> delegate(delegate_);
+ gc_root<alien> new_alien(allot<alien>(sizeof(alien)));
if(delegate.type_p(ALIEN_TYPE))
{
- tagged<F_ALIEN> delegate_alien = delegate.as<F_ALIEN>();
+ tagged<alien> delegate_alien = delegate.as<alien>();
displacement += delegate_alien->displacement;
- alien->alien = delegate_alien->alien;
+ new_alien->alien = delegate_alien->alien;
}
else
- alien->alien = delegate.value();
+ new_alien->alien = delegate.value();
- alien->displacement = displacement;
- alien->expired = F;
+ new_alien->displacement = displacement;
+ new_alien->expired = F;
- return alien.value();
+ return new_alien.value();
}
/* make an alien pointing at an offset of another alien */
PRIMITIVE(displaced_alien)
{
- CELL alien = dpop();
- CELL displacement = to_cell(dpop());
+ cell alien = dpop();
+ cell displacement = to_cell(dpop());
if(alien == F && displacement == 0)
dpush(F);
else
{
- switch(tagged<F_OBJECT>(alien).type())
+ switch(tagged<object>(alien).type())
{
case BYTE_ARRAY_TYPE:
case ALIEN_TYPE:
@@ -71,13 +71,13 @@ PRIMITIVE(displaced_alien)
if the object is a byte array, as a sanity check. */
PRIMITIVE(alien_address)
{
- box_unsigned_cell((CELL)pinned_alien_offset(dpop()));
+ box_unsigned_cell((cell)pinned_alien_offset(dpop()));
}
/* pop ( alien n ) from datastack, return alien's address plus n */
static void *alien_pointer(void)
{
- F_FIXNUM offset = to_fixnum(dpop());
+ fixnum offset = to_fixnum(dpop());
return unbox_alien() + offset;
}
@@ -94,8 +94,8 @@ static void *alien_pointer(void)
*ptr = value; \
}
-DEFINE_ALIEN_ACCESSOR(signed_cell,F_FIXNUM,box_signed_cell,to_fixnum)
-DEFINE_ALIEN_ACCESSOR(unsigned_cell,CELL,box_unsigned_cell,to_cell)
+DEFINE_ALIEN_ACCESSOR(signed_cell,fixnum,box_signed_cell,to_fixnum)
+DEFINE_ALIEN_ACCESSOR(unsigned_cell,cell,box_unsigned_cell,to_cell)
DEFINE_ALIEN_ACCESSOR(signed_8,s64,box_signed_8,to_signed_8)
DEFINE_ALIEN_ACCESSOR(unsigned_8,u64,box_unsigned_8,to_unsigned_8)
DEFINE_ALIEN_ACCESSOR(signed_4,s32,box_signed_4,to_fixnum)
@@ -111,9 +111,9 @@ DEFINE_ALIEN_ACCESSOR(cell,void *,box_alien,pinned_alien_offset)
/* open a native library and push a handle */
PRIMITIVE(dlopen)
{
- gc_root<F_BYTE_ARRAY> path(dpop());
+ gc_root<byte_array> path(dpop());
path.untag_check();
- gc_root<F_DLL> dll(allot<F_DLL>(sizeof(F_DLL)));
+ gc_root<dll> dll(allot<dll>(sizeof(dll)));
dll->path = path.value();
ffi_dlopen(dll.untagged());
dpush(dll.value());
@@ -122,18 +122,19 @@ PRIMITIVE(dlopen)
/* look up a symbol in a native library */
PRIMITIVE(dlsym)
{
- gc_root<F_OBJECT> dll(dpop());
- gc_root<F_BYTE_ARRAY> name(dpop());
- dll.untag_check();
+ gc_root<object> library(dpop());
+ gc_root<byte_array> name(dpop());
name.untag_check();
- F_CHAR *sym = (F_CHAR *)(name.untagged() + 1);
+ vm_char *sym = (vm_char *)(name.untagged() + 1);
- if(dll.value() == F)
+ if(library.value() == F)
box_alien(ffi_dlsym(NULL,sym));
else
{
- tagged<F_DLL> d = dll.as<F_DLL>();
+ tagged<dll> d = library.as<dll>();
+ d.untag_check();
+
if(d->dll == NULL)
dpush(F);
else
@@ -144,35 +145,34 @@ PRIMITIVE(dlsym)
/* close a native library handle */
PRIMITIVE(dlclose)
{
- ffi_dlclose(untag_check<F_DLL>(dpop()));
+ ffi_dlclose(untag_check<dll>(dpop()));
}
PRIMITIVE(dll_validp)
{
- CELL dll = dpop();
- if(dll == F)
+ cell library = dpop();
+ if(library == F)
dpush(T);
else
- dpush(tagged<F_DLL>(dll)->dll == NULL ? F : T);
+ dpush(tagged<dll>(library)->dll == NULL ? F : T);
}
/* gets the address of an object representing a C pointer */
-VM_C_API char *alien_offset(CELL object)
+VM_C_API char *alien_offset(cell obj)
{
- switch(tagged<F_OBJECT>(object).type())
+ switch(tagged<object>(obj).type())
{
case BYTE_ARRAY_TYPE:
- F_BYTE_ARRAY *byte_array = untag<F_BYTE_ARRAY>(object);
- return (char *)(byte_array + 1);
+ return untag<byte_array>(obj)->data<char>();
case ALIEN_TYPE:
- F_ALIEN *alien = untag<F_ALIEN>(object);
- if(alien->expired != F)
- general_error(ERROR_EXPIRED,object,F,NULL);
- return alien_offset(alien->alien) + alien->displacement;
+ alien *ptr = untag<alien>(obj);
+ if(ptr->expired != F)
+ general_error(ERROR_EXPIRED,obj,F,NULL);
+ return alien_offset(ptr->alien) + ptr->displacement;
case F_TYPE:
return NULL;
default:
- type_error(ALIEN_TYPE,object);
+ type_error(ALIEN_TYPE,obj);
return NULL; /* can't happen */
}
}
@@ -189,36 +189,36 @@ VM_C_API void box_alien(void *ptr)
if(ptr == NULL)
dpush(F);
else
- dpush(allot_alien(F,(CELL)ptr));
+ dpush(allot_alien(F,(cell)ptr));
}
/* for FFI calls passing structs by value */
-VM_C_API void to_value_struct(CELL src, void *dest, CELL size)
+VM_C_API void to_value_struct(cell src, void *dest, cell size)
{
memcpy(dest,alien_offset(src),size);
}
/* for FFI callbacks receiving structs by value */
-VM_C_API void box_value_struct(void *src, CELL size)
+VM_C_API void box_value_struct(void *src, cell size)
{
- F_BYTE_ARRAY *array = allot_byte_array(size);
- memcpy(array + 1,src,size);
- dpush(tag<F_BYTE_ARRAY>(array));
+ byte_array *bytes = allot_byte_array(size);
+ memcpy(bytes->data<void>(),src,size);
+ dpush(tag<byte_array>(bytes));
}
/* On some x86 OSes, structs <= 8 bytes are returned in registers. */
-VM_C_API void box_small_struct(CELL x, CELL y, CELL size)
+VM_C_API void box_small_struct(cell x, cell y, cell size)
{
- CELL data[2];
+ cell data[2];
data[0] = x;
data[1] = y;
box_value_struct(data,size);
}
/* On OS X/PPC, complex numbers are returned in registers. */
-VM_C_API void box_medium_struct(CELL x1, CELL x2, CELL x3, CELL x4, CELL size)
+VM_C_API void box_medium_struct(cell x1, cell x2, cell x3, cell x4, cell size)
{
- CELL data[4];
+ cell data[4];
data[0] = x1;
data[1] = x2;
data[2] = x3;
View
@@ -1,7 +1,7 @@
namespace factor
{
-CELL allot_alien(CELL delegate, CELL displacement);
+cell allot_alien(cell delegate, cell displacement);
PRIMITIVE(displaced_alien);
PRIMITIVE(alien_address);
@@ -38,12 +38,12 @@ PRIMITIVE(dlsym);
PRIMITIVE(dlclose);
PRIMITIVE(dll_validp);
-VM_C_API char *alien_offset(CELL object);
+VM_C_API char *alien_offset(cell object);
VM_C_API char *unbox_alien(void);
VM_C_API void box_alien(void *ptr);
-VM_C_API void to_value_struct(CELL src, void *dest, CELL size);
-VM_C_API void box_value_struct(void *src, CELL size);
-VM_C_API void box_small_struct(CELL x, CELL y, CELL size);
-VM_C_API void box_medium_struct(CELL x1, CELL x2, CELL x3, CELL x4, CELL size);
+VM_C_API void to_value_struct(cell src, void *dest, cell size);
+VM_C_API void box_value_struct(void *src, cell size);
+VM_C_API void box_small_struct(cell x, cell y, cell size);
+VM_C_API void box_medium_struct(cell x1, cell x2, cell x3, cell x4, cell size);
}
View
@@ -4,58 +4,58 @@ namespace factor
{
/* make a new array with an initial element */
-F_ARRAY *allot_array(CELL capacity, CELL fill_)
+array *allot_array(cell capacity, cell fill_)
{
- gc_root<F_OBJECT> fill(fill_);
- gc_root<F_ARRAY> array(allot_array_internal<F_ARRAY>(capacity));
+ gc_root<object> fill(fill_);
+ gc_root<array> new_array(allot_array_internal<array>(capacity));
if(fill.value() == tag_fixnum(0))
- memset(array->data(),'\0',capacity * CELLS);
+ memset(new_array->data(),'\0',capacity * sizeof(cell));
else
{
/* No need for write barrier here. Either the object is in
the nursery, or it was allocated directly in tenured space
and the write barrier is already hit for us in that case. */
- CELL i;
+ cell i;
for(i = 0; i < capacity; i++)
- array->data()[i] = fill.value();
+ new_array->data()[i] = fill.value();
}
- return array.untagged();
+ return new_array.untagged();
}
/* push a new array on the stack */
PRIMITIVE(array)
{
- CELL initial = dpop();
- CELL size = unbox_array_size();
- dpush(tag<F_ARRAY>(allot_array(size,initial)));
+ cell initial = dpop();
+ cell size = unbox_array_size();
+ dpush(tag<array>(allot_array(size,initial)));
}
-CELL allot_array_1(CELL obj_)
+cell allot_array_1(cell obj_)
{
- gc_root<F_OBJECT> obj(obj_);
- gc_root<F_ARRAY> a(allot_array_internal<F_ARRAY>(1));
+ gc_root<object> obj(obj_);
+ gc_root<array> a(allot_array_internal<array>(1));
set_array_nth(a.untagged(),0,obj.value());
return a.value();
}
-CELL allot_array_2(CELL v1_, CELL v2_)
+cell allot_array_2(cell v1_, cell v2_)
{
- gc_root<F_OBJECT> v1(v1_);
- gc_root<F_OBJECT> v2(v2_);
- gc_root<F_ARRAY> a(allot_array_internal<F_ARRAY>(2));
+ gc_root<object> v1(v1_);
+ gc_root<object> v2(v2_);
+ gc_root<array> a(allot_array_internal<array>(2));
set_array_nth(a.untagged(),0,v1.value());
set_array_nth(a.untagged(),1,v2.value());
return a.value();
}
-CELL allot_array_4(CELL v1_, CELL v2_, CELL v3_, CELL v4_)
+cell allot_array_4(cell v1_, cell v2_, cell v3_, cell v4_)
{
- gc_root<F_OBJECT> v1(v1_);
- gc_root<F_OBJECT> v2(v2_);
- gc_root<F_OBJECT> v3(v3_);
- gc_root<F_OBJECT> v4(v4_);
- gc_root<F_ARRAY> a(allot_array_internal<F_ARRAY>(4));
+ gc_root<object> v1(v1_);
+ gc_root<object> v2(v2_);
+ gc_root<object> v3(v3_);
+ gc_root<object> v4(v4_);
+ gc_root<array> a(allot_array_internal<array>(4));
set_array_nth(a.untagged(),0,v1.value());
set_array_nth(a.untagged(),1,v2.value());
set_array_nth(a.untagged(),2,v3.value());
@@ -65,23 +65,23 @@ CELL allot_array_4(CELL v1_, CELL v2_, CELL v3_, CELL v4_)
PRIMITIVE(resize_array)
{
- F_ARRAY* array = untag_check<F_ARRAY>(dpop());
- CELL capacity = unbox_array_size();
- dpush(tag<F_ARRAY>(reallot_array(array,capacity)));
+ array* a = untag_check<array>(dpop());
+ cell capacity = unbox_array_size();
+ dpush(tag<array>(reallot_array(a,capacity)));
}
-void growable_array::add(CELL elt_)
+void growable_array::add(cell elt_)
{
- gc_root<F_OBJECT> elt(elt_);
- if(count == array_capacity(array.untagged()))
- array = reallot_array(array.untagged(),count * 2);
+ gc_root<object> elt(elt_);
+ if(count == array_capacity(elements.untagged()))
+ elements = reallot_array(elements.untagged(),count * 2);
- set_array_nth(array.untagged(),count++,elt.value());
+ set_array_nth(elements.untagged(),count++,elt.value());
}
void growable_array::trim()
{
- array = reallot_array(array.untagged(),count);
+ elements = reallot_array(elements.untagged(),count);
}
}
Oops, something went wrong.

0 comments on commit 7c0a59f

Please sign in to comment.