Skip to main content

rl_lang/interpreter/stdlib/bitwise/
mod.rs

1//! `std::bitwise` - bitwise operations on `byte` and `int` values.
2//!
3//! Mixed `byte`/`int` operands widen to `int`. `bit_xor` requires matching types.
4
5pub mod bit_and;
6pub mod bit_not;
7pub mod bit_or;
8pub mod bit_shift_left;
9pub mod bit_shift_right;
10pub mod bit_xor;
11pub mod count_bits;
12pub mod leading_zeros;
13pub mod trailing_zeros;
14
15use crate::interpreter::native::Module;
16
17pub const KEYWORDS: &[&str] = &[
18    "bit_and",
19    "bit_or",
20    "bit_xor",
21    "bit_not",
22    "bit_shift_left",
23    "bit_shift_right",
24    "count_bits",
25    "leading_zeros",
26    "trailing_zeros",
27];
28
29pub fn module() -> Module {
30    Module::new("bitwise")
31        .with_raw_function("bit_and", bit_and::std_bit_and)
32        .with_raw_function("bit_or", bit_or::std_bit_or)
33        .with_raw_function("bit_xor", bit_xor::std_bit_xor)
34        .with_raw_function("bit_not", bit_not::std_bit_not)
35        .with_raw_function("bit_shift_left", bit_shift_left::std_bit_shift_left)
36        .with_raw_function("bit_shift_right", bit_shift_right::std_bit_shift_right)
37        .with_raw_function("count_bits", count_bits::std_count_bits)
38        .with_raw_function("leading_zeros", leading_zeros::std_leading_zeros)
39        .with_raw_function("trailing_zeros", trailing_zeros::std_trailing_zeros)
40}