From: Peter Johnson Date: Mon, 26 May 2003 19:16:44 +0000 (-0000) Subject: Add lindex parameter to yasm_intnum_calc(), and add error messages for SEG, X-Git-Tag: v0.2.2~3^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=16c09e4b4143009734628d7eadc76621f2a89149;p=yasm Add lindex parameter to yasm_intnum_calc(), and add error messages for SEG, 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 --- diff --git a/libyasm/bytecode.c b/libyasm/bytecode.c index 05e23ecf..14ae8ec9 100644 --- a/libyasm/bytecode.c +++ b/libyasm/bytecode.c @@ -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); diff --git a/libyasm/expr.c b/libyasm/expr.c index 8fc2cd7a..2963c637 100644 --- a/libyasm/expr.c +++ b/libyasm/expr.c @@ -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; inumterms; 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); } diff --git a/libyasm/intnum.c b/libyasm/intnum.c index 91462a44..eff5f4d4 100644 --- a/libyasm/intnum.c +++ b/libyasm/intnum.c @@ -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 @@ -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); diff --git a/libyasm/intnum.h b/libyasm/intnum.h index b1abe659..55ade70b 100644 --- a/libyasm/intnum.h +++ b/libyasm/intnum.h @@ -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 diff --git a/modules/optimizers/basic/basic-optimizer.c b/modules/optimizers/basic/basic-optimizer.c index 12f9ded6..f680485a 100644 --- a/modules/optimizers/basic/basic-optimizer.c +++ b/modules/optimizers/basic/basic-optimizer.c @@ -25,7 +25,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -/*@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;