From b08a0d3e2bf45bae11c982dd24d0292d6436b993 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 4 Feb 2024 18:04:41 -0500 Subject: Updates and functionality --- nextlang.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 nextlang.h (limited to 'nextlang.h') diff --git a/nextlang.h b/nextlang.h new file mode 100644 index 00000000..2dd65704 --- /dev/null +++ b/nextlang.h @@ -0,0 +1,40 @@ +#pragma once + +#include +#include +#include +#include +#include +#include + +#define Int64_t int64_t +#define Int32_t int32_t +#define Int16_t int16_t +#define Int8_t int8_t + +#define Num64_t double +#define Num32_t float + +#define String_t CORD + +#define Char_t char + +#define Bool_t bool + +#define Void_t void + +#ifndef auto +#define auto __auto_type +#endif + +#define CORD_asprintf(...) ({ CORD __c; CORD_sprintf(&__c, __VA_ARGS__); __c; }) +#define __declare(var, val) __typeof(val) var = val +#define __cord(x) _Generic(x, bool: x ? "yes" : "no", \ + int16_t: CORD_asprintf("%d", x), int32_t: CORD_asprintf("%d", x), int64_t: CORD_asprintf("%ld", x), \ + double: CORD_asprintf("%g", x), float: CORD_asprintf("%g", x), \ + CORD: x, \ + default: "???") +#define __heap(x) (__typeof(x)*)memcpy(GC_MALLOC(sizeof(x)), (__typeof(x)[1]){x}, sizeof(x)) +#define __stack(x) (&(__typeof(x)){x}) + +#define say(str) puts(CORD_to_const_char_star(str)) -- cgit v1.2.3