gas/
[deliverable/binutils-gdb.git] / gas / expr.c
index b7cc1b8cacb8a7de564fb0980fd51d6554d94df6..7e37010949d9f2bc277465ff48665560974a8c94 100644 (file)
@@ -1,6 +1,6 @@
 /* expr.c -operands, expressions-
    Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2001, 2002
+   1999, 2000, 2001, 2002, 2003, 2004, 2005
    Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
@@ -17,8 +17,8 @@
 
    You should have received a copy of the GNU General Public License
    along with GAS; see the file COPYING.  If not, write to the Free
-   Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA.  */
+   Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
+   02110-1301, USA.  */
 
 /* This is really a branch office of as-read.c. I split it out to clearly
    distinguish the world of expressions from the world of statements.
@@ -157,33 +157,6 @@ expr_build_uconstant (offsetT value)
   return make_expr_symbol (&e);
 }
 
-/* Build an expression for OP s1.  */
-
-symbolS *
-expr_build_unary (operatorT op, symbolS *s1)
-{
-  expressionS e;
-
-  e.X_op = op;
-  e.X_add_symbol = s1;
-  e.X_add_number = 0;
-  return make_expr_symbol (&e);
-}
-
-/* Build an expression for s1 OP s2.  */
-
-symbolS *
-expr_build_binary (operatorT op, symbolS *s1, symbolS *s2)
-{
-  expressionS e;
-
-  e.X_op = op;
-  e.X_add_symbol = s1;
-  e.X_op_symbol = s2;
-  e.X_add_number = 0;
-  return make_expr_symbol (&e);
-}
-
 /* Build an expression for the current location ('.').  */
 
 symbolS *
@@ -213,8 +186,6 @@ FLONUM_TYPE generic_floating_point_number = {
   0                            /* sign.  */
 };
 
-/* If nonzero, we've been asked to assemble nan, +inf or -inf.  */
-int generic_floating_point_magic;
 \f
 static void
 floating_constant (expressionS *expressionP)
@@ -609,10 +580,6 @@ integer_constant (int radix, expressionS *expressionP)
       else
        {
          expressionP->X_op = O_constant;
-#ifdef TARGET_WORD_SIZE
-         /* Sign extend NUMBER.  */
-         number |= (-(number >> (TARGET_WORD_SIZE - 1))) << (TARGET_WORD_SIZE - 1);
-#endif
          expressionP->X_add_number = number;
          input_line_pointer--; /* Restore following character.  */
        }                       /* Really just a number.  */
@@ -981,12 +948,7 @@ operand (expressionS *expressionP)
       /* expression () will pass trailing whitespace.  */
       if ((c == '(' && *input_line_pointer != ')')
          || (c == '[' && *input_line_pointer != ']'))
-       {
-#ifdef RELAX_PAREN_GROUPING
-         if (c != '(')
-#endif
-           as_bad (_("missing '%c'"), c == '(' ? ')' : ']');
-       }
+       as_bad (_("missing '%c'"), c == '(' ? ')' : ']');
       else
        input_line_pointer++;
       SKIP_WHITESPACE ();
@@ -1020,13 +982,6 @@ operand (expressionS *expressionP)
       mri_char_constant (expressionP);
       break;
 
-    case '+':
-      /* Do not accept ++e as +(+e) */
-      if (input_line_pointer[1] == '+')
-       goto target_op;
-      (void) operand (expressionP);
-      break;
-
 #ifdef TC_M68K
     case '"':
       /* Double quote is the bitwise not operator in MRI mode.  */
@@ -1040,9 +995,11 @@ operand (expressionS *expressionP)
        goto isname;
     case '!':
     case '-':
+    case '+':
       {
-        /* Do not accept --e as -(-e) */
-       if (c == '-' && input_line_pointer[1] == '-')
+       /* Do not accept ++e or --e as +(+e) or -(-e)
+          Disabled, since the preprocessor removes whitespace.  */
+       if (0 && (c == '-' || c == '+') && *input_line_pointer == c)
          goto target_op;
        
        operand (expressionP);
@@ -1059,7 +1016,7 @@ operand (expressionS *expressionP)
              }
            else if (c == '~' || c == '"')
              expressionP->X_add_number = ~ expressionP->X_add_number;
-           else
+           else if (c == '!')
              expressionP->X_add_number = ! expressionP->X_add_number;
          }
        else if (expressionP->X_op == O_big
@@ -1074,17 +1031,49 @@ operand (expressionS *expressionP)
            else
              generic_floating_point_number.sign = 'N';
          }
+       else if (expressionP->X_op == O_big
+                && expressionP->X_add_number > 0)
+         {
+           int i;
+
+           if (c == '~' || c == '-')
+             {
+               for (i = 0; i < expressionP->X_add_number; ++i)
+                 generic_bignum[i] = ~generic_bignum[i];
+               if (c == '-')
+                 for (i = 0; i < expressionP->X_add_number; ++i)
+                   {
+                     generic_bignum[i] += 1;
+                     if (generic_bignum[i])
+                       break;
+                   }
+             }
+           else if (c == '!')
+             {
+               int nonzero = 0;
+               for (i = 0; i < expressionP->X_add_number; ++i)
+                 {
+                   if (generic_bignum[i])
+                     nonzero = 1;
+                   generic_bignum[i] = 0;
+                 }
+               generic_bignum[0] = nonzero;
+             }
+         }
        else if (expressionP->X_op != O_illegal
                 && expressionP->X_op != O_absent)
          {
-           expressionP->X_add_symbol = make_expr_symbol (expressionP);
-           if (c == '-')
-             expressionP->X_op = O_uminus;
-           else if (c == '~' || c == '"')
-             expressionP->X_op = O_bit_not;
-           else
-             expressionP->X_op = O_logical_not;
-           expressionP->X_add_number = 0;
+           if (c != '+')
+             {
+               expressionP->X_add_symbol = make_expr_symbol (expressionP);
+               if (c == '-')
+                 expressionP->X_op = O_uminus;
+               else if (c == '~' || c == '"')
+                 expressionP->X_op = O_bit_not;
+               else
+                 expressionP->X_op = O_logical_not;
+               expressionP->X_add_number = 0;
+             }
          }
        else
          as_warn (_("Unary operator %c ignored because bad operand follows"),
@@ -1551,8 +1540,9 @@ operator (int *num_chars)
 
     case '+':
     case '-':
-      /* Do not allow a++b and a--b to be a + (+b) and a - (-b) */
-      if (input_line_pointer[1] != c)
+      /* Do not allow a++b and a--b to be a + (+b) and a - (-b)
+        Disabled, since the preprocessor removes whitespace.  */
+      if (1 || input_line_pointer[1] != c)
        return op_encoding[c];
       return O_illegal;
 
@@ -1684,7 +1674,7 @@ expr (int rankarg,                /* Larger # is higher rank.  */
       know (op_right == O_illegal
            || op_rank[(int) op_right] <= op_rank[(int) op_left]);
       know ((int) op_left >= (int) O_multiply
-           && (int) op_left <= (int) O_logical_or);
+           && (int) op_left <= (int) O_index);
 
       /* input_line_pointer->after right-hand quantity.  */
       /* left-hand quantity in resultP.  */
This page took 0.025484 seconds and 4 git commands to generate.