about summary refs log tree commit diff
path: root/src/libexpr/primops.cc
diff options
context:
space:
mode:
authorvolth <volth@webmaster.ms>2018-05-16T06·57+0000
committerGitHub <noreply@github.com>2018-05-16T06·57+0000
commitf3c090f91ce5e188151d887e3b5806239f5e6c0a (patch)
treefe1e05d242898c86f80cab5ff0cacbd9474343dd /src/libexpr/primops.cc
parent49b7cf1813d71b2c9d09f7c69408061774c01c51 (diff)
add `mod' and bitwise builtins: remove `mod' and shifts
Diffstat (limited to 'src/libexpr/primops.cc')
-rw-r--r--src/libexpr/primops.cc36
1 files changed, 0 insertions, 36 deletions
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index fa17f06b4c73..8514e804f11e 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -1676,23 +1676,6 @@ static void prim_div(EvalState & state, const Pos & pos, Value * * args, Value &
     }
 }
 
-static void prim_mod(EvalState & state, const Pos & pos, Value * * args, Value & v)
-{
-    NixFloat f2 = state.forceFloat(*args[1], pos);
-    if (f2 == 0) throw EvalError(format("division by zero, at %1%") % pos);
-
-    if (args[0]->type == tFloat || args[1]->type == tFloat) {
-        mkFloat(v, state.forceFloat(*args[0], pos) % state.forceFloat(*args[1], pos));
-    } else {
-        NixInt i1 = state.forceInt(*args[0], pos);
-        NixInt i2 = state.forceInt(*args[1], pos);
-        /* Avoid division overflow as it might raise SIGFPE. */
-        if (i1 == std::numeric_limits<NixInt>::min() && i2 == -1)
-            throw EvalError(format("overflow in integer division, at %1%") % pos);
-        mkInt(v, i1 % i2);
-    }
-}
-
 static void prim_bin_and(EvalState & state, const Pos & pos, Value * * args, Value & v)
 {
     mkInt(v, state.forceInt(*args[0], pos) & state.forceInt(*args[1], pos));
@@ -1708,21 +1691,6 @@ static void prim_bin_xor(EvalState & state, const Pos & pos, Value * * args, Val
     mkInt(v, state.forceInt(*args[0], pos) ^ state.forceInt(*args[1], pos));
 }
 
-static void prim_bin_shl(EvalState & state, const Pos & pos, Value * * args, Value & v)
-{
-    mkInt(v, state.forceInt(*args[0], pos) << (state.forceInt(*args[1], pos) & 63));
-}
-
-static void prim_bin_unsigned_shr(EvalState & state, const Pos & pos, Value * * args, Value & v)
-{
-    mkInt(v, (unsigned long)state.forceInt(*args[0], pos) >> (state.forceInt(*args[1], pos) & 63));
-}
-
-static void prim_bin_signed_shr(EvalState & state, const Pos & pos, Value * * args, Value & v)
-{
-    mkInt(v, (signed long)state.forceInt(*args[0], pos) >> (state.forceInt(*args[1], pos) & 63));
-}
-
 static void prim_lessThan(EvalState & state, const Pos & pos, Value * * args, Value & v)
 {
     state.forceValue(*args[0]);
@@ -2267,13 +2235,9 @@ void EvalState::createBaseEnv()
     addPrimOp("__sub", 2, prim_sub);
     addPrimOp("__mul", 2, prim_mul);
     addPrimOp("__div", 2, prim_div);
-    addPrimOp("__mod", 2, prim_mod);
     addPrimOp("__bin_and", 2, prim_bin_and);
     addPrimOp("__bin_or", 2, prim_bin_or);
     addPrimOp("__bin_xor", 2, prim_bin_xor);
-    addPrimOp("__bin_shl", 2, prim_bin_shl);
-    addPrimOp("__bin_unsigned_shr", 2, prim_bin_unsigned_shr);
-    addPrimOp("__bin_signed_shr", 2, prim_bin_signed_shr);
     addPrimOp("__lessThan", 2, prim_lessThan);
 
     // String manipulation