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
310 vsetc(&ctype, VT_CONST, &cval);310 vsetc(&ctype, VT_CONST, &cval);
311}311}
312 312
313/* push arbitrary 64bit constant */
314void 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
313/* Return a static symbol pointing to a section */323/* Return a static symbol pointing to a section */
314ST_FUNC Sym *get_sym_ref(CType *type, Section *sec, unsigned long offset, unsigned long size)324ST_FUNC Sym *get_sym_ref(CType *type, Section *sec, unsigned long offset, unsigned long size)
315{325{
@@ -3535,6 +3545,21 @@ ST_FUNC void unary(void) · 3219 unmodified lines
3535 vtop->sym = s;3545 vtop->sym = s;
3536 next();3546 next();
3537 break;3547 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
3538 default:3563 default:
3539 tok_identifier:3564 tok_identifier:
3540 t = tok;3565 t = tok;
tcctok.h+7−2
@@ -81,10 +81,15 @@ · 80 unmodified lines
81 DEF(TOK___TIME__, "__TIME__")81 DEF(TOK___TIME__, "__TIME__")
82 DEF(TOK___FUNCTION__, "__FUNCTION__")82 DEF(TOK___FUNCTION__, "__FUNCTION__")
83 DEF(TOK___VA_ARGS__, "__VA_ARGS__")83 DEF(TOK___VA_ARGS__, "__VA_ARGS__")
84 84
85/* special identifiers */85/* special identifiers */
86 DEF(TOK___FUNC__, "__func__")86 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
88/* attribute identifiers */93/* attribute identifiers */
89/* XXX: handle all tokens generically since speed is not critical */94/* XXX: handle all tokens generically since speed is not critical */
90 DEF(TOK_SECTION1, "section")95 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