diff options
author | H. Peter Anvin <hpa@zytor.com> | 2008-06-09 20:45:19 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2008-06-09 20:45:19 -0700 |
commit | 11627049aec88e21b6a9cbdef10984868d4ca3fe (patch) | |
tree | 1d6a223214cc0425ea11d3e2314b68d4030c2db6 /eval.c | |
parent | fcb8909749b2a159ba7f32fec7df8e465a974f77 (diff) | |
download | nasm-11627049aec88e21b6a9cbdef10984868d4ca3fe.tar.gz nasm-11627049aec88e21b6a9cbdef10984868d4ca3fe.tar.bz2 nasm-11627049aec88e21b6a9cbdef10984868d4ca3fe.zip |
Make strings a first-class token type; defer evaluation
Make strings a proper, first-class token type, instead of relying on
the "TOKEN_NUM with tv_charptr" hack. Only convert a string to a
number if requested in an expression context; this also makes it
possible to actually issue a warning when it overflows.
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -668,6 +668,8 @@ static expr *expr6(int critical) expr *e; int32_t label_seg; int64_t label_ofs; + int64_t tmpval; + bool rn_warn; char *scope; switch (i) { @@ -741,6 +743,7 @@ static expr *expr6(int critical) return e; case TOKEN_NUM: + case TOKEN_STR: case TOKEN_REG: case TOKEN_ID: case TOKEN_INSN: /* Opcodes that occur here are really labels */ @@ -751,6 +754,12 @@ static expr *expr6(int critical) case TOKEN_NUM: addtotemp(EXPR_SIMPLE, tokval->t_integer); break; + case TOKEN_STR: + tmpval = readstrnum(tokval->t_charptr, tokval->t_inttwo, &rn_warn); + if (rn_warn) + error(ERR_WARNING|ERR_PASS1, "character constant too long"); + addtotemp(EXPR_SIMPLE, tmpval); + break; case TOKEN_REG: addtotemp(tokval->t_integer, 1L); if (hint && hint->type == EAH_NOHINT) |