]> granicus.if.org Git - yasm/commitdiff
Add lindex parameter to yasm_intnum_calc(), and add error messages for SEG,
authorPeter Johnson <peter@tortall.net>
Mon, 26 May 2003 19:16:44 +0000 (19:16 -0000)
committerPeter Johnson <peter@tortall.net>
Mon, 26 May 2003 19:16:44 +0000 (19:16 -0000)
WRT, and ':' (SEGOFF) usage.  This change also brings the yasm_intnum_calc()
interface in line with the yasm_floatnum_calc() interface.

Note: This may not be the final place we want these error messages to reside,
but the lindex addition should remain for the sake of consistency.

svn path=/trunk/yasm/; revision=953

libyasm/bytecode.c
libyasm/expr.c
libyasm/intnum.c
libyasm/intnum.h
modules/optimizers/basic/basic-optimizer.c

index 05e23ecfecc756ecb7f4c23046f3d09b1b032e57..14ae8ec97555a445fd42166cacea10f2c72196d1 100644 (file)
@@ -26,7 +26,7 @@
  */
 #define YASM_LIB_INTERNAL
 #include "util.h"
-/*@unused@*/ RCSID("$IdPath: yasm/libyasm/bytecode.c,v 1.94 2003/05/04 22:15:09 peter Exp $");
+/*@unused@*/ RCSID("$IdPath$");
 
 #include "coretype.h"
 #include "file.h"
