forked from AbleOS/holey-bytes
fixing generic function inlining
This commit is contained in:
parent
9e65f3949d
commit
6d7e726066
|
@ -905,6 +905,7 @@ impl Codegen {
|
||||||
|
|
||||||
let scope = self.ci.vars.len();
|
let scope = self.ci.vars.len();
|
||||||
let sig = self.compute_signature(&mut func, func_ast.pos(), args)?;
|
let sig = self.compute_signature(&mut func, func_ast.pos(), args)?;
|
||||||
|
self.ci.vars.truncate(scope);
|
||||||
|
|
||||||
self.assert_arg_count(expr.pos(), args.len(), cargs.len(), "inline function call");
|
self.assert_arg_count(expr.pos(), args.len(), cargs.len(), "inline function call");
|
||||||
|
|
||||||
|
@ -912,13 +913,10 @@ impl Codegen {
|
||||||
for (arg, carg) in args.iter().zip(cargs) {
|
for (arg, carg) in args.iter().zip(cargs) {
|
||||||
let ty = self.tys.ins.args[sig_args.next().unwrap()];
|
let ty = self.tys.ins.args[sig_args.next().unwrap()];
|
||||||
let sym = parser::find_symbol(&ast.symbols, carg.id);
|
let sym = parser::find_symbol(&ast.symbols, carg.id);
|
||||||
if sym.flags & idfl::COMPTIME != 0 {
|
let loc = match sym.flags & idfl::COMPTIME != 0 {
|
||||||
sig_args.next().unwrap();
|
true => Loc::ty(self.tys.ins.args[sig_args.next().unwrap()]),
|
||||||
continue;
|
false => self.expr_ctx(arg, Ctx::default().with_ty(ty))?.loc,
|
||||||
}
|
};
|
||||||
|
|
||||||
debug_assert_ne!(ty, ty::Id::TYPE);
|
|
||||||
let loc = self.expr_ctx(arg, Ctx::default().with_ty(ty))?.loc;
|
|
||||||
self.ci.vars.push(Variable { id: carg.id, value: Value { ty, loc } });
|
self.ci.vars.push(Variable { id: carg.id, value: Value { ty, loc } });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
main:
|
||||||
|
ADDI64 r254, r254, -32d
|
||||||
|
ST r31, r254, 0a, 32h
|
||||||
|
LI64 r32, 10d
|
||||||
|
NEG r32, r32
|
||||||
|
CP r33, r32
|
||||||
|
LI64 r34, 8d
|
||||||
|
ADDI64 r34, r34, -1d
|
||||||
|
SRS64 r33, r33, r34
|
||||||
|
CP r34, r32
|
||||||
|
XOR r34, r34, r33
|
||||||
|
SUB64 r1, r34, r33
|
||||||
|
LD r31, r254, 0a, 32h
|
||||||
|
ADDI64 r254, r254, 32d
|
||||||
|
JALA r0, r31, 0a
|
||||||
|
code size: 119
|
||||||
|
ret: 10
|
||||||
|
status: Ok(())
|
Loading…
Reference in a new issue