Add canonical Expr implementation for Num.powInt

This commit is contained in:
Dimitar Apostolov 2020-09-15 21:48:54 +02:00
parent 11383e97ab
commit 50223ae93c
3 changed files with 22 additions and 1 deletions

View file

@ -93,6 +93,7 @@ pub fn builtin_defs(var_store: &mut VarStore) -> MutMap<Symbol, Def> {
Symbol::NUM_TO_FLOAT => num_to_float,
Symbol::NUM_POW => num_pow,
Symbol::NUM_CEILING => num_ceiling,
Symbol::NUM_POW_INT => num_pow_int,
}
}
@ -622,6 +623,25 @@ fn num_ceiling(symbol: Symbol, var_store: &mut VarStore) -> Def {
int_var,
)
}
/// Num.powInt : Int, Int -> Int
fn num_pow_int(symbol: Symbol, var_store: &mut VarStore) -> Def {
let int_var = var_store.fresh();
let body = RunLowLevel {
op: LowLevel::NumPowInt,
args: vec![(int_var, Var(Symbol::ARG_1)), (int_var, Var(Symbol::ARG_2))],
ret_var: int_var,
};
defn(
symbol,
vec![(int_var, Symbol::ARG_1), (int_var, Symbol::ARG_2)],
var_store,
body,
int_var,
)
}
/// List.isEmpty : List * -> Bool
fn list_is_empty(symbol: Symbol, var_store: &mut VarStore) -> Def {
let list_var = var_store.fresh();