Let finderrors work on assembly programs.
authorRyan C. Gordon <icculus@icculus.org>
Fri, 12 Dec 2008 00:58:10 -0500
changeset 503 ec8e7739cf5d
parent 502 3cb501248990
child 504 d79ae3b98f47
Let finderrors work on assembly programs.
finderrors.c
--- a/finderrors.c	Fri Dec 12 00:08:12 2008 -0500
+++ b/finderrors.c	Fri Dec 12 00:58:10 2008 -0500
@@ -51,7 +51,12 @@
         return 0;
     } // if
 
-    if (strstr(fn, ".bytecode") == NULL)
+    int assembly = 0;
+    if (strstr(fn, ".bytecode") != NULL)
+        assembly = 0;
+    else if (strstr(fn, ".disasm") != NULL)
+        assembly = 1;
+    else
         return 1;
 
     (*total)++;
@@ -74,6 +79,28 @@
         return 1;
     } // if
 
+    if (assembly)
+    {
+        const MOJOSHADER_parseData *a;
+
+        a = MOJOSHADER_assemble((char *) buf, 0, 0, 0);
+        if (a->error)
+        {
+            report("FAIL: %s %s\n", fname, a->error);
+            return 1;
+        } // if
+
+        else if (a->output_len > sizeof (buf))
+        {
+            report("FAIL: %s buffer overflow in finderrors.c\n", fname);
+            return 1;
+        } // if
+
+        rc = a->output_len;
+        memcpy(buf, a->output, rc);
+        MOJOSHADER_freeParseData(a);
+    } // if
+
     #if FINDERRORS_COMPILE_SHADERS
     MOJOSHADER_glShader *shader = MOJOSHADER_glCompileShader(buf, rc, NULL, 0);
     if (shader == NULL)
@@ -175,7 +202,7 @@
         for (i = 2; i < argc; i++)
             total += do_dir(argv[i], profile);
 
-        printf("Saw %d bytecode files.\n", total);
+        printf("Saw %d files.\n", total);
 
         #if FINDERRORS_COMPILE_SHADERS
         MOJOSHADER_glDestroyContext(ctx);