Initial commit
author |
Steve Losh <steve@stevelosh.com> |
date |
Tue, 02 Mar 2021 21:42:58 -0500 |
parents |
(none) |
children |
87674bc4c220 |
#include <stdio.h>
#include <stdint.h>
// Bools
#define bool_f 0x2F
#define bool_t 0x6F
// Fixnums
#define fx_mask 0x03
#define fx_tag 0x00
#define fx_shift 2
// Characters
#define ch_mask 0xFF
#define ch_tag 0x0F
#define ch_shift 8
// Nil
#define nil 0x3F
typedef uint64_t ptr;
static void print_ptr(ptr x) {
if ((x & fx_mask) == fx_tag) {
printf("%ld", ((int64_t)x >> fx_shift));
} else if ((x & ch_mask) == ch_tag) {
printf("#\\%c", ((int)x >> ch_shift));
} else if (x == bool_f) {
printf("#f");
} else if (x == bool_t) {
printf("#t");
} else if (x == nil) {
printf("()");
} else {
printf("#<unknown #x%016lx>", x);
}
printf("\n");
}
int main(int argc, char** argv) {
print_ptr(scheme_entry());
return 0;
}