aboutsummaryrefslogtreecommitdiff
path: root/lib/ls_expr.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ls_expr.c')
-rw-r--r--lib/ls_expr.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/ls_expr.c b/lib/ls_expr.c
index f2e4bfc..3c5581b 100644
--- a/lib/ls_expr.c
+++ b/lib/ls_expr.c
@@ -90,6 +90,8 @@ static ls_int_t _sub_int_int(ls_int_t lhs, ls_int_t rhs);
static ls_int_t _mul_int_int(ls_int_t lhs, ls_int_t rhs);
static ls_int_t _div_int_int(ls_int_t lhs, ls_int_t rhs);
static ls_int_t _mod_int_int(ls_int_t lhs, ls_int_t rhs);
+static ls_int_t _shl_int_int(ls_int_t lhs, ls_int_t rhs);
+static ls_int_t _shr_int_int(ls_int_t lhs, ls_int_t rhs);
static ls_int_t _abs_int(ls_int_t lhs, ls_int_t rhs);
static ls_int_t _neg_int(ls_int_t lhs, ls_int_t rhs);
@@ -124,6 +126,9 @@ static const ls_opdef_t _ops[] = {
[LS_OP_ADD] = { 11, false, false, &_add_int_int },
[LS_OP_SUB] = { 11, false, false, &_sub_int_int },
+ [LS_OP_SHL] = { 10, false, false, &_shl_int_int },
+ [LS_OP_SHR] = { 10, false, false, &_shr_int_int },
+
[LS_OP_LT] = { 9, false, false, &_lt_int_int },
[LS_OP_GT] = { 9, false, false, &_gt_int_int },
[LS_OP_LEQ] = { 9, false, false, &_leq_int_int },
@@ -425,6 +430,28 @@ _mod_int_int(ls_int_t lhs, ls_int_t rhs)
}
static ls_int_t
+_shl_int_int(ls_int_t lhs, ls_int_t rhs)
+{
+ if (rhs < 0)
+ return _shr_int_int(lhs, -rhs);
+ else if (rhs > 32)
+ return 0;
+ else
+ return lhs << rhs;
+}
+
+static ls_int_t
+_shr_int_int(ls_int_t lhs, ls_int_t rhs)
+{
+ if (rhs < 0)
+ return _shl_int_int(lhs, -rhs);
+ else if (rhs > 32)
+ return 0;
+ else
+ return lhs >> rhs;
+}
+
+static ls_int_t
_abs_int(ls_int_t lhs, ls_int_t rhs)
{
(void) lhs;