]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
astir.h -> gmqcc.h
authorDale Weiler <killfieldengine@gmail.com>
Sat, 28 Apr 2012 09:08:03 +0000 (05:08 -0400)
committerDale Weiler <killfieldengine@gmail.com>
Sat, 28 Apr 2012 09:08:03 +0000 (05:08 -0400)
ast.h
astir.h [deleted file]
gmqcc.h
ir.h

diff --git a/ast.h b/ast.h
index a2b5d2cb2b64220999d9e90ec11b861d9f6f4941..a617a8c10955f254063b74b4c84f5f6e4a361aa3 100644 (file)
--- a/ast.h
+++ b/ast.h
@@ -22,8 +22,6 @@
  */
 #ifndef GMQCC_AST_HDR
 #define GMQCC_AST_HDR
  */
 #ifndef GMQCC_AST_HDR
 #define GMQCC_AST_HDR
-
-#include "astir.h"
 #include "ir.h"
 
 /* Note: I will not be using a _t suffix for the
 #include "ir.h"
 
 /* Note: I will not be using a _t suffix for the
diff --git a/astir.h b/astir.h
deleted file mode 100644 (file)
index dff1bdc..0000000
--- a/astir.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright (C) 2012 
- *     Wolfgang Bumiller
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of
- * this software and associated documentation files (the "Software"), to deal in
- * the Software without restriction, including without limitation the rights to
- * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is furnished to do
- * so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-#ifndef GMQCC_ASTIR_HDR
-#define GMQCC_ASTIR_HDR
-
-#define MEM_VECTOR_PROTO(Towner, Tmem, mem)                   \
-    bool GMQCC_WARN Towner##_##mem##_add(Towner*, Tmem);      \
-    bool GMQCC_WARN Towner##_##mem##_remove(Towner*, size_t);
-
-#define MEM_VECTOR_PROTO_ALL(Towner, Tmem, mem)                    \
-    MEM_VECTOR_PROTO(Towner, Tmem, mem)                            \
-    bool GMQCC_WARN Towner##_##mem##_find(Towner*, Tmem, size_t*); \
-    void Towner##_##mem##_clear(Towner*);
-
-#define MEM_VECTOR_MAKE(Twhat, name) \
-    Twhat  *name;                    \
-    size_t name##_count;             \
-    size_t name##_alloc
-
-#define _MEM_VEC_FUN_ADD(Tself, Twhat, mem)                          \
-bool GMQCC_WARN Tself##_##mem##_add(Tself *self, Twhat f)            \
-{                                                                    \
-    Twhat *reall;                                                    \
-    if (self->mem##_count == self->mem##_alloc) {                    \
-        if (!self->mem##_alloc) {                                    \
-            self->mem##_alloc = 16;                                  \
-        } else {                                                     \
-            self->mem##_alloc *= 2;                                  \
-        }                                                            \
-        reall = (Twhat*)mem_a(sizeof(Twhat) * self->mem##_alloc);    \
-        if (!reall) {                                                \
-            return false;                                            \
-        }                                                            \
-        memcpy(reall, self->mem, sizeof(Twhat) * self->mem##_count); \
-        mem_d(self->mem);                                            \
-        self->mem = reall;                                           \
-    }                                                                \
-    self->mem[self->mem##_count++] = f;                              \
-    return true;                                                     \
-}
-
-#define _MEM_VEC_FUN_REMOVE(Tself, Twhat, mem)                       \
-bool GMQCC_WARN Tself##_##mem##_remove(Tself *self, size_t idx)      \
-{                                                                    \
-    size_t i;                                                        \
-    Twhat *reall;                                                    \
-    if (idx >= self->mem##_count) {                                  \
-        return true; /* huh... */                                    \
-    }                                                                \
-    for (i = idx; i < self->mem##_count-1; ++i) {                    \
-        self->mem[i] = self->mem[i+1];                               \
-    }                                                                \
-    self->mem##_count--;                                             \
-    if (self->mem##_count < self->mem##_count/2)                     \
-    {                                                                \
-        self->mem##_alloc /= 2;                                      \
-        reall = (Twhat*)mem_a(sizeof(Twhat) * self->mem##_count);    \
-        if (!reall) {                                                \
-            return false;                                            \
-        }                                                            \
-        memcpy(reall, self->mem, sizeof(Twhat) * self->mem##_count); \
-        mem_d(self->mem);                                            \
-        self->mem = reall;                                           \
-    }                                                                \
-    return true;                                                     \
-}
-
-#define _MEM_VEC_FUN_FIND(Tself, Twhat, mem)                    \
-bool GMQCC_WARN Tself##_##mem##_find(Tself *self, Twhat obj, size_t *idx) \
-{                                                               \
-    size_t i;                                                   \
-    for (i = 0; i < self->mem##_count; ++i) {                   \
-        if (self->mem[i] == obj) {                              \
-            if (idx) {                                          \
-                *idx = i;                                       \
-            }                                                   \
-            return true;                                        \
-        }                                                       \
-    }                                                           \
-    return false;                                               \
-}
-
-#define _MEM_VEC_FUN_CLEAR(Tself, mem)  \
-void Tself##_##mem##_clear(Tself *self) \
-{                                       \
-    if (!self->mem)                     \
-        return;                         \
-    free((void*) self->mem);            \
-    self->mem = NULL;                   \
-    self->mem##_count = 0;              \
-    self->mem##_alloc = 0;              \
-}
-
-#define MEM_VECTOR_CLEAR(owner, mem) \
-    if ((owner)->mem)                \
-        free((void*)((owner)->mem)); \
-    (owner)->mem = NULL;             \
-    (owner)->mem##_count = 0;        \
-    (owner)->mem##_alloc = 0
-
-#define MEM_VECTOR_INIT(owner, mem) \
-{                                   \
-    (owner)->mem = NULL;            \
-    (owner)->mem##_count = 0;       \
-    (owner)->mem##_alloc = 0;       \
-}
-
-#define MEM_VEC_FUNCTIONS(Tself, Twhat, mem) \
-_MEM_VEC_FUN_REMOVE(Tself, Twhat, mem)       \
-_MEM_VEC_FUN_ADD(Tself, Twhat, mem)
-
-#define MEM_VEC_FUNCTIONS_ALL(Tself, Twhat, mem) \
-MEM_VEC_FUNCTIONS(Tself, Twhat, mem)             \
-_MEM_VEC_FUN_CLEAR(Tself, mem)                   \
-_MEM_VEC_FUN_FIND(Tself, Twhat, mem)
-
-enum store_types {
-    store_global,
-    store_local,  /* local, assignable for now, should get promoted later */
-    store_value,  /* unassignable */
-};
-
-typedef struct {
-    float x, y, z;
-} vector_t;
-
-/* A shallow copy of a lex_file to remember where which ast node
- * came from.
- */
-typedef struct lex_ctx
-{
-    const char *file;
-    size_t     line;
-} lex_ctx_t;
-
-#endif
diff --git a/gmqcc.h b/gmqcc.h
index 2e49982e08a05ad8ec10752ade17057a851caa21..091bda01e9581d8f8355c97c0ee1d71f2451ff9a 100644 (file)
--- a/gmqcc.h
+++ b/gmqcc.h
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2012 
 /*
  * Copyright (C) 2012 
- *     Dale Weiler
+ *     Dale Weiler, Wolfgang Bumiller
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy of
  * this software and associated documentation files (the "Software"), to deal in
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy of
  * this software and associated documentation files (the "Software"), to deal in
@@ -567,4 +567,135 @@ extern bool opts_memchk;
 extern bool opts_darkplaces_stringtablebug;
 extern bool opts_omit_nullcode;
 extern int  opts_compiler;
 extern bool opts_darkplaces_stringtablebug;
 extern bool opts_omit_nullcode;
 extern int  opts_compiler;
+//======================================================================
+//============================= ast.c ==================================
+//======================================================================
+#define MEM_VECTOR_PROTO(Towner, Tmem, mem)                   \
+    bool GMQCC_WARN Towner##_##mem##_add(Towner*, Tmem);      \
+    bool GMQCC_WARN Towner##_##mem##_remove(Towner*, size_t);
+
+#define MEM_VECTOR_PROTO_ALL(Towner, Tmem, mem)                    \
+    MEM_VECTOR_PROTO(Towner, Tmem, mem)                            \
+    bool GMQCC_WARN Towner##_##mem##_find(Towner*, Tmem, size_t*); \
+    void Towner##_##mem##_clear(Towner*);
+
+#define MEM_VECTOR_MAKE(Twhat, name) \
+    Twhat  *name;                    \
+    size_t name##_count;             \
+    size_t name##_alloc
+
+#define _MEM_VEC_FUN_ADD(Tself, Twhat, mem)                          \
+bool GMQCC_WARN Tself##_##mem##_add(Tself *self, Twhat f)            \
+{                                                                    \
+    Twhat *reall;                                                    \
+    if (self->mem##_count == self->mem##_alloc) {                    \
+        if (!self->mem##_alloc) {                                    \
+            self->mem##_alloc = 16;                                  \
+        } else {                                                     \
+            self->mem##_alloc *= 2;                                  \
+        }                                                            \
+        reall = (Twhat*)mem_a(sizeof(Twhat) * self->mem##_alloc);    \
+        if (!reall) {                                                \
+            return false;                                            \
+        }                                                            \
+        memcpy(reall, self->mem, sizeof(Twhat) * self->mem##_count); \
+        mem_d(self->mem);                                            \
+        self->mem = reall;                                           \
+    }                                                                \
+    self->mem[self->mem##_count++] = f;                              \
+    return true;                                                     \
+}
+
+#define _MEM_VEC_FUN_REMOVE(Tself, Twhat, mem)                       \
+bool GMQCC_WARN Tself##_##mem##_remove(Tself *self, size_t idx)      \
+{                                                                    \
+    size_t i;                                                        \
+    Twhat *reall;                                                    \
+    if (idx >= self->mem##_count) {                                  \
+        return true; /* huh... */                                    \
+    }                                                                \
+    for (i = idx; i < self->mem##_count-1; ++i) {                    \
+        self->mem[i] = self->mem[i+1];                               \
+    }                                                                \
+    self->mem##_count--;                                             \
+    if (self->mem##_count < self->mem##_count/2) {                   \
+        self->mem##_alloc /= 2;                                      \
+        reall = (Twhat*)mem_a(sizeof(Twhat) * self->mem##_count);    \
+        if (!reall) {                                                \
+            return false;                                            \
+        }                                                            \
+        memcpy(reall, self->mem, sizeof(Twhat) * self->mem##_count); \
+        mem_d(self->mem);                                            \
+        self->mem = reall;                                           \
+    }                                                                \
+    return true;                                                     \
+}
+
+#define _MEM_VEC_FUN_FIND(Tself, Twhat, mem)                    \
+bool GMQCC_WARN Tself##_##mem##_find(Tself *self, Twhat obj, size_t *idx) \
+{                                                               \
+    size_t i;                                                   \
+    for (i = 0; i < self->mem##_count; ++i) {                   \
+        if (self->mem[i] == obj) {                              \
+            if (idx) {                                          \
+                *idx = i;                                       \
+            }                                                   \
+            return true;                                        \
+        }                                                       \
+    }                                                           \
+    return false;                                               \
+}
+
+#define _MEM_VEC_FUN_CLEAR(Tself, mem)  \
+void Tself##_##mem##_clear(Tself *self) \
+{                                       \
+    if (!self->mem)                     \
+        return;                         \
+    free((void*) self->mem);            \
+    self->mem = NULL;                   \
+    self->mem##_count = 0;              \
+    self->mem##_alloc = 0;              \
+}
+
+#define MEM_VECTOR_CLEAR(owner, mem) \
+    if ((owner)->mem)                \
+        free((void*)((owner)->mem)); \
+    (owner)->mem = NULL;             \
+    (owner)->mem##_count = 0;        \
+    (owner)->mem##_alloc = 0
+
+#define MEM_VECTOR_INIT(owner, mem) \
+{                                   \
+    (owner)->mem = NULL;            \
+    (owner)->mem##_count = 0;       \
+    (owner)->mem##_alloc = 0;       \
+}
+
+#define MEM_VEC_FUNCTIONS(Tself, Twhat, mem) \
+_MEM_VEC_FUN_REMOVE(Tself, Twhat, mem)       \
+_MEM_VEC_FUN_ADD(Tself, Twhat, mem)
+
+#define MEM_VEC_FUNCTIONS_ALL(Tself, Twhat, mem) \
+MEM_VEC_FUNCTIONS(Tself, Twhat, mem)             \
+_MEM_VEC_FUN_CLEAR(Tself, mem)                   \
+_MEM_VEC_FUN_FIND(Tself, Twhat, mem)
+
+enum store_types {
+    store_global,
+    store_local,  /* local, assignable for now, should get promoted later */
+    store_value,  /* unassignable */
+};
+
+typedef struct {
+    float x, y, z;
+} vector_t;
+
+/*
+ * A shallow copy of a lex_file to remember where which ast node
+ * came from.
+ */
+typedef struct lex_ctx {
+    const char *file;
+    size_t     line;
+} lex_ctx_t;
 #endif
 #endif
diff --git a/ir.h b/ir.h
index c51bc84eb24648be8ddcdf8c067576acc519bcec..6172fd3709cfd4b3acb39a969dbb54f6f52fa36f 100644 (file)
--- a/ir.h
+++ b/ir.h
@@ -23,8 +23,6 @@
 #ifndef GMQCC_IR_HDR
 #define GMQCC_IR_HDR
 
 #ifndef GMQCC_IR_HDR
 #define GMQCC_IR_HDR
 
-#include "astir.h"
-
 /* ir_value */
 
 typedef struct
 /* ir_value */
 
 typedef struct