mojoshader_compiler.c
changeset 1111 7530b37979b8
parent 1060 4cdf5a3ceb03
child 1145 07f69ab909ec
--- a/mojoshader_compiler.c	Thu Jun 07 04:31:01 2012 -0400
+++ b/mojoshader_compiler.c	Fri Aug 03 13:39:36 2012 -0400
@@ -2325,6 +2325,9 @@
 static const MOJOSHADER_astDataType *datatype_base(Context *ctx, const MOJOSHADER_astDataType *dt)
 {
     dt = reduce_datatype(ctx, dt);
+    if (dt == NULL)
+        return dt;
+
     switch (dt->type)
     {
         case MOJOSHADER_AST_DATATYPE_VECTOR:
@@ -4600,6 +4603,7 @@
                                        MOJOSHADER_irExpression *left,
                                        MOJOSHADER_irExpression *right)
 {
+    if ((!left) || (!right)) return NULL;
     NEW_IR_EXPR(retval, MOJOSHADER_irBinOp, MOJOSHADER_IR_BINOP, left->info.type, left->info.elements);
     assert(left->info.type == right->info.type);
     assert(left->info.elements == right->info.elements);
@@ -4613,6 +4617,7 @@
                                       MOJOSHADER_irStatement *stmt,
                                       MOJOSHADER_irExpression *expr)
 {
+    if (!expr) return NULL;
     NEW_IR_EXPR(retval, MOJOSHADER_irESeq, MOJOSHADER_IR_ESEQ, expr->info.type, expr->info.elements);
     retval->stmt = stmt;
     retval->expr = expr;
@@ -4779,8 +4784,8 @@
                                       const int writemask)
 {
     NEW_IR_NODE(retval, MOJOSHADER_irMove, MOJOSHADER_IR_MOVE);
-    assert(dst->info.type == src->info.type);
-    assert(dst->info.elements == src->info.elements);
+    assert(dst && src && (dst->info.type == src->info.type));
+    assert(dst && src && (dst->info.elements == src->info.elements));
     retval->dst = dst;
     retval->src = src;
     retval->writemask = writemask;
@@ -4832,8 +4837,8 @@
     const int join = generate_ir_label(ctx);
     const int tmp = generate_ir_temp(ctx);
 
-    assert(tval->info.type == fval->info.type);
-    assert(tval->info.elements == fval->info.elements);
+    assert(tval && fval && (tval->info.type == fval->info.type));
+    assert(tval && fval && (tval->info.elements == fval->info.elements));
 
     const MOJOSHADER_astDataTypeType dt = tval->info.type;
     const int elements = tval->info.elements;
@@ -5320,6 +5325,9 @@
     MOJOSHADER_irExpression *expr = build_ir_expr(ctx, ast->identifier);
     MOJOSHADER_irExpression *finalexpr = expr;
 
+    if (expr == NULL)
+        return NULL;
+
     assert(!ast->isswizzle);
 
     while (finalexpr->ir.type == MOJOSHADER_IR_ESEQ)