diff options
author | H. Peter Anvin <hpa@zytor.com> | 2008-06-14 21:08:38 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2008-06-14 21:08:38 -0700 |
commit | 9c749101ef6a6a406221b79c0352f97e29b3787a (patch) | |
tree | e48e61daebfd0c7f187e11f30d573feac386bf74 /eval.c | |
parent | 503e71d3ee4ef68fa8379b445ba7e928de19db29 (diff) | |
download | nasm-9c749101ef6a6a406221b79c0352f97e29b3787a.tar.gz nasm-9c749101ef6a6a406221b79c0352f97e29b3787a.tar.bz2 nasm-9c749101ef6a6a406221b79c0352f97e29b3787a.zip |
Support __utf16__ and __utf32__ in an expression context
Support __utf16__ and __utf32__ in expression contexts.
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 45 |
1 files changed, 45 insertions, 0 deletions
@@ -662,6 +662,48 @@ static expr *eval_floatize(enum floatize type) return finishtemp(); } +static expr *eval_strfunc(enum strfunc type) +{ + char *string; + size_t string_len; + int64_t val; + bool parens, rn_warn; + + i = scan(scpriv, tokval); + if (i == '(') { + parens = true; + i = scan(scpriv, tokval); + } + if (i != TOKEN_STR) { + error(ERR_NONFATAL, "expecting string"); + return NULL; + } + string_len = string_transform(tokval->t_charptr, tokval->t_inttwo, + &string, type); + if (string_len == (size_t)-1) { + error(ERR_NONFATAL, "invalid string for transform"); + return NULL; + } + + val = readstrnum(string, string_len, &rn_warn); + if (parens) { + i = scan(scpriv, tokval); + if (i != ')') { + error(ERR_NONFATAL, "expecting `)'"); + return NULL; + } + } + + if (rn_warn) + error(ERR_WARNING|ERR_PASS1, "character constant too long"); + + begintemp(); + addtotemp(EXPR_SIMPLE, val); + + i = scan(scpriv, tokval); + return finishtemp(); +} + static expr *expr6(int critical) { int32_t type; @@ -730,6 +772,9 @@ static expr *expr6(int critical) case TOKEN_FLOATIZE: return eval_floatize(tokval->t_integer); + case TOKEN_STRFUNC: + return eval_strfunc(tokval->t_integer); + case '(': i = scan(scpriv, tokval); e = bexpr(critical); |