Skip to content

Commit

Permalink
Let finderrors work on assembly programs.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Dec 12, 2008
1 parent 339f441 commit d65b102
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions finderrors.c
Expand Up @@ -51,7 +51,12 @@ static int do_file(const char *profile, const char *dname, const char *fn, int *
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)++;
Expand All @@ -74,6 +79,28 @@ static int do_file(const char *profile, const char *dname, const char *fn, int *
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)
Expand Down Expand Up @@ -175,7 +202,7 @@ int main(int argc, char **argv)
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);
Expand Down

0 comments on commit d65b102

Please sign in to comment.