]> de.git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - ir.c
Merge branch 'master' of github.com:graphitemaster/gmqcc
[xonotic/gmqcc.git] / ir.c
diff --git a/ir.c b/ir.c
index 232bd69d00531620b523a794638b3c2adb979ae0..e0eee379b032c9f77f51e114f2ba8326c44f5c93 100644 (file)
--- a/ir.c
+++ b/ir.c
@@ -171,6 +171,28 @@ uint16_t type_ne_instr[TYPE_COUNT] = {
     AINSTR_END, /* array  */
 };
 
+uint16_t type_not_instr[TYPE_COUNT] = {
+    INSTR_NOT_F, /* should use I when having integer support */
+    INSTR_NOT_S,
+    INSTR_NOT_F,
+    INSTR_NOT_V,
+    INSTR_NOT_ENT,
+    INSTR_NOT_ENT,
+    INSTR_NOT_FNC,
+    INSTR_NOT_ENT, /* should use I */
+#if 0
+    INSTR_NOT_I, /* integer type */
+#else
+    INSTR_NOT_F,
+#endif
+
+    INSTR_NOT_V, /* variant, should never be accessed */
+
+    AINSTR_END, /* struct */
+    AINSTR_END, /* union  */
+    AINSTR_END, /* array  */
+};
+
 static void irerror(lex_ctx ctx, const char *msg, ...)
 {
     va_list ap;
@@ -520,7 +542,6 @@ bool ir_function_finalize(ir_function *self)
 
     if (!ir_function_calculate_liferanges(self))
         return false;
-
     if (!ir_function_allocate_locals(self))
         return false;
     return true;
@@ -3308,6 +3329,26 @@ void ir_instr_dump(ir_instr *in, char *ind,
     ind[strlen(ind)-1] = 0;
 }
 
+void ir_value_dump_string(const char *str, int (*oprintf)(const char*, ...))
+{
+    oprintf("\"");
+    for (; *str; ++str) {
+        switch (*str) {
+            case '\n': oprintf("\\n"); break;
+            case '\r': oprintf("\\r"); break;
+            case '\t': oprintf("\\t"); break;
+            case '\v': oprintf("\\v"); break;
+            case '\f': oprintf("\\f"); break;
+            case '\b': oprintf("\\b"); break;
+            case '\a': oprintf("\\a"); break;
+            case '\\': oprintf("\\\\"); break;
+            case '"': oprintf("\\\""); break;
+            default: oprintf("%c", *str); break;
+        }
+    }
+    oprintf("\"");
+}
+
 void ir_value_dump(ir_value* v, int (*oprintf)(const char*, ...))
 {
     if (v->isconst) {
@@ -3332,7 +3373,7 @@ void ir_value_dump(ir_value* v, int (*oprintf)(const char*, ...))
                 oprintf("(entity)");
                 break;
             case TYPE_STRING:
-                oprintf("\"%s\"", v->constval.vstring);
+                ir_value_dump_string(v->constval.vstring, oprintf);
                 break;
 #if 0
             case TYPE_INTEGER: