renaming matches() vars

View: New views
1 Messages — Rating Filter:   Alert me  

renaming matches() vars

by Cyrill Gorcunov :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

While reading matches() code I found it's easy (for me
only perhaps) to mess with itemp and instruction variables.
Sometime I start think about itemp being instruction and reverse.

May we rename them to tmpl and inst respectively?
I don;t insist by any means -- just personal impression.
Feel free to argue and drop the idea :)

I mean something like this.

        -- Cyrill
---
 assemble.c |   58 +++++++++++++++++++++++++++++-----------------------------
 1 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/assemble.c b/assemble.c
index e8c0509..df8b979 100644
--- a/assemble.c
+++ b/assemble.c
@@ -2020,8 +2020,8 @@ done:
     return merr;
 }
 
-static enum match_result matches(const struct itemplate *itemp,
- insn *instruction, int bits)
+static enum match_result matches(const struct itemplate *tmpl,
+ insn *inst, int bits)
 {
     int i, size[MAX_OPERANDS], asize, oprs;
     bool opsizemissing = false;
@@ -2029,26 +2029,26 @@ static enum match_result matches(const struct itemplate *itemp,
     /*
      * Check the opcode
      */
-    if (itemp->opcode != instruction->opcode)
+    if (tmpl->opcode != inst->opcode)
         return MERR_INVALOP;
 
     /*
      * Count the operands
      */
-    if (itemp->operands != instruction->operands)
+    if (tmpl->operands != inst->operands)
         return MERR_INVALOP;
 
     /*
      * Check that no spurious colons or TOs are present
      */
-    for (i = 0; i < itemp->operands; i++)
-        if (instruction->oprs[i].type & ~itemp->opd[i] & (COLON | TO))
+    for (i = 0; i < tmpl->operands; i++)
+        if (inst->oprs[i].type & ~tmpl->opd[i] & (COLON | TO))
             return MERR_INVALOP;
 
     /*
      * Process size flags
      */
-    switch (itemp->flags & IF_SMASK) {
+    switch (tmpl->flags & IF_SMASK) {
     case IF_SB:
  asize = BITS8;
  break;
@@ -2088,9 +2088,9 @@ static enum match_result matches(const struct itemplate *itemp,
  break;
     }
 
-    if (itemp->flags & IF_ARMASK) {
+    if (tmpl->flags & IF_ARMASK) {
  /* S- flags only apply to a specific operand */
- i = ((itemp->flags & IF_ARMASK) >> IF_ARSHFT) - 1;
+ i = ((tmpl->flags & IF_ARMASK) >> IF_ARSHFT) - 1;
  memset(size, 0, sizeof size);
  size[i] = asize;
     } else {
@@ -2102,20 +2102,20 @@ static enum match_result matches(const struct itemplate *itemp,
     /*
      * Check that the operand flags all match up
      */
-    for (i = 0; i < itemp->operands; i++) {
- opflags_t type = instruction->oprs[i].type;
+    for (i = 0; i < tmpl->operands; i++) {
+ opflags_t type = inst->oprs[i].type;
  if (!(type & SIZE_MASK))
     type |= size[i];
 
- if (itemp->opd[i] & SAME_AS) {
-    int j = SAME_AS_IDX(itemp->opd[i]);
-    if (type != instruction->oprs[j].type ||
- instruction->oprs[i].basereg != instruction->oprs[j].basereg)
+ if (tmpl->opd[i] & SAME_AS) {
+    int j = SAME_AS_IDX(tmpl->opd[i]);
+    if (type != inst->oprs[j].type ||
+ inst->oprs[i].basereg != inst->oprs[j].basereg)
  return MERR_INVALOP;
- } else if (itemp->opd[i] & ~type ||
-            ((itemp->opd[i] & SIZE_MASK) &&
-             ((itemp->opd[i] ^ type) & SIZE_MASK))) {
-            if ((itemp->opd[i] & ~type & ~SIZE_MASK) || (type & SIZE_MASK)) {
+ } else if (tmpl->opd[i] & ~type ||
+            ((tmpl->opd[i] & SIZE_MASK) &&
+             ((tmpl->opd[i] ^ type) & SIZE_MASK))) {
+            if ((tmpl->opd[i] & ~type & ~SIZE_MASK) || (type & SIZE_MASK)) {
                 return MERR_INVALOP;
     } else if (!is_class(REGISTER, type)) {
  /*
@@ -2134,10 +2134,10 @@ static enum match_result matches(const struct itemplate *itemp,
     /*
      * Check operand sizes
      */
-    if (itemp->flags & (IF_SM | IF_SM2)) {
-        oprs = (itemp->flags & IF_SM2 ? 2 : itemp->operands);
+    if (tmpl->flags & (IF_SM | IF_SM2)) {
+        oprs = (tmpl->flags & IF_SM2 ? 2 : tmpl->operands);
         for (i = 0; i < oprs; i++) {
-            asize = itemp->opd[i] & SIZE_MASK;
+            asize = tmpl->opd[i] & SIZE_MASK;
             if (asize) {
                 for (i = 0; i < oprs; i++)
                     size[i] = asize;
@@ -2145,31 +2145,31 @@ static enum match_result matches(const struct itemplate *itemp,
             }
         }
     } else {
-        oprs = itemp->operands;
+        oprs = tmpl->operands;
     }
 
-    for (i = 0; i < itemp->operands; i++) {
-        if (!(itemp->opd[i] & SIZE_MASK) &&
-            (instruction->oprs[i].type & SIZE_MASK & ~size[i]))
+    for (i = 0; i < tmpl->operands; i++) {
+        if (!(tmpl->opd[i] & SIZE_MASK) &&
+            (inst->oprs[i].type & SIZE_MASK & ~size[i]))
             return MERR_OPSIZEMISMATCH;
     }
 
     /*
      * Check template is okay at the set cpu level
      */
-    if (((itemp->flags & IF_PLEVEL) > cpu))
+    if (((tmpl->flags & IF_PLEVEL) > cpu))
         return MERR_BADCPU;
 
     /*
      * Verify the appropriate long mode flag.
      */
-    if ((itemp->flags & (bits == 64 ? IF_NOLONG : IF_LONG)))
+    if ((tmpl->flags & (bits == 64 ? IF_NOLONG : IF_LONG)))
         return MERR_BADMODE;
 
     /*
      * Check if special handling needed for Jumps
      */
-    if ((itemp->code[0] & 0374) == 0370)
+    if ((tmpl->code[0] & 0374) == 0370)
  return MOK_JUMP;
 
     return MOK_GOOD;
--
1.6.4.msysgit.0


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Nasm-devel mailing list
Nasm-devel@...
https://lists.sourceforge.net/lists/listinfo/nasm-devel