Nullable pointer and loop inlining tests. #22
|
@ -1042,6 +1042,41 @@ main := fn(): uint {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### inlining_loops
|
||||||
|
```hb
|
||||||
|
x := 1
|
||||||
|
|
||||||
|
foo := fn(): void {
|
||||||
|
loop if true break
|
||||||
|
x = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
main := fn(): uint {
|
||||||
|
@inline(foo)
|
||||||
|
return x
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### null_check_test
|
||||||
|
```hb
|
||||||
|
get_ptr := fn(): ?^uint {
|
||||||
|
value := 0
|
||||||
|
return &value
|
||||||
|
}
|
||||||
|
|
||||||
|
main := fn(): void {
|
||||||
|
ptr := get_ptr()
|
||||||
|
|
||||||
|
if ptr == null {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
loop {
|
||||||
|
*ptr += 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### Just Testing Optimizations
|
### Just Testing Optimizations
|
||||||
|
|
||||||
#### const_folding_with_arg
|
#### const_folding_with_arg
|
||||||
|
|
|
@ -4412,6 +4412,8 @@ mod tests {
|
||||||
writing_into_string;
|
writing_into_string;
|
||||||
request_page;
|
request_page;
|
||||||
tests_ptr_to_ptr_copy;
|
tests_ptr_to_ptr_copy;
|
||||||
|
inlining_loops;
|
||||||
|
null_check_test;
|
||||||
|
|
||||||
// Just Testing Optimizations;
|
// Just Testing Optimizations;
|
||||||
const_folding_with_arg;
|
const_folding_with_arg;
|
||||||
|
|
8
lang/tests/son_tests_inlining_loops.txt
Normal file
8
lang/tests/son_tests_inlining_loops.txt
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
main:
|
||||||
|
LRA r2, r0, :x
|
||||||
|
LI64 r1, 0d
|
||||||
|
ST r1, r2, 0a, 8h
|
||||||
|
JALA r0, r31, 0a
|
||||||
|
code size: 57
|
||||||
|
ret: 0
|
||||||
|
status: Ok(())
|
6
lang/tests/son_tests_null_check_test.txt
Normal file
6
lang/tests/son_tests_null_check_test.txt
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
test.hb:15:4: can't prove the value is not 'null', use '@unwrap(<opt>)' if you believe compiler is stupid, or explicitly check for null and handle it ('if <opt> == null { /* handle */ } else { /* use opt */ }')
|
||||||
|
*ptr += 1
|
||||||
|
^
|
||||||
|
test.hb:15:4: can't prove the value is not 'null', use '@unwrap(<opt>)' if you believe compiler is stupid, or explicitly check for null and handle it ('if <opt> == null { /* handle */ } else { /* use opt */ }')
|
||||||
|
*ptr += 1
|
||||||
|
^
|
Loading…
Reference in a new issue