trying to make Str.toNum work for Ints

This commit is contained in:
Anton-4 2021-12-01 20:37:21 +01:00
parent 2e21fd0cb9
commit e63701c5d1
6 changed files with 6 additions and 15 deletions

View file

@ -5269,6 +5269,7 @@ fn run_low_level<'a, 'ctx, 'env>(
str_ends_with(env, scope, args[0], args[1])
}
StrToNum => {
// Str.toNum : Str -> Result (Num *) {}
debug_assert_eq!(args.len(), 1);
let (string, _string_layout) = load_symbol_and_layout(scope, &args[0]);

View file

@ -441,13 +441,3 @@ pub fn empty_str<'a, 'ctx, 'env>(env: &Env<'a, 'ctx, 'env>) -> BasicValueEnum<'c
// so the whole struct should be a const_zero
BasicValueEnum::StructValue(struct_type.const_zero())
}
/// Str.toNum : Str -> Result (Num a) [ ExpectedNum a ]*
pub fn str_to_num<'a, 'ctx, 'env>(
env: &Env<'a, 'ctx, 'env>,
scope: &Scope<'a, 'ctx>,
str_symbol: Symbol,
) -> BasicValueEnum<'ctx> {
let str_i128 = str_symbol_to_c_abi(env, scope, str_symbol);
call_bitcode_fn(env, &[str_i128.into()], bitcode::STR_TRIM_RIGHT)
}