* MAINTAINERS: Update my email address
[deliverable/binutils-gdb.git] / gas / expr.c
index 09f38b1bb7e07b75dc91c665420e4a6f3c5c3288..8ddc965c7aad609fffdcf17aac10ae04a1180e86 100644 (file)
@@ -1,5 +1,6 @@
 /* expr.c -operands, expressions-
-   Copyright (C) 1987, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000
+   Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
+   1999, 2000, 2001
    Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
@@ -41,15 +42,14 @@ static void mri_char_constant PARAMS ((expressionS *));
 static void current_location PARAMS ((expressionS *));
 static void clean_up_expression PARAMS ((expressionS * expressionP));
 static segT operand PARAMS ((expressionS *));
-static operatorT operator PARAMS ((void));
+static operatorT operator PARAMS ((int *));
 
 extern const char EXP_CHARS[], FLT_CHARS[];
 
 /* We keep a mapping of expression symbols to file positions, so that
    we can provide better error messages.  */
 
-struct expr_symbol_line
-{
+struct expr_symbol_line {
   struct expr_symbol_line *next;
   symbolS *sym;
   char *file;
@@ -105,7 +105,7 @@ make_expr_symbol (expressionP)
   symbol_set_value_expression (symbolP, expressionP);
 
   if (expressionP->X_op == O_constant)
-    resolve_symbol_value (symbolP, 1);
+    resolve_symbol_value (symbolP, finalize_syms);
 
   n = (struct expr_symbol_line *) xmalloc (sizeof *n);
   n->sym = symbolP;
@@ -217,8 +217,8 @@ expr_build_dot ()
    and never write into the early words, thus they'll always be zero.
    I hate Dean's floating-point code.  Bleh.  */
 LITTLENUM_TYPE generic_bignum[SIZE_OF_LARGE_NUMBER + 6];
-FLONUM_TYPE generic_floating_point_number =
-{
+
+FLONUM_TYPE generic_floating_point_number = {
   &generic_bignum[6],          /* low.  (JF: Was 0)  */
   &generic_bignum[SIZE_OF_LARGE_NUMBER + 6 - 1], /* high.  JF: (added +6)  */
   0,                           /* leader.  */
@@ -859,7 +859,7 @@ operand (expressionP)
              input_line_pointer++;
              floating_constant (expressionP);
              expressionP->X_add_number =
-               -(isupper ((unsigned char) c) ? tolower (c) : c);
+               - (isupper ((unsigned char) c) ? tolower (c) : c);
            }
          else
            {
@@ -982,7 +982,7 @@ operand (expressionP)
          input_line_pointer++;
          floating_constant (expressionP);
          expressionP->X_add_number =
-           -(isupper ((unsigned char) c) ? tolower (c) : c);
+           - (isupper ((unsigned char) c) ? tolower (c) : c);
          break;
 
        case '$':
@@ -1069,7 +1069,7 @@ operand (expressionP)
            /* input_line_pointer -> char after operand.  */
            if (c == '-')
              {
-               expressionP->X_add_number = -expressionP->X_add_number;
+               expressionP->X_add_number = - expressionP->X_add_number;
                /* Notice: '-' may overflow: no warning is given.
                   This is compatible with other people's
                   assemblers.  Sigh.  */
@@ -1304,7 +1304,7 @@ operand (expressionP)
        {
          /* Let the target try to parse it.  Success is indicated by changing
             the X_op field to something other than O_absent and pointing
-            input_line_pointer passed the expression.  If it can't parse the
+            input_line_pointer past the expression.  If it can't parse the
             expression, X_op and input_line_pointer should be unchanged.  */
          expressionP->X_op = O_absent;
          --input_line_pointer;
@@ -1418,9 +1418,8 @@ clean_up_expression (expressionP)
 #undef __
 #define __ O_illegal
 
-static const operatorT op_encoding[256] =
-{                              /* Maps ASCII -> operators.  */
-
+/* Maps ASCII -> operators.  */
+static const operatorT op_encoding[256] = {
   __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
   __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
 
@@ -1464,15 +1463,14 @@ static const operatorT op_encoding[256] =
    7   * / % << >>
    8   unary - unary ~
 */
-static operator_rankT op_rank[] =
-{
+static operator_rankT op_rank[] = {
   0,   /* O_illegal */
   0,   /* O_absent */
   0,   /* O_constant */
   0,   /* O_symbol */
   0,   /* O_symbol_rva */
   0,   /* O_register */
-  0,   /* O_bit */
+  0,   /* O_big */
   9,   /* O_uminus */
   9,   /* O_bit_not */
   9,   /* O_logical_not */
@@ -1520,8 +1518,8 @@ static operator_rankT op_rank[] =
    mode.  Also, MRI uses a different bit_not operator, and this fixes
    that as well.  */
 
-#define STANDARD_MUL_PRECEDENCE (7)
-#define MRI_MUL_PRECEDENCE (5)
+#define STANDARD_MUL_PRECEDENCE 8
+#define MRI_MUL_PRECEDENCE 6
 
 void
 expr_set_precedence ()
@@ -1555,17 +1553,19 @@ expr_begin ()
   }
 }
 \f
-/* Return the encoding for the operator at INPUT_LINE_POINTER.
-   Advance INPUT_LINE_POINTER to the last character in the operator
-   (i.e., don't change it for a single character operator).  */
+/* Return the encoding for the operator at INPUT_LINE_POINTER, and
+   sets NUM_CHARS to the number of characters in the operator.
+   Does not advance INPUT_LINE_POINTER.  */
 
 static inline operatorT
-operator ()
+operator (num_chars)
+     int *num_chars;
 {
   int c;
   operatorT ret;
 
   c = *input_line_pointer & 0xff;
+  *num_chars = 1;
 
   if (is_end_of_line[c])
     return O_illegal;
@@ -1590,14 +1590,14 @@ operator ()
          ret = O_le;
          break;
        }
-      ++input_line_pointer;
+      *num_chars = 2;
       return ret;
 
     case '=':
       if (input_line_pointer[1] != '=')
        return op_encoding[c];
 
-      ++input_line_pointer;
+      *num_chars = 2;
       return O_eq;
 
     case '>':
@@ -1612,7 +1612,7 @@ operator ()
          ret = O_ge;
          break;
        }
-      ++input_line_pointer;
+      *num_chars = 2;
       return ret;
 
     case '!':
@@ -1623,21 +1623,21 @@ operator ()
            return O_bit_inclusive_or;
          return op_encoding[c];
        }
-      ++input_line_pointer;
+      *num_chars = 2;
       return O_bit_exclusive_or;
 
     case '|':
       if (input_line_pointer[1] != '|')
        return op_encoding[c];
 
-      ++input_line_pointer;
+      *num_chars = 2;
       return O_logical_or;
 
     case '&':
       if (input_line_pointer[1] != '&')
        return op_encoding[c];
 
-      ++input_line_pointer;
+      *num_chars = 2;
       return O_logical_and;
     }
 
@@ -1656,6 +1656,7 @@ expr (rankarg, resultP)
   expressionS right;
   operatorT op_left;
   operatorT op_right;
+  int op_chars;
 
   know (rank >= 0);
 
@@ -1664,12 +1665,12 @@ expr (rankarg, resultP)
   /* operand () gobbles spaces.  */
   know (*input_line_pointer != ' ');
 
-  op_left = operator ();
+  op_left = operator (&op_chars);
   while (op_left != O_illegal && op_rank[(int) op_left] > rank)
     {
       segT rightseg;
 
-      input_line_pointer++;    /* -> after 1st character of operator.  */
+      input_line_pointer += op_chars;  /* -> after operator.  */
 
       rightseg = expr (op_rank[(int) op_left], &right);
       if (right.X_op == O_absent)
@@ -1709,7 +1710,7 @@ expr (rankarg, resultP)
               )
        as_bad (_("operation combines symbols in different segments"));
 
-      op_right = operator ();
+      op_right = operator (&op_chars);
 
       know (op_right == O_illegal
            || op_rank[(int) op_right] <= op_rank[(int) op_left]);
@@ -1817,27 +1818,27 @@ expr (rankarg, resultP)
            case O_subtract:            resultP->X_add_number -= v; break;
            case O_eq:
              resultP->X_add_number =
-               resultP->X_add_number == v ? ~(offsetT) 0 : 0;
+               resultP->X_add_number == v ? ~ (offsetT) 0 : 0;
              break;
            case O_ne:
              resultP->X_add_number =
-               resultP->X_add_number != v ? ~(offsetT) 0 : 0;
+               resultP->X_add_number != v ? ~ (offsetT) 0 : 0;
              break;
            case O_lt:
              resultP->X_add_number =
-               resultP->X_add_number < v ? ~(offsetT) 0 : 0;
+               resultP->X_add_number <  v ? ~ (offsetT) 0 : 0;
              break;
            case O_le:
              resultP->X_add_number =
-               resultP->X_add_number <= v ? ~(offsetT) 0 : 0;
+               resultP->X_add_number <= v ? ~ (offsetT) 0 : 0;
              break;
            case O_ge:
              resultP->X_add_number =
-               resultP->X_add_number >= v ? ~(offsetT) 0 : 0;
+               resultP->X_add_number >= v ? ~ (offsetT) 0 : 0;
              break;
            case O_gt:
              resultP->X_add_number =
-               resultP->X_add_number > v ? ~(offsetT) 0 : 0;
+               resultP->X_add_number >  v ? ~ (offsetT) 0 : 0;
              break;
            case O_logical_and:
              resultP->X_add_number = resultP->X_add_number && v;
This page took 0.028253 seconds and 4 git commands to generate.