core: Use assert_msg.
* src/mes.c: Use assert_msg instead of assert. * src/gc.c: Likewise. * src/hash.c: Likewise. * src/lib.c: Likewise. * src/math.c: Likewise. * src/module.c: Likewise. * src/posix.c: Likewise. * src/reader.c: Likewise. * src/string.c: Likewise. * src/struct.c: Likewise. * src/vector.c: Likewise. * simple.make (LIB_SOURCES): Add lib/mes/assert_msg.c.
This commit is contained in:
parent
cf22ba44ce
commit
6a96134eba
|
@ -52,6 +52,7 @@ int oputc (int c);
|
||||||
int oputs (char const *s);
|
int oputs (char const *s);
|
||||||
char *search_path (char const *file_name);
|
char *search_path (char const *file_name);
|
||||||
ssize_t _read (int fd, void *buffer, size_t size);
|
ssize_t _read (int fd, void *buffer, size_t size);
|
||||||
|
void assert_msg (int check, char *msg);
|
||||||
|
|
||||||
extern char *__brk;
|
extern char *__brk;
|
||||||
extern void (*__call_at_exit) (void);
|
extern void (*__call_at_exit) (void);
|
||||||
|
|
|
@ -62,6 +62,7 @@ MES_SOURCES = \
|
||||||
|
|
||||||
LIB_SOURCES = \
|
LIB_SOURCES = \
|
||||||
lib/mes/eputs.c \
|
lib/mes/eputs.c \
|
||||||
|
lib/mes/assert_msg.c \
|
||||||
lib/mes/itoa.c
|
lib/mes/itoa.c
|
||||||
|
|
||||||
M2_SOURCES = \
|
M2_SOURCES = \
|
||||||
|
|
5
src/gc.c
5
src/gc.c
|
@ -21,7 +21,6 @@
|
||||||
#include "mes/lib.h"
|
#include "mes/lib.h"
|
||||||
#include "mes/mes.h"
|
#include "mes/mes.h"
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -109,7 +108,7 @@ gc_up_arena () /*:((internal)) */
|
||||||
eputs (":");
|
eputs (":");
|
||||||
eputs (itoa (ARENA_SIZE - g_free));
|
eputs (itoa (ARENA_SIZE - g_free));
|
||||||
eputs ("\n");
|
eputs ("\n");
|
||||||
assert (0);
|
assert_msg (0, "0");
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
g_cells = p;
|
g_cells = p;
|
||||||
|
@ -308,7 +307,7 @@ SCM
|
||||||
gc_push_frame () /*:((internal)) */
|
gc_push_frame () /*:((internal)) */
|
||||||
{
|
{
|
||||||
if (g_stack < 5)
|
if (g_stack < 5)
|
||||||
assert (!"STACK FULL");
|
assert_msg (0, "STACK FULL");
|
||||||
g_stack_array[g_stack - 1] = cell_f;
|
g_stack_array[g_stack - 1] = cell_f;
|
||||||
g_stack_array[g_stack - 2] = r0;
|
g_stack_array[g_stack - 2] = r0;
|
||||||
g_stack_array[g_stack - 3] = r1;
|
g_stack_array[g_stack - 3] = r1;
|
||||||
|
|
11
src/hash.c
11
src/hash.c
|
@ -21,7 +21,6 @@
|
||||||
#include "mes/lib.h"
|
#include "mes/lib.h"
|
||||||
#include "mes/mes.h"
|
#include "mes/mes.h"
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -30,7 +29,7 @@ hash_cstring (char const *s, long size)
|
||||||
int hash = s[0] * 37;
|
int hash = s[0] * 37;
|
||||||
if (s[0] != 0 && s[1] != 0)
|
if (s[0] != 0 && s[1] != 0)
|
||||||
hash = hash + s[1] * 43;
|
hash = hash + s[1] * 43;
|
||||||
assert (size);
|
assert_msg (size, "size");
|
||||||
hash = hash % size;
|
hash = hash % size;
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
@ -48,21 +47,21 @@ hash_ (SCM x, long size)
|
||||||
{
|
{
|
||||||
if (TYPE (x) == TSTRING)
|
if (TYPE (x) == TSTRING)
|
||||||
return hash_cstring (CSTRING (x), size);
|
return hash_cstring (CSTRING (x), size);
|
||||||
assert (0);
|
assert_msg (0, "0");
|
||||||
return hashq_ (x, size);
|
return hashq_ (x, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCM
|
SCM
|
||||||
hashq (SCM x, SCM size)
|
hashq (SCM x, SCM size)
|
||||||
{
|
{
|
||||||
assert (0);
|
assert_msg (0, "0");
|
||||||
return MAKE_NUMBER (hashq_ (x, VALUE (size)));
|
return MAKE_NUMBER (hashq_ (x, VALUE (size)));
|
||||||
}
|
}
|
||||||
|
|
||||||
SCM
|
SCM
|
||||||
hash (SCM x, SCM size)
|
hash (SCM x, SCM size)
|
||||||
{
|
{
|
||||||
assert (0);
|
assert_msg (0, "0");
|
||||||
return MAKE_NUMBER (hash_ (x, VALUE (size)));
|
return MAKE_NUMBER (hash_ (x, VALUE (size)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,7 +236,7 @@ make_hash_table (SCM x)
|
||||||
long size = 0;
|
long size = 0;
|
||||||
if (TYPE (x) == TPAIR)
|
if (TYPE (x) == TPAIR)
|
||||||
{
|
{
|
||||||
assert (TYPE (x) == TNUMBER);
|
assert_msg (TYPE (x) == TNUMBER, "TYPE (x) == TNUMBER");
|
||||||
size = VALUE (x);
|
size = VALUE (x);
|
||||||
}
|
}
|
||||||
return make_hash_table_ (size);
|
return make_hash_table_ (size);
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#include "mes/lib.h"
|
#include "mes/lib.h"
|
||||||
#include "mes/mes.h"
|
#include "mes/mes.h"
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
int g_depth;
|
int g_depth;
|
||||||
|
@ -257,7 +256,7 @@ display_error_ (SCM x)
|
||||||
SCM
|
SCM
|
||||||
display_port_ (SCM x, SCM p)
|
display_port_ (SCM x, SCM p)
|
||||||
{
|
{
|
||||||
assert (TYPE (p) == TNUMBER);
|
assert_msg (TYPE (p) == TNUMBER, "TYPE (p) == TNUMBER");
|
||||||
return fdisplay_ (x, VALUE (p), 0);
|
return fdisplay_ (x, VALUE (p), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,7 +277,7 @@ write_error_ (SCM x)
|
||||||
SCM
|
SCM
|
||||||
write_port_ (SCM x, SCM p)
|
write_port_ (SCM x, SCM p)
|
||||||
{
|
{
|
||||||
assert (TYPE (p) == TNUMBER);
|
assert_msg (TYPE (p) == TNUMBER, "TYPE (p) == TNUMBER");
|
||||||
return fdisplay_ (x, VALUE (p), 1);
|
return fdisplay_ (x, VALUE (p), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,7 +291,7 @@ fdisplay_ (SCM x, int fd, int write_p) /*:((internal)) */
|
||||||
SCM
|
SCM
|
||||||
exit_ (SCM x) /*:((name . "exit")) */
|
exit_ (SCM x) /*:((name . "exit")) */
|
||||||
{
|
{
|
||||||
assert (TYPE (x) == TNUMBER);
|
assert_msg (TYPE (x) == TNUMBER, "TYPE (x) == TNUMBER");
|
||||||
exit (VALUE (x));
|
exit (VALUE (x));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#include "mes/lib.h"
|
#include "mes/lib.h"
|
||||||
#include "mes/mes.h"
|
#include "mes/mes.h"
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
#include "mes/lib.h"
|
#include "mes/lib.h"
|
||||||
#include "mes/mes.h"
|
#include "mes/mes.h"
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -36,7 +35,7 @@ alloc (long n)
|
||||||
SCM x = g_free;
|
SCM x = g_free;
|
||||||
g_free = g_free + n;
|
g_free = g_free + n;
|
||||||
if (g_free > ARENA_SIZE)
|
if (g_free > ARENA_SIZE)
|
||||||
assert (!"alloc: out of memory");
|
assert_msg (0, "alloc: out of memory");
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +52,7 @@ make_cell__ (long type, SCM car, SCM cdr)
|
||||||
SCM
|
SCM
|
||||||
make_cell_ (SCM type, SCM car, SCM cdr)
|
make_cell_ (SCM type, SCM car, SCM cdr)
|
||||||
{
|
{
|
||||||
assert (TYPE (type) == TNUMBER);
|
assert_msg (TYPE (type) == TNUMBER, "TYPE (type) == TNUMBER");
|
||||||
long t = VALUE (type);
|
long t = VALUE (type);
|
||||||
if (t == TCHAR || t == TNUMBER)
|
if (t == TCHAR || t == TNUMBER)
|
||||||
{
|
{
|
||||||
|
@ -233,7 +232,7 @@ error (SCM key, SCM x)
|
||||||
eputs (": ");
|
eputs (": ");
|
||||||
write_error_ (x);
|
write_error_ (x);
|
||||||
eputs ("\n");
|
eputs ("\n");
|
||||||
assert (0);
|
assert_msg (0, "0");
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1108,7 +1107,7 @@ begin_expand:
|
||||||
else if (TYPE (r1) == TPORT)
|
else if (TYPE (r1) == TPORT)
|
||||||
input = set_current_input_port (r1);
|
input = set_current_input_port (r1);
|
||||||
else
|
else
|
||||||
assert (0);
|
assert_msg (0, "0");
|
||||||
|
|
||||||
push_cc (input, r2, r0, cell_vm_return);
|
push_cc (input, r2, r0, cell_vm_return);
|
||||||
x = read_input_file_env (r0);
|
x = read_input_file_env (r0);
|
||||||
|
|
|
@ -21,8 +21,6 @@
|
||||||
#include "mes/lib.h"
|
#include "mes/lib.h"
|
||||||
#include "mes/mes.h"
|
#include "mes/mes.h"
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
SCM
|
SCM
|
||||||
make_module_type () /*:(internal)) */
|
make_module_type () /*:(internal)) */
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
#include "mes/lib.h"
|
#include "mes/lib.h"
|
||||||
#include "mes/mes.h"
|
#include "mes/mes.h"
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -151,7 +150,7 @@ write_byte (SCM x) /*:((arity . n)) */
|
||||||
char cc = VALUE (c);
|
char cc = VALUE (c);
|
||||||
write (fd, &cc, 1);
|
write (fd, &cc, 1);
|
||||||
#if !__MESC__
|
#if !__MESC__
|
||||||
assert (TYPE (c) == TNUMBER || TYPE (c) == TCHAR);
|
assert_msg (TYPE (c) == TNUMBER || TYPE (c) == TCHAR, "TYPE (c) == TNUMBER || TYPE (c) == TCHAR");
|
||||||
#endif
|
#endif
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
@ -305,7 +304,7 @@ execl_ (SCM file_name, SCM args) /*:((name . "execl")) */
|
||||||
i = i + 1;
|
i = i + 1;
|
||||||
while (args != cell_nil)
|
while (args != cell_nil)
|
||||||
{
|
{
|
||||||
assert (TYPE (CAR (args)) == TSTRING);
|
assert_msg (TYPE (CAR (args)) == TSTRING, "TYPE (CAR (args)) == TSTRING");
|
||||||
c_argv[i] = CSTRING (CAR (args));
|
c_argv[i] = CSTRING (CAR (args));
|
||||||
i = i + 1;
|
i = i + 1;
|
||||||
args = CDR (args);
|
args = CDR (args);
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#include "mes/lib.h"
|
#include "mes/lib.h"
|
||||||
#include "mes/mes.h"
|
#include "mes/mes.h"
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
12
src/string.c
12
src/string.c
|
@ -21,8 +21,6 @@
|
||||||
#include "mes/lib.h"
|
#include "mes/lib.h"
|
||||||
#include "mes/mes.h"
|
#include "mes/mes.h"
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -115,7 +113,7 @@ string_equal_p (SCM a, SCM b) /*:((name . "string=?")) */
|
||||||
eputs ("b= ");
|
eputs ("b= ");
|
||||||
write_error_ (b);
|
write_error_ (b);
|
||||||
eputs ("\n");
|
eputs ("\n");
|
||||||
assert ((TYPE (a) == TSTRING && TYPE (b) == TSTRING) || (TYPE (a) == TKEYWORD || TYPE (b) == TKEYWORD));
|
assert_msg ((TYPE (a) == TSTRING && TYPE (b) == TSTRING) || (TYPE (a) == TKEYWORD || TYPE (b) == TKEYWORD), "(TYPE (a) == TSTRING && TYPE (b) == TSTRING) || (TYPE (a) == TKEYWORD || TYPE (b) == TKEYWORD)");
|
||||||
}
|
}
|
||||||
if (a == b
|
if (a == b
|
||||||
|| STRING (a) == STRING (b)
|
|| STRING (a) == STRING (b)
|
||||||
|
@ -231,7 +229,7 @@ string_append (SCM x) /*:((arity . n)) */
|
||||||
while (x != cell_nil)
|
while (x != cell_nil)
|
||||||
{
|
{
|
||||||
SCM string = CAR (x);
|
SCM string = CAR (x);
|
||||||
assert (TYPE (string) == TSTRING);
|
assert_msg (TYPE (string) == TSTRING, "TYPE (string) == TSTRING");
|
||||||
memcpy (p, CSTRING (string), LENGTH (string) + 1);
|
memcpy (p, CSTRING (string), LENGTH (string) + 1);
|
||||||
p = p + LENGTH (string);
|
p = p + LENGTH (string);
|
||||||
size = size + LENGTH (string);
|
size = size + LENGTH (string);
|
||||||
|
@ -245,15 +243,15 @@ string_append (SCM x) /*:((arity . n)) */
|
||||||
SCM
|
SCM
|
||||||
string_length (SCM string)
|
string_length (SCM string)
|
||||||
{
|
{
|
||||||
assert (TYPE (string) == TSTRING);
|
assert_msg (TYPE (string) == TSTRING, "TYPE (string) == TSTRING");
|
||||||
return MAKE_NUMBER (LENGTH (string));
|
return MAKE_NUMBER (LENGTH (string));
|
||||||
}
|
}
|
||||||
|
|
||||||
SCM
|
SCM
|
||||||
string_ref (SCM str, SCM k)
|
string_ref (SCM str, SCM k)
|
||||||
{
|
{
|
||||||
assert (TYPE (str) == TSTRING);
|
assert_msg (TYPE (str) == TSTRING, "TYPE (str) == TSTRING");
|
||||||
assert (TYPE (k) == TNUMBER);
|
assert_msg (TYPE (k) == TNUMBER, "TYPE (k) == TNUMBER");
|
||||||
size_t size = LENGTH (str);
|
size_t size = LENGTH (str);
|
||||||
size_t i = VALUE (k);
|
size_t i = VALUE (k);
|
||||||
if (i > size)
|
if (i > size)
|
||||||
|
|
12
src/struct.c
12
src/struct.c
|
@ -21,8 +21,6 @@
|
||||||
#include "mes/lib.h"
|
#include "mes/lib.h"
|
||||||
#include "mes/mes.h"
|
#include "mes/mes.h"
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
SCM
|
SCM
|
||||||
make_struct (SCM type, SCM fields, SCM printer)
|
make_struct (SCM type, SCM fields, SCM printer)
|
||||||
{
|
{
|
||||||
|
@ -57,15 +55,15 @@ make_struct (SCM type, SCM fields, SCM printer)
|
||||||
SCM
|
SCM
|
||||||
struct_length (SCM x)
|
struct_length (SCM x)
|
||||||
{
|
{
|
||||||
assert (TYPE (x) == TSTRUCT);
|
assert_msg (TYPE (x) == TSTRUCT, "TYPE (x) == TSTRUCT");
|
||||||
return MAKE_NUMBER (LENGTH (x));
|
return MAKE_NUMBER (LENGTH (x));
|
||||||
}
|
}
|
||||||
|
|
||||||
SCM
|
SCM
|
||||||
struct_ref_ (SCM x, long i)
|
struct_ref_ (SCM x, long i)
|
||||||
{
|
{
|
||||||
assert (TYPE (x) == TSTRUCT);
|
assert_msg (TYPE (x) == TSTRUCT, "TYPE (x) == TSTRUCT");
|
||||||
assert (i < LENGTH (x));
|
assert_msg (i < LENGTH (x), "i < LENGTH (x)");
|
||||||
SCM e = STRUCT (x) + i;
|
SCM e = STRUCT (x) + i;
|
||||||
if (TYPE (e) == TREF)
|
if (TYPE (e) == TREF)
|
||||||
e = REF (e);
|
e = REF (e);
|
||||||
|
@ -79,8 +77,8 @@ struct_ref_ (SCM x, long i)
|
||||||
SCM
|
SCM
|
||||||
struct_set_x_ (SCM x, long i, SCM e)
|
struct_set_x_ (SCM x, long i, SCM e)
|
||||||
{
|
{
|
||||||
assert (TYPE (x) == TSTRUCT);
|
assert_msg (TYPE (x) == TSTRUCT, "TYPE (x) == TSTRUCT");
|
||||||
assert (i < LENGTH (x));
|
assert_msg (i < LENGTH (x), "i < LENGTH (x)");
|
||||||
g_cells[STRUCT (x) + i] = g_cells[vector_entry (e)];
|
g_cells[STRUCT (x) + i] = g_cells[vector_entry (e)];
|
||||||
return cell_unspecified;
|
return cell_unspecified;
|
||||||
}
|
}
|
||||||
|
|
12
src/vector.c
12
src/vector.c
|
@ -21,8 +21,6 @@
|
||||||
#include "mes/lib.h"
|
#include "mes/lib.h"
|
||||||
#include "mes/mes.h"
|
#include "mes/mes.h"
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
SCM
|
SCM
|
||||||
make_vector__ (long k)
|
make_vector__ (long k)
|
||||||
{
|
{
|
||||||
|
@ -43,15 +41,15 @@ make_vector_ (SCM n)
|
||||||
SCM
|
SCM
|
||||||
vector_length (SCM x)
|
vector_length (SCM x)
|
||||||
{
|
{
|
||||||
assert (TYPE (x) == TVECTOR);
|
assert_msg (TYPE (x) == TVECTOR, "TYPE (x) == TVECTOR");
|
||||||
return MAKE_NUMBER (LENGTH (x));
|
return MAKE_NUMBER (LENGTH (x));
|
||||||
}
|
}
|
||||||
|
|
||||||
SCM
|
SCM
|
||||||
vector_ref_ (SCM x, long i)
|
vector_ref_ (SCM x, long i)
|
||||||
{
|
{
|
||||||
assert (TYPE (x) == TVECTOR);
|
assert_msg (TYPE (x) == TVECTOR, "TYPE (x) == TVECTOR");
|
||||||
assert (i < LENGTH (x));
|
assert_msg (i < LENGTH (x), "i < LENGTH (x)");
|
||||||
SCM e = VECTOR (x) + i;
|
SCM e = VECTOR (x) + i;
|
||||||
if (TYPE (e) == TREF)
|
if (TYPE (e) == TREF)
|
||||||
e = REF (e);
|
e = REF (e);
|
||||||
|
@ -79,8 +77,8 @@ vector_entry (SCM x)
|
||||||
SCM
|
SCM
|
||||||
vector_set_x_ (SCM x, long i, SCM e)
|
vector_set_x_ (SCM x, long i, SCM e)
|
||||||
{
|
{
|
||||||
assert (TYPE (x) == TVECTOR);
|
assert_msg (TYPE (x) == TVECTOR, "TYPE (x) == TVECTOR");
|
||||||
assert (i < LENGTH (x));
|
assert_msg (i < LENGTH (x), "i < LENGTH (x)");
|
||||||
g_cells[VECTOR (x) + i] = g_cells[vector_entry (e)];
|
g_cells[VECTOR (x) + i] = g_cells[vector_entry (e)];
|
||||||
return cell_unspecified;
|
return cell_unspecified;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue