#define mem_d(PTRN) free((void*)PTRN)
#define mem_r(PTRN, SIZE) realloc((void*)PTRN, SIZE)
-/* TODO: rename to mem variations */
#define util_strdup(SRC) stat_mem_strdup((char*)(SRC), false)
#define util_strdupe(SRC) stat_mem_strdup((char*)(SRC), true)
-/* util.c */
-
-/*
- * Microsoft implements against the spec versions of ctype.h. Which
- * means what ever the current set locale is will render the actual
- * results of say isalpha('A') wrong for what ever retarded locale
- * is used. Simalerly these are also implemented inefficently on
- * some toolchains and end up becoming actual library calls. Perhaps
- * this is why tools like yacc provide their own? Regardless implementing
- * these as functions is equally as silly, the call overhead is not
- * justified when this could happen on every character from an input
- * stream. We provide our own as macros for absolute inlinability.
- */
#define util_isalpha(a) ((((unsigned)(a)|32)-'a') < 26)
#define util_isdigit(a) (((unsigned)(a)-'0') < 10)
#define util_islower(a) (((unsigned)(a)-'a') < 26)
struct hash_node_t **table;
} hash_table_t, *ht;
-/*
- * hashtable implementation:
- *
- * Note:
- * This was designed for pointers: you manage the life of the object yourself
- * if you do use this for non-pointers please be warned that the object may not
- * be valid if the duration of it exceeds (i.e on stack). So you need to allocate
- * yourself, or put those in global scope to ensure duration is for the whole
- * runtime.
- *
- * util_htnew(size) -- to make a new hashtable
- * util_htset(table, key, value, sizeof(value)) -- to set something in the table
- * util_htget(table, key) -- to get something from the table
- * util_htdel(table) -- to delete the table
- *
- * example of use:
- *
- * ht foo = util_htnew(1024);
- * int data = 100;
- * char *test = "hello world\n";
- * util_htset(foo, "foo", (void*)&data);
- * util_gtset(foo, "bar", (void*)test);
- *
- * printf("foo: %d, bar %s",
- * *((int *)util_htget(foo, "foo")),
- * ((char*)util_htget(foo, "bar"))
- * );
- *
- * util_htdel(foo);
- */
hash_table_t *util_htnew (size_t size);
void util_htrem(hash_table_t *ht, void (*callback)(void *data));
void util_htset(hash_table_t *ht, const char *key, void *value);
#define OFS_PARM6 (OFS_PARM5 +3)
#define OFS_PARM7 (OFS_PARM6 +3)
+typedef union {
+ int16_t s1;
+ uint16_t u1;
+} operand_t;
+
typedef struct {
uint16_t opcode;
-
- /* operand 1 */
- union {
- int16_t s1; /* signed */
- uint16_t u1; /* unsigned */
- } o1;
- /* operand 2 */
- union {
- int16_t s1; /* signed */
- uint16_t u1; /* unsigned */
- } o2;
- /* operand 3 */
- union {
- int16_t s1; /* signed */
- uint16_t u1; /* unsigned */
- } o3;
-
- /*
- * This is the same as the structure in darkplaces
- * {
- * unsigned short op;
- * short a,b,c;
- * }
- * But this one is more sane to work with, and the
- * type sizes are guranteed.
- */
+ operand_t o1;
+ operand_t o2;
+ operand_t o3;
} prog_section_statement_t;
typedef struct {
#include <string.h>
#include "parser.h"
-/*
- * Provides all the "intrinsics" / "builtins" for GMQCC. These can do
- * a few things, they can provide fall back implementations for math
- * functions if the definitions don't exist for some given engine. Or
- * then can determine definitions for existing builtins, and simply
- * wrap back to them instead. This is like a "portable" intrface that
- * is entered when -fintrin is used (causing all existing builtins to
- * be ignored by the compiler and instead interface through here.
- */
#define intrin_ctx(I) parser_ctx((I)->parser)
static GMQCC_INLINE ast_function *intrin_value(intrin_t *intrin, ast_value **out, const char *name, qcint_t vtype) {