@@ -444,7 +444,7 @@ yasm_common_calc_bc_dist(yasm_section *sect, /*@null@*/ yasm_bytecode *precbc1,
            if (dist < precbc1->offset + precbc1->len) {
                intn = yasm_intnum_new_uint(precbc1->offset + precbc1->len
                                            - dist);
-               yasm_intnum_calc(intn, YASM_EXPR_NEG, NULL);
+               yasm_intnum_calc(intn, YASM_EXPR_NEG, NULL, precbc1->line);
                return intn;
            }
            dist -= precbc1->offset + precbc1->len;
@@ -453,7 +453,7 @@ yasm_common_calc_bc_dist(yasm_section *sect, /*@null@*/ yasm_bytecode *precbc1,
     } else {
        if (precbc1) {
            intn = yasm_intnum_new_uint(precbc1->offset + precbc1->len);
-           yasm_intnum_calc(intn, YASM_EXPR_NEG, NULL);
+           yasm_intnum_calc(intn, YASM_EXPR_NEG, NULL, precbc1->line);
            return intn;
        } else {
            return yasm_intnum_new_uint(0);
index 8fc2cd7a80d0725e13408fad628faac88ecd86e1..2963c63712537ac31d7c265c5e9f10737088307e 100644 (file)
@@ -26,7 +26,7 @@
  */
 #define YASM_LIB_INTERNAL
 #include "util.h"
-/*@unused@*/ RCSID("$IdPath: yasm/libyasm/expr.c,v 1.64 2003/03/15 21:59:55 peter Exp $");
+/*@unused@*/ RCSID("$IdPath$");
 
 #include "coretype.h"
 #include "bitvect.h"
@@ -566,7 +566,7 @@ expr_level_op(/*@returned@*/ /*@only@*/ yasm_expr *e, int fold_const,
        for (i=first_int_term+1, o=first_int_term+1; i<e->numterms; i++) {
            if (e->terms[i].type == YASM_EXPR_INT) {
                yasm_intnum_calc(e->terms[first_int_term].data.intn, e->op,
-                                e->terms[i].data.intn);
+                                e->terms[i].data.intn, e->line);
                fold_numterms--;
                level_numterms--;
                /* make sure to delete folded intnum */
@@ -635,7 +635,8 @@ expr_level_op(/*@returned@*/ /*@only@*/ yasm_expr *e, int fold_const,
                        e->terms[first_int_term] = sube->terms[j];  /* struc */
                    } else {
                        yasm_intnum_calc(e->terms[first_int_term].data.intn,
-                                        e->op, sube->terms[j].data.intn);
+                                        e->op, sube->terms[j].data.intn,
+                                        e->line);
                        /* make sure to delete folded intnum */
                        yasm_intnum_delete(sube->terms[j].data.intn);
                    }
index 91462a443abc5a0a0f6454ba4191bd0a86a86336..eff5f4d483af5006e54699486a1cfaf9771e8a26 100644 (file)
@@ -26,7 +26,7 @@
  */
 #define YASM_LIB_INTERNAL
 #include "util.h"
-/*@unused@*/ RCSID("$IdPath: yasm/libyasm/intnum.c,v 1.25 2003/03/17 00:03:02 peter Exp $");
+/*@unused@*/ RCSID("$IdPath$");
 
 #include <ctype.h>
 
@@ -242,7 +242,8 @@ yasm_intnum_delete(yasm_intnum *intn)
 
 /*@-nullderef -nullpass -branchstate@*/
 void
-yasm_intnum_calc(yasm_intnum *acc, yasm_expr_op op, yasm_intnum *operand)
+yasm_intnum_calc(yasm_intnum *acc, yasm_expr_op op, yasm_intnum *operand,
+                unsigned long lindex)
 {
     wordptr result = (wordptr)NULL, op1 = (wordptr)NULL, op2 = (wordptr)NULL;
     wordptr spare = (wordptr)NULL;
@@ -440,6 +441,15 @@ yasm_intnum_calc(yasm_intnum *acc, yasm_expr_op op, yasm_intnum *operand)
            } else
                acc->val.ul = acc->val.ul != operand->val.ul;
            break;
+       case YASM_EXPR_SEG:
+           yasm__error(lindex, N_("invalid use of '%s'"), "SEG");
+           break;
+       case YASM_EXPR_WRT:
+           yasm__error(lindex, N_("invalid use of '%s'"), "WRT");
+           break;
+       case YASM_EXPR_SEGOFF:
+           yasm__error(lindex, N_("invalid use of '%s'"), ":");
+           break;
        case YASM_EXPR_IDENT:
            if (result)
                BitVector_Copy(result, op1);
index b1abe65909a8110059c156d8ac985dcf71669f8c..55ade70b4c552a66de9d7e240041dbcc67d19dfd 100644 (file)
@@ -2,7 +2,7 @@
  * \file intnum.h
  * \brief YASM integer number interface.
  *
- * $IdPath: yasm/libyasm/intnum.h,v 1.15 2003/03/13 06:54:19 peter Exp $
+ * $IdPath$
  *
  *  Copyright (C) 2001  Peter Johnson
  *
@@ -103,8 +103,10 @@ void yasm_intnum_delete(/*@only@*/ yasm_intnum *intn);
  * \param acc      intnum accumulator
  * \param op       operation
  * \param operand   intnum operand
+ * \param lindex    line index (of expression)
  */
-void yasm_intnum_calc(yasm_intnum *acc, yasm_expr_op op, yasm_intnum *operand);
+void yasm_intnum_calc(yasm_intnum *acc, yasm_expr_op op, yasm_intnum *operand,
+                     unsigned long lindex);
 
 /** Simple value check for 0.
  * \param acc      intnum
index 12f9ded6d06ae3f2443d0a5e00883de52275ae73..f680485a4c843adbd461cfc113c395e4e80f9026 100644 (file)
@@ -25,7 +25,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <util.h>
-/*@unused@*/ RCSID("$IdPath: yasm/modules/optimizers/basic/basic-optimizer.c,v 1.33 2003/03/26 05:07:57 peter Exp $");
+/*@unused@*/ RCSID("$IdPath$");
 
 #define YASM_LIB_INTERNAL
 #define YASM_BC_INTERNAL
@@ -68,7 +68,8 @@ basic_optimize_calc_bc_dist_1(yasm_section *sect,
                    if (dist < precbc1->offset + precbc1->len) {
                        intn = yasm_intnum_new_uint(precbc1->offset +
                                                    precbc1->len - dist);
-                       yasm_intnum_calc(intn, YASM_EXPR_NEG, NULL);
+                       yasm_intnum_calc(intn, YASM_EXPR_NEG, NULL,
+                                        precbc1->line);
                        return intn;
                    }
                    dist -= precbc1->offset + precbc1->len;
@@ -84,7 +85,7 @@ basic_optimize_calc_bc_dist_1(yasm_section *sect,
        if (precbc1) {
            if (precbc1->opt_flags == BCFLAG_DONE) {
                intn = yasm_intnum_new_uint(precbc1->offset + precbc1->len);
-               yasm_intnum_calc(intn, YASM_EXPR_NEG, NULL);
+               yasm_intnum_calc(intn, YASM_EXPR_NEG, NULL, precbc1->line);
                return intn;
            } else {
                return NULL;