From 7b758ff41e88084920b9b548b1947f53eaed7f74 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 23 Feb 2011 16:45:06 -0500 Subject: [PATCH] Minor tweaks in case I expose semantic analysis phase to the public API later. --- mojoshader.h | 4 ++++ utils/mojoshader-compiler.c | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/mojoshader.h b/mojoshader.h index 34c6c270..6b4e15aa 100644 --- a/mojoshader.h +++ b/mojoshader.h @@ -1734,6 +1734,10 @@ const MOJOSHADER_astData *MOJOSHADER_parseAst(const char *srcprofile, MOJOSHADER_malloc m, MOJOSHADER_free f, void *d); + +/* !!! FIXME: expose semantic analysis to the public API? */ + + /* * Call this to dispose of AST parsing results when you are done with them. * This will call the MOJOSHADER_free function you provided to diff --git a/utils/mojoshader-compiler.c b/utils/mojoshader-compiler.c index 3258fe42..84ad4e48 100644 --- a/utils/mojoshader-compiler.c +++ b/utils/mojoshader-compiler.c @@ -171,8 +171,16 @@ static void print_ast_datatype(FILE *io, const MOJOSHADER_astDataType *dt) fprintf(io, "%s", dt->user.name); return; + // this should only appear if we did semantic analysis on the AST, + // so we only print the return value here. + case MOJOSHADER_AST_DATATYPE_FUNCTION: + if (!dt->function.retval) + fprintf(io, "void"); + else + print_ast_datatype(io, dt->function.retval); + return; + //case MOJOSHADER_AST_DATATYPE_NONE: - //case MOJOSHADER_AST_DATATYPE_FUNCTION: default: assert(0 && "Unexpected datatype."); return;