diff --git a/flake.nix b/flake.nix index d7c0738..0cfcc98 100644 --- a/flake.nix +++ b/flake.nix @@ -39,6 +39,7 @@ bdwgc pkg-config guile + clang-tools # clangd ]; }; }; diff --git a/play/a.c b/play/a.c index bd75ffa..e72a9b2 100644 --- a/play/a.c +++ b/play/a.c @@ -1,9 +1,7 @@ #include #include -#define BLAH (-1 >> 2 == -1) && (-4 >> 2 == -1) && (-5 >> 2 == -2) && (-8 >> 2 == -2) - -#if BLAH +#if (-1 >> 2 == -1) && (-4 >> 2 == -1) && (-5 >> 2 == -2) && (-8 >> 2 == -2) # define SCM_SRS(x, y) ((x) >> (y)) #else # define SCM_SRS(x, y) \ diff --git a/play/t b/play/t index bd87542..9c16400 100755 Binary files a/play/t and b/play/t differ diff --git a/play/t.anf b/play/t.anf index fde37b2..6102161 100644 --- a/play/t.anf +++ b/play/t.anf @@ -1,8 +1,4 @@ ;;; -*- mode:scheme -*- -(let ((x0 (prim:cons 4 2)) - (x3 (prim:write x2)) - (x2 (prim:* 3 x1)) - (x1 (prim:cdr x0))) - x3) +(let ((x0 (prim:cons 4 2)) (x3 (prim:write x2)) (x2 (prim:* 3 x1)) (x1 (prim:cdr x0))) x3) diff --git a/runtime/gyehoek.c b/runtime/gyehoek.c index 14049ed..bc2f35c 100644 --- a/runtime/gyehoek.c +++ b/runtime/gyehoek.c @@ -1,11 +1,16 @@ #include #include "gyehoek.h" +SCM scm_newline () { + putc ('\n', stdout); + return SCM_PACK(NULL); +} + SCM scm_write (SCM x) { if (SCM_IMP (x)) { - printf ("#\n", SCM_UNPACK (x) >> 2); + printf ("%ld", SCM_UNPACK (x) >> 2); } else { - printf ("#\n", SCM_UNPACK (x)); + printf ("#", SCM_UNPACK (x)); } return SCM_PACK(NULL); } diff --git a/runtime/gyehoek.h b/runtime/gyehoek.h index 2dffe16..8c64784 100644 --- a/runtime/gyehoek.h +++ b/runtime/gyehoek.h @@ -19,6 +19,18 @@ typedef union SCM { struct { scm_t_bits n; } n; } SCM; #define SCM_TRUE 0b01100 #define SCM_EOL 0b10100 +#if (-1 >> 2 == -1) && (-4 >> 2 == -1) && (-5 >> 2 == -2) && (-8 >> 2 == -2) +# define SCM_SRS(x, y) ((x) >> (y)) +#else +# define SCM_SRS(x, y) \ + ((x) < 0 \ + ? -1 - (scm_t_signed_bits) (~(scm_t_bits)(x) >> (y)) \ + : ((x) >> (y))) +#endif + +#define SCM_MAKE_SMALL_INT(x) (SCM_SRS ((SCM_PACK (x)), 2) + 2) +#define SCM_GET_SMALL_INT(x) (SCM_UNPACK (x) >> 2) + SCM scm_write (SCM);