forked from M-Labs/nac3
fixed tests
This commit is contained in:
parent
084efe92af
commit
7d48883583
|
@ -328,14 +328,14 @@ fn test_simple_call() {
|
||||||
|
|
||||||
body: ; preds = %init
|
body: ; preds = %init
|
||||||
%load = load i32, i32* %a, align 4
|
%load = load i32, i32* %a, align 4
|
||||||
%call = call i32 @foo_0(i32 %load)
|
%call = call i32 @foo.0(i32 %load)
|
||||||
store i32 %call, i32* %a, align 4
|
store i32 %call, i32* %a, align 4
|
||||||
%load1 = load i32, i32* %a, align 4
|
%load1 = load i32, i32* %a, align 4
|
||||||
%mul = mul i32 %load1, 2
|
%mul = mul i32 %load1, 2
|
||||||
ret i32 %mul
|
ret i32 %mul
|
||||||
}
|
}
|
||||||
|
|
||||||
define i32 @foo_0(i32 %0) {
|
define i32 @foo.0(i32 %0) {
|
||||||
init:
|
init:
|
||||||
%a = alloca i32, align 4
|
%a = alloca i32, align 4
|
||||||
store i32 %0, i32* %a, align 4
|
store i32 %0, i32* %a, align 4
|
||||||
|
|
|
@ -248,9 +248,17 @@ impl<'a> Inferencer<'a> {
|
||||||
if let TypeEnum::TFunc(sign) = &*self.unifier.get_ty(*ty) {
|
if let TypeEnum::TFunc(sign) = &*self.unifier.get_ty(*ty) {
|
||||||
let sign = sign.borrow();
|
let sign = sign.borrow();
|
||||||
if sign.vars.is_empty() {
|
if sign.vars.is_empty() {
|
||||||
|
let call = self.unifier.add_call(Call {
|
||||||
|
posargs: params,
|
||||||
|
kwargs: HashMap::new(),
|
||||||
|
ret: sign.ret,
|
||||||
|
fun: RefCell::new(None),
|
||||||
|
});
|
||||||
|
let call = self.unifier.add_ty(TypeEnum::TCall(vec![call].into()));
|
||||||
if let Some(ret) = ret {
|
if let Some(ret) = ret {
|
||||||
self.unifier.unify(sign.ret, ret).unwrap();
|
self.unifier.unify(sign.ret, ret).unwrap();
|
||||||
}
|
}
|
||||||
|
self.constrain(call, *ty, &location)?;
|
||||||
return Ok(sign.ret);
|
return Ok(sign.ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -483,6 +491,17 @@ impl<'a> Inferencer<'a> {
|
||||||
if let TypeEnum::TFunc(sign) = &*self.unifier.get_ty(func.custom.unwrap()) {
|
if let TypeEnum::TFunc(sign) = &*self.unifier.get_ty(func.custom.unwrap()) {
|
||||||
let sign = sign.borrow();
|
let sign = sign.borrow();
|
||||||
if sign.vars.is_empty() {
|
if sign.vars.is_empty() {
|
||||||
|
let call = self.unifier.add_call(Call {
|
||||||
|
posargs: args.iter().map(|v| v.custom.unwrap()).collect(),
|
||||||
|
kwargs: keywords
|
||||||
|
.iter()
|
||||||
|
.map(|v| (v.node.arg.as_ref().unwrap().clone(), v.custom.unwrap()))
|
||||||
|
.collect(),
|
||||||
|
fun: RefCell::new(None),
|
||||||
|
ret: sign.ret,
|
||||||
|
});
|
||||||
|
let call = self.unifier.add_ty(TypeEnum::TCall(vec![call].into()));
|
||||||
|
self.unify(func.custom.unwrap(), call, &func.location)?;
|
||||||
return Ok(Located {
|
return Ok(Located {
|
||||||
location,
|
location,
|
||||||
custom: Some(sign.ret),
|
custom: Some(sign.ret),
|
||||||
|
|
Loading…
Reference in New Issue