forked from AbleOS/holey-bytes
wrong index for extend
This commit is contained in:
parent
65e9f272a8
commit
b8032aa840
|
@ -612,6 +612,39 @@ main := fn(): uint {
|
|||
|
||||
### Purely Testing Examples
|
||||
|
||||
#### null_check_returning_small_global
|
||||
```hb
|
||||
MAGIC := 127
|
||||
get := fn(file: ^u8): ?uint {
|
||||
if *file == MAGIC {
|
||||
return MAGIC
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
some_file := [u8].(127, 255, 255, 255, 255, 255)
|
||||
|
||||
foo := fn(): ?uint {
|
||||
gotten := get(&some_file[0])
|
||||
if gotten == null {
|
||||
return null
|
||||
} else if gotten == 4 {
|
||||
return 2
|
||||
} else if gotten == MAGIC {
|
||||
return 0
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
main := fn(): uint {
|
||||
f := foo()
|
||||
if f == null return 100
|
||||
return f
|
||||
}
|
||||
```
|
||||
|
||||
#### null_check_in_the_loop
|
||||
```hb
|
||||
A := struct {
|
||||
|
|
|
@ -4579,7 +4579,7 @@ mod tests {
|
|||
fn generate(ident: &'static str, input: &'static str, output: &mut String) {
|
||||
_ = log::set_logger(&crate::fs::Logger);
|
||||
log::set_max_level(log::LevelFilter::Info);
|
||||
//log::set_max_level(log::LevelFilter::Trace);
|
||||
// log::set_max_level(log::LevelFilter::Trace);
|
||||
|
||||
let mut ctx = CodegenCtx::default();
|
||||
let (ref files, embeds) = crate::test_parse_files(ident, input, &mut ctx.parser);
|
||||
|
@ -4640,6 +4640,7 @@ mod tests {
|
|||
fb_driver;
|
||||
|
||||
// Purely Testing Examples;
|
||||
null_check_returning_small_global;
|
||||
null_check_in_the_loop;
|
||||
stack_provenance;
|
||||
advanced_floating_point_arithmetic;
|
||||
|
|
|
@ -264,8 +264,8 @@ impl HbvmBackend {
|
|||
} else if let Some(against) = op.cmp_against() {
|
||||
let op_ty = fuc.nodes[rh].ty;
|
||||
|
||||
self.emit(extend(fuc.nodes[lh].ty, fuc.nodes[lh].ty.extend(), 0, 0));
|
||||
self.emit(extend(fuc.nodes[rh].ty, fuc.nodes[rh].ty.extend(), 1, 1));
|
||||
self.emit(extend(fuc.nodes[lh].ty, fuc.nodes[lh].ty.extend(), 1, 1));
|
||||
self.emit(extend(fuc.nodes[rh].ty, fuc.nodes[rh].ty.extend(), 2, 2));
|
||||
let &[dst, lhs, rhs] = allocs else { unreachable!() };
|
||||
|
||||
if op_ty.is_float() && matches!(op, TokenKind::Le | TokenKind::Ge) {
|
||||
|
|
Loading…
Reference in a new issue