TODO: Actually implement the functions

This commit is contained in:
Joshua Hoeflich 2021-08-14 19:28:13 -05:00
parent 9dad304e95
commit 22e781259d
10 changed files with 84 additions and 10 deletions

View file

@ -162,6 +162,7 @@ pub fn builtin_defs_map(symbol: Symbol, var_store: &mut VarStore) -> Option<Def>
NUM_ACOS => num_acos,
NUM_ASIN => num_asin,
NUM_BYTES_TO_U16 => num_bytes_to_u16,
NUM_BYTES_TO_U32 => num_bytes_to_u32,
NUM_MAX_INT => num_max_int,
NUM_MIN_INT => num_min_int,
NUM_BITWISE_AND => num_bitwise_and,
@ -1089,7 +1090,7 @@ fn num_asin(symbol: Symbol, var_store: &mut VarStore) -> Def {
)
}
/// Num.bytesToU16 : List U8, Nat -> Nat
/// Num.bytesToU16 : List U8, Nat -> U16
fn num_bytes_to_u16(symbol: Symbol, var_store: &mut VarStore) -> Def {
let list_var = var_store.fresh();
let nat_var = var_store.fresh();
@ -1113,6 +1114,30 @@ fn num_bytes_to_u16(symbol: Symbol, var_store: &mut VarStore) -> Def {
)
}
/// Num.bytesToU32 : List U8, Nat -> U32
fn num_bytes_to_u32(symbol: Symbol, var_store: &mut VarStore) -> Def {
let list_var = var_store.fresh();
let nat_var = var_store.fresh();
let ret_var = var_store.fresh();
let body = RunLowLevel {
op: LowLevel::NumBytesToU32,
args: vec![
(list_var, Var(Symbol::ARG_1)),
(nat_var, Var(Symbol::ARG_2)),
],
ret_var,
};
defn(
symbol,
vec![(list_var, Symbol::ARG_1), (nat_var, Symbol::ARG_2)],
var_store,
body,
ret_var,
)
}
/// Num.bitwiseAnd : Int a, Int a -> Int a
fn num_bitwise_and(symbol: Symbol, var_store: &mut VarStore) -> Def {
num_binop(symbol, var_store, LowLevel::NumBitwiseAnd)