History

Add nan, snan and inf float constants

Thomas Preud'homme committed 16 years ago

Commit 8eb86ab1 parent 22204672 files · +32 −2Browse files

Unified · Split

2 files
  1. tccgen.c +25 −0
  2. tcctok.h +7 −2
tccgen.c+25−0
@@ -310,6 +310,16 @@ static void vpushll(long long v) · 309 unmodified lines
310310 vsetc(&ctype, VT_CONST, &cval);
311311 }
312312
313+/* push arbitrary 64bit constant */
314+void vpush64(int ty, unsigned long long v)
315+{
316+ CValue cval;
317+ CType ctype;
318+ ctype.t = ty;
319+ cval.ull = v;
320+ vsetc(&ctype, VT_CONST, &cval);
321+}
322+
313323 /* Return a static symbol pointing to a section */
314324 ST_FUNC Sym *get_sym_ref(CType *type, Section *sec, unsigned long offset, unsigned long size)
315325 {
@@ -3535,6 +3545,21 @@ ST_FUNC void unary(void) · 3219 unmodified lines
35353545 vtop->sym = s;
35363546 next();
35373547 break;
3548+
3549+ // special qnan , snan and infinity values
3550+ case TOK___NAN__:
3551+ vpush64(VT_DOUBLE, 0x7ff8000000000000);
3552+ next();
3553+ break;
3554+ case TOK___SNAN__:
3555+ vpush64(VT_DOUBLE, 0x7ff0000000000001);
3556+ next();
3557+ break;
3558+ case TOK___INF__:
3559+ vpush64(VT_DOUBLE, 0x7ff0000000000000);
3560+ next();
3561+ break;
3562+
35383563 default:
35393564 tok_identifier:
35403565 t = tok;
tcctok.h+7−2
@@ -81,10 +81,15 @@ · 80 unmodified lines
8181 DEF(TOK___TIME__, "__TIME__")
8282 DEF(TOK___FUNCTION__, "__FUNCTION__")
8383 DEF(TOK___VA_ARGS__, "__VA_ARGS__")
84−
84+
8585 /* special identifiers */
8686 DEF(TOK___FUNC__, "__func__")
87−
87+
88+/* special floating point values */
89+ DEF(TOK___NAN__, "__nan__")
90+ DEF(TOK___SNAN__, "__snan__")
91+ DEF(TOK___INF__, "__inf__")
92+
8893 /* attribute identifiers */
8994 /* XXX: handle all tokens generically since speed is not critical */
9095 DEF(TOK_SECTION1, "section")

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t