mirror of
https://github.com/NixOS/nix
synced 2025-07-02 17:41:48 +02:00
First hit at providing support for floats in the language.
This commit is contained in:
parent
b8258a4475
commit
14ebde5289
16 changed files with 207 additions and 23 deletions
|
@ -22,6 +22,7 @@ typedef enum {
|
|||
tPrimOp,
|
||||
tPrimOpApp,
|
||||
tExternal,
|
||||
tFloat
|
||||
} ValueType;
|
||||
|
||||
|
||||
|
@ -38,6 +39,7 @@ class XMLWriter;
|
|||
|
||||
|
||||
typedef long NixInt;
|
||||
typedef double NixFloat;
|
||||
|
||||
/* External values must descend from ExternalValueBase, so that
|
||||
* type-agnostic nix functions (e.g. showType) can be implemented
|
||||
|
@ -141,6 +143,7 @@ struct Value
|
|||
Value * left, * right;
|
||||
} primOpApp;
|
||||
ExternalValueBase * external;
|
||||
NixFloat fpoint;
|
||||
};
|
||||
|
||||
bool isList() const
|
||||
|
@ -181,6 +184,14 @@ static inline void mkInt(Value & v, NixInt n)
|
|||
}
|
||||
|
||||
|
||||
static inline void mkFloat(Value & v, NixFloat n)
|
||||
{
|
||||
clearValue(v);
|
||||
v.type = tFloat;
|
||||
v.fpoint = n;
|
||||
}
|
||||
|
||||
|
||||
static inline void mkBool(Value & v, bool b)
|
||||
{
|
||||
clearValue(v);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue