/**
* \file slang_codegen.c
- * Mesa GLSL code generator. Convert AST to IR tree.
+ * Generate IR tree from AST.
* \author Brian Paul
*/
#include "imports.h"
#include "macros.h"
+#include "mtypes.h"
+#include "program.h"
+#include "prog_instruction.h"
+#include "prog_parameter.h"
+#include "prog_statevars.h"
#include "slang_typeinfo.h"
-#include "slang_builtin.h"
#include "slang_codegen.h"
#include "slang_compile.h"
-#include "slang_storage.h"
#include "slang_error.h"
#include "slang_simplify.h"
#include "slang_emit.h"
#include "slang_vartable.h"
#include "slang_ir.h"
-#include "mtypes.h"
-#include "program.h"
-#include "prog_instruction.h"
-#include "prog_parameter.h"
-#include "prog_statevars.h"
#include "slang_print.h"
static void
slang_resolve_variable(slang_operation *oper)
{
- if (oper->type != SLANG_OPER_IDENTIFIER)
- return;
- if (!oper->var) {
- oper->var = _slang_locate_variable(oper->locals,
- (const slang_atom) oper->a_id,
- GL_TRUE);
+ if (oper->type == SLANG_OPER_IDENTIFIER && !oper->var) {
+ oper->var = _slang_locate_variable(oper->locals, oper->a_id, GL_TRUE);
}
}
}
if (oper->num_children == 1) {
/* the initializer */
- slang_substitute(A, &oper->children[0], substCount, substOld, substNew, GL_FALSE);
+ slang_substitute(A, &oper->children[0], substCount,
+ substOld, substNew, GL_FALSE);
}
}
break;
static GLuint
-make_writemask(char *field)
+make_writemask(const char *field)
{
GLuint mask = 0x0;
while (*field) {
slang_ir_node *n0;
dest_oper = &oper->children[0];
- while /*if*/ (dest_oper->type == SLANG_OPER_FIELD) {
+ while (dest_oper->type == SLANG_OPER_FIELD) {
/* writemask */
- writemask &= /*=*/make_writemask((char*) dest_oper->a_id);
+ writemask &= make_writemask((char*) dest_oper->a_id);
dest_oper = &dest_oper->children[0];
}
}
-
-
/**
* Generate code for a selection expression: b ? x : y
* XXX in some cases we could implement a selection expression
}
-
/**
* Generate IR tree for a return statement.
*/