forked from koniifer/ableos
fixing inconststent context for function
This commit is contained in:
parent
a023e29d51
commit
6f544251be
|
@ -631,6 +631,7 @@ min := fn(a: int, b: int): int {
|
||||||
```hb
|
```hb
|
||||||
Point := struct {x: int, y: int}
|
Point := struct {x: int, y: int}
|
||||||
Buffer := struct {}
|
Buffer := struct {}
|
||||||
|
Transform := Point
|
||||||
ColorBGRA := Point
|
ColorBGRA := Point
|
||||||
|
|
||||||
line := fn(buffer: Buffer, p0: Point, p1: Point, color: ColorBGRA, thickness: int): void {
|
line := fn(buffer: Buffer, p0: Point, p1: Point, color: ColorBGRA, thickness: int): void {
|
||||||
|
@ -658,8 +659,35 @@ line_high := fn(buffer: Buffer, p0: Point, p1: Point, color: ColorBGRA): void {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
main := fn(): int {
|
screenidx := @use("screen.hb").screenidx
|
||||||
line(.(), .(0, 0), .(0, 0), .(0, 0), 10)
|
|
||||||
|
rect_line := fn(buffer: Buffer, pos: Point, tr: Transform, color: ColorBGRA, thickness: int): void {
|
||||||
|
t := 0
|
||||||
|
y := 0
|
||||||
|
x := 0
|
||||||
|
loop if t == thickness break else {
|
||||||
|
y = pos.y
|
||||||
|
x = pos.x
|
||||||
|
loop if y == pos.y + tr.x break else {
|
||||||
|
a := 1 + @inline(screenidx, 10)
|
||||||
|
a = 1 + @inline(screenidx, 2)
|
||||||
|
y += 1
|
||||||
|
}
|
||||||
|
t += 1
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
main := fn(): int {
|
||||||
|
line(.(), .(0, 0), .(0, 0), .(0, 0), 10)
|
||||||
|
rect_line(.(), .(0, 0), .(0, 0), .(0, 0), 10)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// in module: screen.hb
|
||||||
|
|
||||||
|
screenidx := fn(orange: int): int {
|
||||||
|
return orange
|
||||||
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
|
@ -1538,8 +1538,12 @@ impl Codegen {
|
||||||
|
|
||||||
let loc = self.alloc_ret(sig.ret, ctx, true);
|
let loc = self.alloc_ret(sig.ret, ctx, true);
|
||||||
let prev_ret_reg = std::mem::replace(&mut self.ci.inline_ret_loc, loc);
|
let prev_ret_reg = std::mem::replace(&mut self.ci.inline_ret_loc, loc);
|
||||||
|
let prev_file = std::mem::replace(&mut self.ci.file, fuc.file);
|
||||||
|
let prev_ret = std::mem::replace(&mut self.ci.ret, Some(sig.ret));
|
||||||
self.expr(body);
|
self.expr(body);
|
||||||
let loc = std::mem::replace(&mut self.ci.inline_ret_loc, prev_ret_reg);
|
let loc = std::mem::replace(&mut self.ci.inline_ret_loc, prev_ret_reg);
|
||||||
|
self.ci.file = prev_file;
|
||||||
|
self.ci.ret = prev_ret;
|
||||||
|
|
||||||
if let Some(last_ret) = self.ci.ret_relocs.last()
|
if let Some(last_ret) = self.ci.ret_relocs.last()
|
||||||
&& last_ret.offset as usize + self.ci.snap.code == self.output.code.len() - 5
|
&& last_ret.offset as usize + self.ci.snap.code == self.output.code.len() - 5
|
||||||
|
|
Loading…
Reference in a new issue