mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-22 20:41:20 +00:00
Ruamoko: Implement infinity.
The special token __INFINITY__, like __FILE__ and friends, will expand to a floating-point expression containing a value the C compiler considers infinite. Obviously, this assumes that the system has relatively modern float hardware -- but if it doesn't, having Ruamoko be able to represent float infinity is the least of your problems. :)
This commit is contained in:
parent
da552e33e7
commit
6ead583195
2 changed files with 16 additions and 3 deletions
|
@ -213,11 +213,19 @@
|
|||
these are the same values that would be returned by any math functions or
|
||||
floating-point calculations, these allow you to get the results without
|
||||
actually calling them.
|
||||
\note There does not appear to be a portable way to translate C's HUGE_VAL
|
||||
value, the basis for positive and negative infinities, to Ruamoko.
|
||||
\{
|
||||
*/
|
||||
# define M_E 2.7182818284590452354 ///< Euler's number \em e, the irrational base of the natural logarithm and a really neat thing
|
||||
/**
|
||||
Positive infinity. This is a special value replaced by the compiler with
|
||||
the actual floating-point value for a positive infinity. To get a negative
|
||||
infinity, just use -INFINITY.
|
||||
*/
|
||||
# define INFINITY __INFINITY__
|
||||
/**
|
||||
Euler's number \em e, the irrational base of the natural logarithm and a
|
||||
really neat thing
|
||||
*/
|
||||
# define M_E 2.7182818284590452354
|
||||
# define M_LOG2E 1.4426950408889634074 ///< The log, base 2, of \em e: <code>log2 (\ref M_E)</code>
|
||||
# define M_LOG10E 0.43429448190325182765 ///< The log, base 10, of \em e: <code>log10 (\ref M_E)</code>
|
||||
# define M_LN2 0.69314718055994530942 ///< The natural log evaluated at 2: <code>log (2)</code>
|
||||
|
|
|
@ -109,6 +109,11 @@ convert_name (expr_t *e)
|
|||
new = new_integer_expr (e->line);
|
||||
goto convert;
|
||||
}
|
||||
if (!strcmp (sym->name, "__INFINITY__")
|
||||
&& current_func) {
|
||||
new = new_float_expr (INFINITY);
|
||||
goto convert;
|
||||
}
|
||||
if (!strcmp (sym->name, "__FILE__")
|
||||
&& current_func) {
|
||||
new = new_string_expr (GETSTR (e->file));
|
||||
|
|
Loading…
Reference in a new issue