]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - test/ast-macros.h
ast macros to create a field, generating fields in ast-test
[xonotic/gmqcc.git] / test / ast-macros.h
index ebb3a5bd6b7b09807622a90c8ef9523f0b09e4bb..56df82eb7794272982d4fb8a41bf654b5f7a812b 100644 (file)
@@ -21,6 +21,17 @@ name = ast_value_new(ctx, #varname, type)
 #define MKGLOBAL(name) \
 assert(globals_add(name) >= 0)
 
+#define FIELD(type, name) \
+name = ast_value_new(ctx, #name, TYPE_FIELD);                  \
+do {                                                           \
+    ast_value *field_##name = ast_value_new(ctx, #name, type); \
+    name->expression.next = (ast_expression*)field_##name;     \
+    MKFIELD(name);                                             \
+} while (0)
+
+#define MKFIELD(name) \
+assert(fields_add(name) >= 0)
+
 #define MKCONSTFLOAT(name, value)  \
 do {                               \
     name->isconst = true;          \