aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/value.hh
diff options
context:
space:
mode:
authorChristian Theune <ct@flyingcircus.io>2016-01-05 00:40:40 +0100
committerChristian Theune <ct@flyingcircus.io>2016-01-05 00:40:40 +0100
commit14ebde52893263930cdcde1406cc91cc5c42556f (patch)
tree2b65c11405f9aef33eb284208716f9cb5b434599 /src/libexpr/value.hh
parentb8258a4475726b56a4caa6553568c67a343a091d (diff)
First hit at providing support for floats in the language.
Diffstat (limited to 'src/libexpr/value.hh')
-rw-r--r--src/libexpr/value.hh11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/libexpr/value.hh b/src/libexpr/value.hh
index e6d1502cb..88424106c 100644
--- a/src/libexpr/value.hh
+++ b/src/libexpr/value.hh
@@ -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);