Files
corelang/lang.h
2022-05-06 10:13:16 +02:00

86 lines
1.6 KiB
C

#pragma once
#define global static
#define function static
#define assert(x) do{if(!(x)) __debugbreak();}while(0)
#define assert_msg(x,...) assert(x)
#define not_implemented assert_msg(0, "Not implemented")
#define invalid_codepath assert_msg(0, "Invalid codepath")
#define buff_cap(x) (sizeof(x)/sizeof((x)[0]))
#define lit(x) ((String){(U8*)x,buff_cap(x)-1})
#define meta(x)
#include <stdint.h>
typedef int8_t S8;
typedef int16_t S16;
typedef int32_t S32;
typedef int64_t S64;
typedef uint8_t U8;
typedef uint16_t U16;
typedef uint32_t U32;
typedef uint64_t U64;
typedef S8 B8;
typedef S16 B16;
typedef S32 B32;
typedef S64 B64;
typedef uint64_t SizeU;
typedef int64_t SizeI;
typedef float F32;
typedef double F64;
const B32 true = 1;
const B32 false = 0;
#define kib(x) ((x)*1024llu)
#define mib(x) (kib(x)*1024llu)
#define gib(x) (mib(x)*1024llu)
#define string_expand(x) (int)x.len, x.str
typedef struct String_Node String_Node;
typedef struct String_List String_List;
typedef struct String{
U8 *str;
S64 len;
}String;
struct String_Node{
String_Node *next;
union{
String string;
struct{U8*str; S64 len;};
};
};
struct String_List{
String_Node *first;
String_Node *last;
S64 char_count;
S64 node_count;
};
#define SLLQueuePushMod(f,l,n,next) do{\
if((f)==0){\
(f)=(l)=(n);\
}\
else{\
(l)=(l)->next=(n);\
} \
}while(0)
#define SLLQueuePush(f,l,n) SLLQueuePushMod(f,l,n,next)
#define SLLStackPush(l,n) do{\
(n)->next = (l);\
(l) = (n);\
}while(0)
#define SLLStackPop(l,n) do{\
if(l){\
(n) = (l);\
(l) = (l)->next;\
(n)->next = 0;\
}\
}while(0)