forked from AbleOS/holey-bytes
making the pointered arrays work properly
Signed-off-by: Jakub Doka <jakub.doka2@gmail.com>
This commit is contained in:
parent
d220823d78
commit
418fd0039e
|
@ -721,6 +721,15 @@ main := fn(): uint {
|
|||
|
||||
### Incomplete Examples
|
||||
|
||||
#### string_array
|
||||
```hb
|
||||
strings := (^u8).["abcdefshijklmnop\0", "abcdefghijklnnop\0", "abcdefshijklmnop\0", "abcdefghijklmnop\0", "abcdefghijflmnop\0", "dbcdefghijklmnop\0", "abcdefghijklmnop\0"]
|
||||
|
||||
main := fn(): uint {
|
||||
return @bitcast(strings[0])
|
||||
}
|
||||
```
|
||||
|
||||
#### comptime_pointers
|
||||
```hb
|
||||
main := fn(): uint {
|
||||
|
|
|
@ -372,7 +372,7 @@ impl<'a> Formatter<'a> {
|
|||
),
|
||||
Expr::Ctor { ty, fields, trailing_comma, .. } => {
|
||||
if let Some(ty) = ty {
|
||||
self.fmt_paren(ty, f, unary)?;
|
||||
self.fmt_paren(ty, f, postfix)?;
|
||||
}
|
||||
f.write_str(".{")?;
|
||||
self.fmt_list(
|
||||
|
@ -409,7 +409,7 @@ impl<'a> Formatter<'a> {
|
|||
),
|
||||
Expr::List { ty, kind: term, fields, trailing_comma, .. } => {
|
||||
if let Some(ty) = ty {
|
||||
self.fmt_paren(ty, f, unary)?;
|
||||
self.fmt_paren(ty, f, postfix)?;
|
||||
}
|
||||
let (start, end) = match term {
|
||||
ListKind::Tuple => (".(", ")"),
|
||||
|
|
|
@ -845,27 +845,21 @@ impl<'a> Codegen<'a> {
|
|||
}
|
||||
Expr::Ident { id, .. }
|
||||
if let Some(vl) = {
|
||||
let mut piter = self.ci.parent;
|
||||
let f = self.file();
|
||||
loop {
|
||||
if let Some((captures, capture_tuple)) = self.tys.captures_of(piter, f)
|
||||
if let Some((captures, capture_tuple)) = self.tys.captures_of(self.ci.parent, f)
|
||||
&& let Some(idx) = captures.iter().position(|&cid| cid.id == id)
|
||||
{
|
||||
if captures[idx].is_ct {
|
||||
let ty = self.tys.ins.args[capture_tuple.range().start + idx];
|
||||
break Some(self.ci.nodes.new_const_lit(ty::Id::TYPE, ty));
|
||||
Some(self.ci.nodes.new_const_lit(ty::Id::TYPE, ty))
|
||||
} else {
|
||||
break Some(
|
||||
Some(
|
||||
Value::new(NEVER)
|
||||
.ty(self.tys.ins.args[capture_tuple.range().start + idx]),
|
||||
);
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
piter = match self.tys.parent_of(piter) {
|
||||
Some(p) => p,
|
||||
None => break None,
|
||||
};
|
||||
} else {
|
||||
None
|
||||
}
|
||||
} =>
|
||||
{
|
||||
|
@ -4350,6 +4344,7 @@ mod tests {
|
|||
fb_driver;
|
||||
|
||||
// Purely Testing Examples;
|
||||
string_array;
|
||||
proper_ident_propagation;
|
||||
method_receiver_by_value;
|
||||
comparing_floating_points;
|
||||
|
|
8
lang/tests/son_tests_string_array.txt
Normal file
8
lang/tests/son_tests_string_array.txt
Normal file
|
@ -0,0 +1,8 @@
|
|||
main:
|
||||
LRA r13, r0, :strings
|
||||
LD r13, r13, 0a, 8h
|
||||
CP r1, r13
|
||||
JALA r0, r31, 0a
|
||||
code size: 98
|
||||
ret: 134998808175692
|
||||
status: Ok(())
|
Loading…
Reference in a new issue