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, version 3 of the License ONLY.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 module gaem
.runner
.value
is aliced
;
19 import gaem
.runner
.strpool
;
22 // ////////////////////////////////////////////////////////////////////////// //
27 bool isReal (Real v
) nothrow @safe @nogc {
34 bool isString (Real v
) nothrow @safe @nogc {
41 bool isUndef (Real v
) nothrow @safe @nogc {
44 return (isNaN(v
) && getNaNPayload(v
) < 0);
48 // creates "undefined" value
49 Real
undefValue () nothrow @safe @nogc {
56 // for invalid strings it returns 0
57 int getStrId (Real v
) nothrow @safe @nogc {
61 auto res
= getNaNPayload(v
);
62 static if (Real
.sizeof
== 4) {
63 return (res
< 0 ?
0 : cast(int)res
);
65 return (res
< 0 || res
> int.max ?
0 : cast(int)res
);
73 Real
buildStrId (int id
) nothrow @safe @nogc {
76 static if (Real
.sizeof
== 4) {
77 assert(id
>= 0 && id
<= 0x3F_FFFF
);
85 Real
Value () nothrow @safe @nogc { pragma(inline
, true); return undefValue(); }
89 static if (is(T
: const(char)[])) return buildStrId(newDynStr(v
));
90 else static if (is(T
: Real
)) return cast(Real
)v
;
91 else static assert(0, "invalid value type");