builtin maxI128 initial

This commit is contained in:
Eric Henry 2021-03-09 12:47:42 -05:00
parent c2525d2407
commit 4d046abefa
11 changed files with 73 additions and 17 deletions

View file

@ -159,6 +159,7 @@ pub fn builtin_defs_map(symbol: Symbol, var_store: &mut VarStore) -> Option<Def>
NUM_SHIFT_RIGHT => num_shift_right_by,
NUM_SHIFT_RIGHT_ZERO_FILL => num_shift_right_zf_by,
NUM_INT_CAST=> num_int_cast,
NUM_MAX_I128=> num_max_i128,
RESULT_MAP => result_map,
RESULT_MAP_ERR => result_map_err,
RESULT_AFTER => result_after,
@ -374,7 +375,7 @@ fn lowlevel_3(symbol: Symbol, op: LowLevel, var_store: &mut VarStore) -> Def {
fn num_max_int(symbol: Symbol, var_store: &mut VarStore) -> Def {
let int_var = var_store.fresh();
let int_percision_var = var_store.fresh();
let body = Int(int_var, int_percision_var, i64::MAX);
let body = Int(int_var, int_percision_var, i64::MAX.into());
Def {
annotation: None,
@ -389,7 +390,7 @@ fn num_max_int(symbol: Symbol, var_store: &mut VarStore) -> Def {
fn num_min_int(symbol: Symbol, var_store: &mut VarStore) -> Def {
let int_var = var_store.fresh();
let int_percision_var = var_store.fresh();
let body = Int(int_var, int_percision_var, i64::MIN);
let body = Int(int_var, int_percision_var, i64::MIN.into());
Def {
annotation: None,
@ -1344,6 +1345,21 @@ fn num_int_cast(symbol: Symbol, var_store: &mut VarStore) -> Def {
lowlevel_1(symbol, LowLevel::NumIntCast, var_store)
}
/// Num.maxI128: I128
fn num_max_i128(symbol: Symbol, var_store: &mut VarStore) -> Def {
let int_var = var_store.fresh();
let int_percision_var = var_store.fresh();
let body = Int(int_var, int_percision_var, i128::MAX);
Def {
annotation: None,
expr_var: int_var,
loc_expr: Located::at_zero(body),
loc_pattern: Located::at_zero(Pattern::Identifier(symbol)),
pattern_vars: SendMap::default(),
}
}
/// List.isEmpty : List * -> Bool
fn list_is_empty(symbol: Symbol, var_store: &mut VarStore) -> Def {
let list_var = var_store.fresh();