mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 07:14:46 +00:00
[WIP] Add Dec/Decimal builtin types
This commit is contained in:
parent
07dea4ee04
commit
4d6e5a1a4f
15 changed files with 160 additions and 16 deletions
|
@ -131,6 +131,9 @@ fn hash_builtin<'a, 'ctx, 'env>(
|
|||
let hash_bytes = store_and_use_as_u8_ptr(env, val, &layout);
|
||||
hash_bitcode_fn(env, seed, hash_bytes, layout.stack_size(ptr_bytes))
|
||||
}
|
||||
Builtin::Decimal => {
|
||||
panic!("TODO: Hash Decimal");
|
||||
}
|
||||
Builtin::Str => {
|
||||
// let zig deal with big vs small string
|
||||
call_bitcode_fn(
|
||||
|
|
|
@ -96,6 +96,7 @@ fn build_eq_builtin<'a, 'ctx, 'env>(
|
|||
|
||||
Builtin::Usize => int_cmp(IntPredicate::EQ, "eq_usize"),
|
||||
|
||||
Builtin::Decimal => panic!("TODO: eq decimal"),
|
||||
Builtin::Float128 => float_cmp(FloatPredicate::OEQ, "eq_f128"),
|
||||
Builtin::Float64 => float_cmp(FloatPredicate::OEQ, "eq_f64"),
|
||||
Builtin::Float32 => float_cmp(FloatPredicate::OEQ, "eq_f32"),
|
||||
|
@ -241,6 +242,7 @@ fn build_neq_builtin<'a, 'ctx, 'env>(
|
|||
|
||||
Builtin::Usize => int_cmp(IntPredicate::NE, "neq_usize"),
|
||||
|
||||
Builtin::Decimal => panic!("TODO: negate decimal"),
|
||||
Builtin::Float128 => float_cmp(FloatPredicate::ONE, "neq_f128"),
|
||||
Builtin::Float64 => float_cmp(FloatPredicate::ONE, "neq_f64"),
|
||||
Builtin::Float32 => float_cmp(FloatPredicate::ONE, "neq_f32"),
|
||||
|
|
|
@ -82,6 +82,7 @@ pub fn basic_type_from_builtin<'a, 'ctx, 'env>(
|
|||
Int8 => context.i8_type().as_basic_type_enum(),
|
||||
Int1 => context.bool_type().as_basic_type_enum(),
|
||||
Usize => ptr_int(context, ptr_bytes).as_basic_type_enum(),
|
||||
Decimal => zig_dec_type(env).into(),
|
||||
Float128 => context.f128_type().as_basic_type_enum(),
|
||||
Float64 => context.f64_type().as_basic_type_enum(),
|
||||
Float32 => context.f32_type().as_basic_type_enum(),
|
||||
|
@ -180,3 +181,9 @@ pub fn zig_str_type<'a, 'ctx, 'env>(
|
|||
) -> StructType<'ctx> {
|
||||
env.module.get_struct_type("str.RocStr").unwrap()
|
||||
}
|
||||
|
||||
pub fn zig_dec_type<'a, 'ctx, 'env>(
|
||||
env: &crate::llvm::build::Env<'a, 'ctx, 'env>,
|
||||
) -> StructType<'ctx> {
|
||||
env.module.get_struct_type("dec.RocDec").unwrap()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue