forked from AbleOS/holey-bytes
fixing messed up flag calculation
This commit is contained in:
parent
f535ea7b0a
commit
9d2f419140
|
@ -624,6 +624,25 @@ main := fn(): uint {
|
||||||
|
|
||||||
### Purely Testing Examples
|
### Purely Testing Examples
|
||||||
|
|
||||||
|
#### nullable_structure
|
||||||
|
```hb
|
||||||
|
Structure := struct {}
|
||||||
|
|
||||||
|
returner_fn := fn(): ?Structure {
|
||||||
|
structure := Structure.()
|
||||||
|
return structure
|
||||||
|
}
|
||||||
|
|
||||||
|
main := fn(): int {
|
||||||
|
ret := returner_fn()
|
||||||
|
if ret != null {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
#### needless_unwrap
|
#### needless_unwrap
|
||||||
```hb
|
```hb
|
||||||
main := fn(): uint {
|
main := fn(): uint {
|
||||||
|
|
|
@ -4267,10 +4267,11 @@ impl<'a> Codegen<'a> {
|
||||||
|
|
||||||
match oty.loc(self.tys) {
|
match oty.loc(self.tys) {
|
||||||
Loc::Reg => {
|
Loc::Reg => {
|
||||||
|
std::println!("{} {} {}", self.ty_display(oty), flag_offset, self.tys.size_of(oty));
|
||||||
self.strip_ptr(val);
|
self.strip_ptr(val);
|
||||||
// registers have inverted offsets so that accessing the inner type is a noop
|
// registers have inverted offsets so that accessing the inner type is a noop
|
||||||
let flag_offset = self.tys.size_of(oty) - flag_offset - 1;
|
let flag_offset = self.tys.size_of(oty) * 8 - flag_offset * 8 - 1;
|
||||||
let fill = self.ci.nodes.new_const(oty, 1i64 << (flag_offset * 8 - 1));
|
let fill = self.ci.nodes.new_const(oty, 1i64 << flag_offset);
|
||||||
val.id = self
|
val.id = self
|
||||||
.ci
|
.ci
|
||||||
.nodes
|
.nodes
|
||||||
|
@ -4595,6 +4596,7 @@ mod tests {
|
||||||
fb_driver;
|
fb_driver;
|
||||||
|
|
||||||
// Purely Testing Examples;
|
// Purely Testing Examples;
|
||||||
|
nullable_structure;
|
||||||
needless_unwrap;
|
needless_unwrap;
|
||||||
inlining_issues;
|
inlining_issues;
|
||||||
null_check_test;
|
null_check_test;
|
||||||
|
|
21
lang/tests/son_tests_nullable_structure.txt
Normal file
21
lang/tests/son_tests_nullable_structure.txt
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
main:
|
||||||
|
ADDI64 r254, r254, -16d
|
||||||
|
ST r31, r254, 0a, 16h
|
||||||
|
JAL r31, r0, :returner_fn
|
||||||
|
LI8 r32, 0b
|
||||||
|
ANDI r1, r1, 255d
|
||||||
|
ANDI r32, r32, 255d
|
||||||
|
JEQ r1, r32, :0
|
||||||
|
LI64 r1, 1d
|
||||||
|
JMP :1
|
||||||
|
0: LI64 r1, 0d
|
||||||
|
1: LD r31, r254, 0a, 16h
|
||||||
|
ADDI64 r254, r254, 16d
|
||||||
|
JALA r0, r31, 0a
|
||||||
|
returner_fn:
|
||||||
|
LD r1, r254, 0a, 0h
|
||||||
|
ORI r1, r1, 128d
|
||||||
|
JALA r0, r31, 0a
|
||||||
|
code size: 164
|
||||||
|
ret: 1
|
||||||
|
status: Ok(())
|
|
@ -38,7 +38,7 @@ main:
|
||||||
JNE r1, r0, :7
|
JNE r1, r0, :7
|
||||||
CP r39, r38
|
CP r39, r38
|
||||||
JMP :8
|
JMP :8
|
||||||
7: LI32 r39, 8388609w
|
7: LI32 r39, 2147483649w
|
||||||
8: ANDI r39, r39, 4294967295d
|
8: ANDI r39, r39, 4294967295d
|
||||||
ANDI r38, r38, 4294967295d
|
ANDI r38, r38, 4294967295d
|
||||||
JNE r39, r38, :9
|
JNE r39, r38, :9
|
||||||
|
|
Loading…
Reference in a new issue