Added assert

This commit is contained in:
Dmitry Boulytchev 2021-01-25 01:22:56 +03:00
parent eeddb0b25a
commit 2b9adec087
6 changed files with 15 additions and 2 deletions

Binary file not shown.

View file

@ -1,3 +1,4 @@
F,assert;
F,getEnv; F,getEnv;
F,system; F,system;
V,sysargs; V,sysargs;

View file

@ -151,6 +151,15 @@ static void failure (char *s, ...) {
vfailure (s, args); vfailure (s, args);
} }
void Lassert (void *f, char *s, ...) {
if (!UNBOX(f)) {
va_list args;
va_start (args, s);
vfailure (s, args);
}
}
# define ASSERT_BOXED(memo, x) \ # define ASSERT_BOXED(memo, x) \
do if (UNBOXED(x)) failure ("boxed value expected in %s\n", memo); while (0) do if (UNBOXED(x)) failure ("boxed value expected in %s\n", memo); while (0)
# define ASSERT_UNBOXED(memo, x) \ # define ASSERT_UNBOXED(memo, x) \

View file

@ -12,6 +12,9 @@ is added implicitly by the compiler and can not be specified by an end user.
The following declarations are accessible: The following declarations are accessible:
\descr{\lstinline|fun assert (n, s, ...)|}{Asserts that \lstinline|n| is non-zero; otherwise raises \lstinline|failure| with
a corresponding error message.}
\descr{\lstinline|fun stringInt (s)|}{Converts a string representation of a signed decimal number into integer.} \descr{\lstinline|fun stringInt (s)|}{Converts a string representation of a signed decimal number into integer.}
\descr{\lstinline|fun read ()|}{Reads an integer value from the standard input, printing a prompt "\lstinline|>|".} \descr{\lstinline|fun read ()|}{Reads an integer value from the standard input, printing a prompt "\lstinline|>|".}

View file

@ -1 +1 @@
let path = "/home/db/.opam/4.07.1+fp/share/Lama" let path = "/home/db/.opam/4.07.1+fp+flambda/share/Lama"

View file

@ -1 +1 @@
let version = "Version 1.00, 19252991a, Thu Dec 24 02:54:54 2020 +0300" let version = "Version 1.00, eeddb0b25, Tue Jan 12 01:14:18 2021 +0300"