forked from AbleOS/ableos
tuple and array syntax
This commit is contained in:
parent
0e27f57bc6
commit
49d00313e2
6
Cargo.lock
generated
6
Cargo.lock
generated
|
@ -213,12 +213,12 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hbbytecode"
|
name = "hbbytecode"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#f59c0c10922fb330d43b944a5bfcaa1021ecffe3"
|
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#4b3b6af70eb84d513b9fa926dd8c36e1dba88713"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hblang"
|
name = "hblang"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#f59c0c10922fb330d43b944a5bfcaa1021ecffe3"
|
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#4b3b6af70eb84d513b9fa926dd8c36e1dba88713"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hashbrown",
|
"hashbrown",
|
||||||
"hbbytecode",
|
"hbbytecode",
|
||||||
|
@ -229,7 +229,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hbvm"
|
name = "hbvm"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#f59c0c10922fb330d43b944a5bfcaa1021ecffe3"
|
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#4b3b6af70eb84d513b9fa926dd8c36e1dba88713"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hbbytecode",
|
"hbbytecode",
|
||||||
]
|
]
|
||||||
|
|
|
@ -119,11 +119,23 @@ fmt_float := fn(v: @Any(), str: ^u8, precision: uint, radix: int): uint {
|
||||||
|
|
||||||
fmt_container := fn(v: @Any(), str: ^u8, opts: FormatOptions): uint {
|
fmt_container := fn(v: @Any(), str: ^u8, opts: FormatOptions): uint {
|
||||||
T2 := @TypeOf(v)
|
T2 := @TypeOf(v)
|
||||||
i := 0;
|
kind := Kind.of(T2)
|
||||||
*@as(^[@lenof(@nameof(T2))]u8, @bitcast(str)) = *@bitcast(@nameof(T2))
|
i := 0
|
||||||
len := @lenof(@nameof(T2));
|
len := 0
|
||||||
*@as(^[2]u8, @bitcast(str + len)) = *@bitcast(".(\0")
|
if kind == .Struct {
|
||||||
len += 2
|
*@as(^[@lenof(@nameof(T2))]u8, @bitcast(str + len)) = *@bitcast(@nameof(T2))
|
||||||
|
len += @lenof(@nameof(T2));
|
||||||
|
*@as(^[2]u8, @bitcast(str + len)) = *@bitcast(".(\0")
|
||||||
|
len += 2
|
||||||
|
} else if kind == .Slice {
|
||||||
|
*@as(^[@lenof(@nameof(@ChildOf(T2)))]u8, @bitcast(str + len)) = *@bitcast(@nameof(@ChildOf(T2)))
|
||||||
|
len += @lenof(@nameof(@ChildOf(T2)));
|
||||||
|
*@as(^[2]u8, @bitcast(str + len)) = *@bitcast(".[\0")
|
||||||
|
len += 2
|
||||||
|
} else if kind == .Tuple {
|
||||||
|
*@as(^[2]u8, @bitcast(str + len)) = *@bitcast(".(\0")
|
||||||
|
len += 2
|
||||||
|
}
|
||||||
$loop {
|
$loop {
|
||||||
v_sub := v[i]
|
v_sub := v[i]
|
||||||
len += @inline(format, v_sub, str + len, opts)
|
len += @inline(format, v_sub, str + len, opts)
|
||||||
|
@ -132,9 +144,14 @@ fmt_container := fn(v: @Any(), str: ^u8, opts: FormatOptions): uint {
|
||||||
*@as(^[2]u8, @bitcast(str + len)) = *@bitcast(", \0")
|
*@as(^[2]u8, @bitcast(str + len)) = *@bitcast(", \0")
|
||||||
len += 2
|
len += 2
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
*@as(^[1]u8, @bitcast(str + len)) = *@bitcast(")\0")
|
if kind == .Struct | kind == .Tuple {
|
||||||
len += 1
|
*@as(^[1]u8, @bitcast(str + len)) = *@bitcast(")\0")
|
||||||
|
len += 1
|
||||||
|
} else if kind == .Slice {
|
||||||
|
*@as(^[1]u8, @bitcast(str + len)) = *@bitcast("]\0")
|
||||||
|
len += 1
|
||||||
|
}
|
||||||
return len
|
return len
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue