forked from M-Labs/nac3
nac3core: fix converting int to bool (#119)
This commit is contained in:
parent
681d85d3be
commit
0fe346106d
|
@ -1,7 +1,7 @@
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
|
||||||
use nac3parser::ast::fold::Fold;
|
use nac3parser::ast::fold::Fold;
|
||||||
use inkwell::FloatPredicate;
|
use inkwell::{FloatPredicate, IntPredicate};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
symbol_resolver::SymbolValue,
|
symbol_resolver::SymbolValue,
|
||||||
|
@ -415,15 +415,12 @@ impl TopLevelComposer {
|
||||||
if ctx.unifier.unioned(arg_ty, boolean) {
|
if ctx.unifier.unioned(arg_ty, boolean) {
|
||||||
Some(arg)
|
Some(arg)
|
||||||
} else if ctx.unifier.unioned(arg_ty, int32) || ctx.unifier.unioned(arg_ty, int64) {
|
} else if ctx.unifier.unioned(arg_ty, int32) || ctx.unifier.unioned(arg_ty, int64) {
|
||||||
Some(
|
Some(ctx.builder.build_int_compare(
|
||||||
ctx.builder
|
IntPredicate::NE,
|
||||||
.build_int_truncate(
|
ctx.ctx.i64_type().const_zero(),
|
||||||
arg.into_int_value(),
|
arg.into_int_value(),
|
||||||
ctx.ctx.bool_type(),
|
"bool",
|
||||||
"trunc",
|
).into())
|
||||||
)
|
|
||||||
.into(),
|
|
||||||
)
|
|
||||||
} else if ctx.unifier.unioned(arg_ty, float) {
|
} else if ctx.unifier.unioned(arg_ty, float) {
|
||||||
let val = ctx.builder.
|
let val = ctx.builder.
|
||||||
build_float_compare(
|
build_float_compare(
|
||||||
|
|
Loading…
Reference in New Issue