2 * coded by Ketmar // Invisible Vector <ketmar@ketmar.no-ip.org>
3 * Understanding is not required. Only obedience.
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 module gaem
.runner
.value
is aliced
;
20 import gaem
.runner
.strpool
;
23 // ////////////////////////////////////////////////////////////////////////// //
28 bool isReal (Real v
) nothrow @safe @nogc {
35 bool isString (Real v
) nothrow @safe @nogc {
42 bool isUndef (Real v
) nothrow @safe @nogc {
45 return (isNaN(v
) && getNaNPayload(v
) < 0);
49 // creates "undefined" value
50 Real
undefValue () nothrow @safe @nogc {
57 // for invalid strings it returns 0
58 int getStrId (Real v
) nothrow @safe @nogc {
62 auto res
= getNaNPayload(v
);
63 static if (Real
.sizeof
== 4) {
64 return (res
< 0 ?
0 : cast(int)res
);
66 return (res
< 0 || res
> int.max ?
0 : cast(int)res
);
74 Real
buildStrId (int id
) nothrow @safe @nogc {
77 static if (Real
.sizeof
== 4) {
78 assert(id
>= 0 && id
<= 0x3F_FFFF
);
86 Real
Value () nothrow @safe @nogc { pragma(inline
, true); return undefValue(); }
90 static if (is(T
: const(char)[])) return buildStrId(newDynStr(v
));
91 else static if (is(T
: Real
)) return cast(Real
)v
;
92 else static assert(0, "invalid value type");