mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 23:31:12 +00:00
code gen for simple guards
Guards cannot use variables bound in the pattern yet
This commit is contained in:
parent
bd7ad318cf
commit
a16d48a6a9
4 changed files with 490 additions and 293 deletions
|
@ -771,13 +771,24 @@ fn call_by_name<'a, B: Backend>(
|
|||
.ins()
|
||||
.load(env.ptr_sized_int(), MemFlags::new(), list_ptr, offset)
|
||||
}
|
||||
Symbol::INT_EQ_I64 | Symbol::INT_EQ_I8 | Symbol::INT_EQ_I1 => {
|
||||
Symbol::INT_EQ_I64 | Symbol::INT_EQ_I8 => {
|
||||
debug_assert!(args.len() == 2);
|
||||
let a = build_arg(&args[0], env, scope, module, builder, procs);
|
||||
let b = build_arg(&args[1], env, scope, module, builder, procs);
|
||||
|
||||
builder.ins().icmp(IntCC::Equal, a, b)
|
||||
}
|
||||
Symbol::INT_EQ_I1 => {
|
||||
debug_assert!(args.len() == 2);
|
||||
let a = build_arg(&args[0], env, scope, module, builder, procs);
|
||||
let b = build_arg(&args[1], env, scope, module, builder, procs);
|
||||
|
||||
// integer comparisons don't work for booleans, and a custom xand gives errors.
|
||||
let p = builder.ins().bint(types::I8, a);
|
||||
let q = builder.ins().bint(types::I8, b);
|
||||
|
||||
builder.ins().icmp(IntCC::Equal, p, q)
|
||||
}
|
||||
Symbol::FLOAT_EQ => {
|
||||
debug_assert!(args.len() == 2);
|
||||
let a = build_arg(&args[0], env, scope, module, builder, procs);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue