mojoshader.c
branchtrunk
changeset 83 ce46250e553d
parent 82 dc7ad4cea75b
child 84 a49c5e1948d3
--- a/mojoshader.c	Fri Apr 04 07:05:13 2008 -0400
+++ b/mojoshader.c	Fri Apr 04 07:20:59 2008 -0400
@@ -617,7 +617,7 @@
                                     const int regnum)
 {
     return (reglist_exists(&ctx->used_registers, regtype, regnum) != NULL);
-} // set_used_register
+} // get_used_register
 
 static inline void set_defined_register(Context *ctx, const RegisterType rtype,
                                         const int regnum)
@@ -2494,7 +2494,9 @@
     ctx->dwords[2] = SWAP32(ctx->tokens[2]);
     ctx->dwords[3] = SWAP32(ctx->tokens[3]);
 
-    switch (ctx->dest_args[0].regtype)
+    const RegisterType regtype = ctx->dest_args[0].regtype;
+    const int regnum = ctx->dest_args[0].regnum;
+    switch (regtype)
     {
         case REG_TYPE_CONST:
         case REG_TYPE_CONST2:
@@ -2506,6 +2508,8 @@
             return fail(ctx, "DEF token using invalid register");
     } // switch
 
+    set_defined_register(ctx, regtype, regnum);
+
     return 6;
 } // parse_args_DEF
 
@@ -2520,9 +2524,13 @@
     ctx->dwords[2] = SWAP32(ctx->tokens[2]);
     ctx->dwords[3] = SWAP32(ctx->tokens[3]);
 
-    if (ctx->dest_args[0].regtype != REG_TYPE_CONSTINT)
+    const RegisterType regtype = ctx->dest_args[0].regtype;
+    const int regnum = ctx->dest_args[0].regnum;
+    if (regtype != REG_TYPE_CONSTINT)
         return fail(ctx, "DEFI token using invalid register");
 
+    set_defined_register(ctx, regtype, regnum);
+
     return 6;
 } // parse_args_DEFI
 
@@ -2534,9 +2542,13 @@
 
     ctx->dwords[0] = *(ctx->tokens) ? 1 : 0;
 
-    if (ctx->dest_args[0].regtype != REG_TYPE_CONSTBOOL)
+    const RegisterType regtype = ctx->dest_args[0].regtype;
+    const int regnum = ctx->dest_args[0].regnum;
+    if (regtype != REG_TYPE_CONSTBOOL)
         return fail(ctx, "DEFB token using invalid register");
 
+    set_defined_register(ctx, regtype, regnum);
+
     return 3;
 } // parse_args_DEFB
 
@@ -2558,6 +2570,7 @@
         return FAIL;
 
     const RegisterType regtype = ctx->dest_args[0].regtype;
+    const int regnum = ctx->dest_args[0].regnum;
     if ((ctx->shader_type == MOJOSHADER_TYPE_PIXEL) && (ctx->major_ver >= 3))
     {
         if (regtype == REG_TYPE_INPUT)
@@ -2565,7 +2578,7 @@
 
         else if (regtype == REG_TYPE_MISCTYPE)
         {
-            const MiscTypeType mt = (MiscTypeType) ctx->dest_args[0].regnum;
+            const MiscTypeType mt = (MiscTypeType) regnum;
             if (mt == MISCTYPE_TYPE_POSITION)
                 reserved_mask = 0x7FFFFFFF;
             else if (mt == MISCTYPE_TYPE_FACE)
@@ -2680,6 +2693,8 @@
     if ((token & reserved_mask) != 0)
         return fail(ctx, "reserved bits in DCL dword aren't zero");
 
+    set_defined_register(ctx, regtype, regnum);
+
     return 3;
 } // parse_args_DCL