From 260a2de62808ca4ef632e341b239353f7ea41856 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Tue, 3 Jan 2017 15:48:45 -0500 Subject: [PATCH] Rename TC_CHARACTER_STRING to TC_BYTEVECTOR and TC_NULL to TC_FALSE. --- src/microcode/const.h | 4 ++-- src/microcode/debug.c | 4 ++-- src/microcode/fasl.h | 2 +- src/microcode/gcloop.c | 6 +++--- src/microcode/interp.c | 4 ++-- src/microcode/object.h | 26 +++++++++++++++----------- src/microcode/primutl.c | 2 +- src/microcode/sdata.h | 23 +++++++++-------------- src/microcode/string.c | 6 +++--- src/microcode/types.h | 10 ++++------ src/runtime/utabs.scm | 2 +- 11 files changed, 43 insertions(+), 46 deletions(-) diff --git a/src/microcode/const.h b/src/microcode/const.h index 592529940..12241bd32 100644 --- a/src/microcode/const.h +++ b/src/microcode/const.h @@ -99,9 +99,9 @@ USA. /* VMS preprocessor does not like line continuations in conditionals */ #define Are_The_Constants_Incompatible \ -((TC_NULL != 0x00) || (TC_CONSTANT != 0x08) || \ +((TC_FALSE != 0x00) || (TC_CONSTANT != 0x08) || \ (TC_FIXNUM != 0x1A) || (TC_BROKEN_HEART != 0x22) || \ - (TC_CHARACTER_STRING != 0x1E)) + (TC_BYTEVECTOR != 0x1E)) /* The values used above are in sdata.h and types.h, check for consistency if the check below fails. */ diff --git a/src/microcode/debug.c b/src/microcode/debug.c index ca6b9d430..cf400755d 100644 --- a/src/microcode/debug.c +++ b/src/microcode/debug.c @@ -379,7 +379,7 @@ do_printing (outf_channel stream, SCHEME_OBJECT Expr, bool Detailed) Expr = (MEMORY_REF ((MEMORY_REF (Expr, ASSIGN_NAME)), VARIABLE_SYMBOL)); goto SPrint; - case TC_CHARACTER_STRING: + case TC_BYTEVECTOR: print_string (stream, Expr); return; @@ -401,7 +401,7 @@ do_printing (outf_channel stream, SCHEME_OBJECT Expr, bool Detailed) print_list (stream, Expr); return; - case TC_NULL: + case TC_FALSE: break; case TC_UNINTERNED_SYMBOL: diff --git a/src/microcode/fasl.h b/src/microcode/fasl.h index 324db1de2..47bc3fbc5 100644 --- a/src/microcode/fasl.h +++ b/src/microcode/fasl.h @@ -89,7 +89,7 @@ USA. #define CI_BAND_P(P) ((OBJECT_TYPE (P)) == TC_CONSTANT) #define MAKE_CI_VERSION(b, v, a) \ - (MAKE_OBJECT (((b) ? TC_CONSTANT : TC_NULL), \ + (MAKE_OBJECT (((b) ? TC_CONSTANT : TC_FALSE), \ ((((unsigned long) (v)) << HALF_DATUM_LENGTH) \ | ((unsigned long) (a))))) diff --git a/src/microcode/gcloop.c b/src/microcode/gcloop.c index 14166156a..0b0e40552 100644 --- a/src/microcode/gcloop.c +++ b/src/microcode/gcloop.c @@ -892,7 +892,7 @@ gc_transport_weak_pair (SCHEME_OBJECT pair) if ((caddr != 0) && (ADDRESS_IN_FROMSPACE_P (caddr))) { - WRITE_TOSPACE (new_addr, (OBJECT_NEW_TYPE (TC_NULL, old_car))); + WRITE_TOSPACE (new_addr, (OBJECT_NEW_TYPE (TC_FALSE, old_car))); (old_addr[1]) = ((weak_chain == 0) ? (MAKE_OBJECT ((OBJECT_TYPE (old_car)), 0)) @@ -1251,7 +1251,7 @@ finalize_gc_object_references (void) gc_type_t gc_type_map [N_TYPE_CODES] = { - GC_NON_POINTER, /* TC_NULL,etc */ + GC_NON_POINTER, /* TC_FALSE */ GC_PAIR, /* TC_LIST */ GC_NON_POINTER, /* TC_CHARACTER */ GC_PAIR, /* TC_SCODE_QUOTE */ @@ -1281,7 +1281,7 @@ gc_type_t gc_type_map [N_TYPE_CODES] = GC_UNDEFINED, /* was TC_PCOMB1 */ GC_VECTOR, /* TC_CONTROL_POINT */ GC_PAIR, /* TC_INTERNED_SYMBOL */ - GC_VECTOR, /* TC_CHARACTER_STRING,TC_VECTOR_8B */ + GC_VECTOR, /* TC_BYTEVECTOR */ GC_PAIR, /* TC_ACCESS */ GC_TRIPLE, /* TC_HUNK3_A */ GC_PAIR, /* TC_DEFINITION */ diff --git a/src/microcode/interp.c b/src/microcode/interp.c index fce91c35c..35bf07f0b 100644 --- a/src/microcode/interp.c +++ b/src/microcode/interp.c @@ -407,7 +407,7 @@ Interpret (int pop_return_p) { case TC_BIG_FIXNUM: /* The self evaluating items */ case TC_BIG_FLONUM: - case TC_CHARACTER_STRING: + case TC_BYTEVECTOR: case TC_CHARACTER: case TC_COMPILED_CODE_BLOCK: case TC_COMPLEX: @@ -422,7 +422,7 @@ Interpret (int pop_return_p) case TC_INTERNED_SYMBOL: case TC_LIST: case TC_NON_MARKED_VECTOR: - case TC_NULL: + case TC_FALSE: case TC_PRIMITIVE: case TC_PROCEDURE: case TC_QUAD: diff --git a/src/microcode/object.h b/src/microcode/object.h index 2734058d8..035e7e786 100644 --- a/src/microcode/object.h +++ b/src/microcode/object.h @@ -178,7 +178,7 @@ extern SCHEME_OBJECT * memory_base; #define FLONUM_P(object) ((OBJECT_TYPE (object)) == TC_BIG_FLONUM) #define COMPLEX_P(object) ((OBJECT_TYPE (object)) == TC_COMPLEX) #define CHARACTER_P(object) ((OBJECT_TYPE (object)) == TC_CHARACTER) -#define STRING_P(object) ((OBJECT_TYPE (object)) == TC_CHARACTER_STRING) +#define BYTEVECTOR_P(object) ((OBJECT_TYPE (object)) == TC_BYTEVECTOR) #define BIT_STRING_P(object) ((OBJECT_TYPE (object)) == TC_BIT_STRING) #define CELL_P(object) ((OBJECT_TYPE (object)) == TC_CELL) #define PAIR_P(object) ((OBJECT_TYPE (object)) == TC_LIST) @@ -255,35 +255,38 @@ extern SCHEME_OBJECT * memory_base; /* String Operations */ +#define STRING_P BYTEVECTOR_P + /* Add 1 byte to length to account for '\0' at end of string. Add 1 word to length to account for string header word. */ #define STRING_LENGTH_TO_GC_LENGTH(n_chars) \ - ((BYTES_TO_WORDS ((n_chars) + 1)) + 1) + ((BYTES_TO_WORDS ((n_chars) + 1)) + BYTEVECTOR_LENGTH_SIZE) #define STRING_LENGTH(s) \ - (OBJECT_DATUM (MEMORY_REF ((s), STRING_LENGTH_INDEX))) + (OBJECT_DATUM (MEMORY_REF ((s), BYTEVECTOR_LENGTH_INDEX))) #define SET_STRING_LENGTH(s, n_chars) do \ { \ MEMORY_SET ((s), \ - STRING_LENGTH_INDEX, \ + BYTEVECTOR_LENGTH_INDEX, \ (MAKE_OBJECT (0, (n_chars)))); \ STRING_SET ((s), (n_chars), '\0'); \ } while (0) /* Subtract 1 to account for the fact that we maintain a '\0' at the end of the string. */ -#define MAXIMUM_STRING_LENGTH(s) \ - ((((VECTOR_LENGTH (s)) - 1) * (sizeof (SCHEME_OBJECT))) - 1) +#define MAXIMUM_STRING_LENGTH(s) \ + ((((VECTOR_LENGTH (s)) - BYTEVECTOR_LENGTH_SIZE) * (sizeof (SCHEME_OBJECT))) \ + - 1) #define SET_MAXIMUM_STRING_LENGTH(s, n_chars) \ (SET_VECTOR_LENGTH ((s), (STRING_LENGTH_TO_GC_LENGTH (n_chars)))) #define STRING_LOC(s, i) \ - (((unsigned char *) (MEMORY_LOC (s, STRING_CHARS))) + (i)) + (((unsigned char *) (MEMORY_LOC (s, BYTEVECTOR_DATA))) + (i)) -#define STRING_POINTER(s) ((char *) (MEMORY_LOC (s, STRING_CHARS))) -#define STRING_BYTE_PTR(s) ((byte_t *) (MEMORY_LOC (s, STRING_CHARS))) +#define STRING_POINTER(s) ((char *) (MEMORY_LOC (s, BYTEVECTOR_DATA))) +#define STRING_BYTE_PTR(s) ((byte_t *) (MEMORY_LOC (s, BYTEVECTOR_DATA))) #define STRING_REF(s, i) (* (STRING_LOC ((s), (i)))) #define STRING_SET(s, i, c) ((* (STRING_LOC ((s), (i)))) = (c)) @@ -356,6 +359,8 @@ extern SCHEME_OBJECT * memory_base; #define FIXNUM_TO_ULONG_P(fixnum) (((OBJECT_DATUM (fixnum)) & SIGN_MASK) == 0) #define FIXNUM_TO_ULONG(fixnum) (OBJECT_DATUM (fixnum)) +#define FIXNUM_ZERO (ULONG_TO_FIXNUM (0)) + #define FIXNUM_TO_DOUBLE(fixnum) ((double) (FIXNUM_TO_LONG (fixnum))) #define DOUBLE_TO_FIXNUM_P(number) \ @@ -482,12 +487,11 @@ extern SCHEME_OBJECT * memory_base; 9 '() */ -#define SHARP_F MAKE_OBJECT (TC_NULL, 0) +#define SHARP_F MAKE_OBJECT (TC_FALSE, 0) #define SHARP_T MAKE_OBJECT (TC_CONSTANT, 0) #define UNSPECIFIC MAKE_OBJECT (TC_CONSTANT, 1) #define DEFAULT_OBJECT MAKE_OBJECT (TC_CONSTANT, 7) #define EMPTY_LIST MAKE_OBJECT (TC_CONSTANT, 9) -#define FIXNUM_ZERO MAKE_OBJECT (TC_FIXNUM, 0) #define BROKEN_HEART_ZERO MAKE_OBJECT (TC_BROKEN_HEART, 0) /* Last immediate reference trap. */ diff --git a/src/microcode/primutl.c b/src/microcode/primutl.c index d73688e5e..74c64e681 100644 --- a/src/microcode/primutl.c +++ b/src/microcode/primutl.c @@ -515,7 +515,7 @@ import_primitive_table (SCHEME_OBJECT * entries, long arity = (FIXNUM_TO_LONG (*entries++)); SCHEME_OBJECT prim = (find_primitive - ((MAKE_POINTER_OBJECT (TC_CHARACTER_STRING, entries)), + ((MAKE_POINTER_OBJECT (TC_BYTEVECTOR, entries)), true, true, arity)); if (!PRIMITIVE_P (prim)) diff --git a/src/microcode/sdata.h b/src/microcode/sdata.h index b550fb92d..3041ca611 100644 --- a/src/microcode/sdata.h +++ b/src/microcode/sdata.h @@ -58,20 +58,15 @@ USA. */ #define CELL_CONTENTS 0 -/* CHARACTER - * Not currently used. Intended ultimately to complete the abstraction - * of strings. This will probably be removed eventually. - */ - -/* CHARACTER_STRING - * Synonym for 8B_VECTOR. Used to store strings of characters. Format - * consists of the normal non-marked vector header (STRING_HEADER) - * followed by the number of characters in the string (as a FIXNUM), - * followed by the characters themselves. - */ -#define STRING_HEADER 0 -#define STRING_LENGTH_INDEX 1 -#define STRING_CHARS 2 +/* BYTEVECTOR + * Format consists of the normal non-marked vector header + * (BYTEVECTOR_HEADER) followed by the number of bytes in the vector + * (with type-code 0), followed by the bytes themselves. + */ +#define BYTEVECTOR_HEADER 0 +#define BYTEVECTOR_LENGTH_INDEX 1 +#define BYTEVECTOR_LENGTH_SIZE 1 +#define BYTEVECTOR_DATA 2 /* COMPILED_PROCEDURE */ #define COMP_PROCEDURE_ADDRESS 0 diff --git a/src/microcode/string.c b/src/microcode/string.c index ae254323b..fc863da3e 100644 --- a/src/microcode/string.c +++ b/src/microcode/string.c @@ -33,7 +33,7 @@ SCHEME_OBJECT allocate_string (unsigned long nbytes) { SCHEME_OBJECT result - = (allocate_non_marked_vector (TC_CHARACTER_STRING, + = (allocate_non_marked_vector (TC_BYTEVECTOR, (STRING_LENGTH_TO_GC_LENGTH (nbytes)), true)); SET_STRING_LENGTH (result, nbytes); @@ -44,7 +44,7 @@ SCHEME_OBJECT allocate_string_no_gc (unsigned long nbytes) { SCHEME_OBJECT result - = (allocate_non_marked_vector (TC_CHARACTER_STRING, + = (allocate_non_marked_vector (TC_BYTEVECTOR, (STRING_LENGTH_TO_GC_LENGTH (nbytes)), false)); SET_STRING_LENGTH (result, nbytes); @@ -140,7 +140,7 @@ DEFINE_PRIMITIVE ("SET-STRING-MAXIMUM-LENGTH!", Prim_set_string_maximum_length, SET_STRING_LENGTH (string, length); MEMORY_SET (string, - STRING_HEADER, + BYTEVECTOR_HEADER, (MAKE_OBJECT (TC_MANIFEST_NM_VECTOR, ((BYTES_TO_WORDS (length + 1)) + 1)))); } diff --git a/src/microcode/types.h b/src/microcode/types.h index e5dc4b5a9..45f835a66 100644 --- a/src/microcode/types.h +++ b/src/microcode/types.h @@ -26,7 +26,7 @@ USA. /* Type code definitions */ -#define TC_NULL 0x00 +#define TC_FALSE 0x00 #define TC_LIST 0x01 #define TC_CHARACTER 0x02 #define TC_SCODE_QUOTE 0x03 @@ -56,7 +56,7 @@ USA. /* #define TC_PCOMB1 0x1B */ #define TC_CONTROL_POINT 0x1C #define TC_INTERNED_SYMBOL 0x1D -#define TC_CHARACTER_STRING 0x1E +#define TC_BYTEVECTOR 0x1E #define TC_ACCESS 0x1F #define TC_HUNK3_A 0x20 #define TC_DEFINITION 0x21 @@ -134,7 +134,7 @@ USA. /* 0x1B */ 0, \ /* 0x1C */ "control-point", \ /* 0x1D */ "interned-symbol", \ - /* 0x1e */ "string", \ + /* 0x1e */ "bytevector", \ /* 0x1f */ "access", \ /* 0x20 */ "hunk3-a", \ /* 0x21 */ "definition", \ @@ -172,10 +172,8 @@ USA. /* Aliases */ -#define TC_FALSE TC_NULL -#define TC_MANIFEST_VECTOR TC_NULL +#define TC_MANIFEST_VECTOR TC_FALSE #define TC_BIT_STRING TC_VECTOR_1B -#define TC_VECTOR_8B TC_CHARACTER_STRING #define TC_HUNK3 TC_HUNK3_B #define UNMARKED_HISTORY_TYPE TC_HUNK3_A diff --git a/src/runtime/utabs.scm b/src/runtime/utabs.scm index 59753b279..1fc9b9729 100644 --- a/src/runtime/utabs.scm +++ b/src/runtime/utabs.scm @@ -265,7 +265,7 @@ USA. (BIGNUM BIG-FIXNUM) (PROMISE DELAYED) (FIXNUM ADDRESS POSITIVE-FIXNUM NEGATIVE-FIXNUM) - (STRING CHARACTER-STRING VECTOR-8B) + (BYTEVECTOR STRING CHARACTER-STRING VECTOR-8B) (HUNK3-A UNMARKED-HISTORY) (TRIPLE HUNK3 HUNK3-B MARKED-HISTORY) (REFERENCE-TRAP UNASSIGNED) -- 2.25.1