forked from AbleOS/ableos
broken for now
This commit is contained in:
parent
d55fd895c9
commit
b059faa7f8
6
Cargo.lock
generated
6
Cargo.lock
generated
|
@ -213,12 +213,12 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "hbbytecode"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#945e5c70f6cb20a77fbb654a0ab6bef7d2b25aac"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#95496116b05bf2ee2192a5acfe1bcedbdb23b28f"
|
||||
|
||||
[[package]]
|
||||
name = "hblang"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#945e5c70f6cb20a77fbb654a0ab6bef7d2b25aac"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#95496116b05bf2ee2192a5acfe1bcedbdb23b28f"
|
||||
dependencies = [
|
||||
"hashbrown",
|
||||
"hbbytecode",
|
||||
|
@ -229,7 +229,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "hbvm"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#945e5c70f6cb20a77fbb654a0ab6bef7d2b25aac"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#95496116b05bf2ee2192a5acfe1bcedbdb23b28f"
|
||||
dependencies = [
|
||||
"hbbytecode",
|
||||
]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.{string, pointer, primitive, unsigned_int, signed_int, float, integer, memory, panic} := @use("stn")
|
||||
.{Kind, string, unsigned_int, signed_int, float, integer, memory, panic} := @use("stn")
|
||||
|
||||
format_int := fn($T: type, v: T, str: ^u8, radix: T): uint {
|
||||
if integer(T) {
|
||||
|
@ -126,38 +126,42 @@ format_float := fn($T: type, v: T, str: ^u8, precision: uint, radix: int): uint
|
|||
}
|
||||
|
||||
format_inner := fn($T: type, v: T, str: ^u8, opts: FormatOptions): uint {
|
||||
if integer(T) | pointer(T) {
|
||||
if integer(T) {
|
||||
return @inline(format_int, T, v, str, @intcast(opts.radix))
|
||||
} else {
|
||||
return @inline(format_int, uint, @bitcast(v), str, 16)
|
||||
}
|
||||
} else if T == bool {
|
||||
return @inline(format_bool, v, str)
|
||||
} else if float(T) {
|
||||
return @inline(format_float, T, v, str, opts.decimal_digits, @intcast(opts.radix))
|
||||
} else if !primitive(T) {
|
||||
i := 0
|
||||
// name := @nameof(T)
|
||||
// len := @inline(string.length, name)
|
||||
len := 0;
|
||||
*@as(^[u8; 2], @bitcast(str + len)) = *@bitcast(".(\0")
|
||||
len += 2
|
||||
$loop {
|
||||
v_sub := v[i]
|
||||
TSub := @TypeOf(v_sub)
|
||||
len += @inline(format_inner, TSub, v_sub, str + len, opts)
|
||||
i += 1
|
||||
if i == @len(T) break else {
|
||||
*@as(^[u8; 2], @bitcast(str + len)) = *@bitcast(", \0")
|
||||
len += 2
|
||||
match @as(Kind, @bitcast(@kindof(T))) {
|
||||
.Pointer => return @inline(format_int, uint, @bitcast(v), str, 16),
|
||||
.Builtin => {
|
||||
if integer(T) {
|
||||
if integer(T) {
|
||||
return @inline(format_int, T, v, str, @intcast(opts.radix))
|
||||
} else {
|
||||
}
|
||||
} else if T == bool {
|
||||
return @inline(format_bool, v, str)
|
||||
} else if float(T) {
|
||||
return @inline(format_float, T, v, str, opts.decimal_digits, @intcast(opts.radix))
|
||||
}
|
||||
};
|
||||
*@as(^[u8; 1], @bitcast(str + len)) = *@bitcast(")\0")
|
||||
len += 1
|
||||
return len
|
||||
} else {
|
||||
panic("Unsupported formatter type\0")
|
||||
},
|
||||
.Struct => {
|
||||
i := 0
|
||||
name := @nameof(T);
|
||||
*@as(^[u8; @len(name)], @bitcast(str)) = *@bitcast(name)
|
||||
len := @inline(string.length, name);
|
||||
*@as(^[u8; 2], @bitcast(str + len)) = *@bitcast(".(\0")
|
||||
len += 2
|
||||
$loop {
|
||||
v_sub := v[i]
|
||||
TSub := @TypeOf(v_sub)
|
||||
len += @inline(format_inner, TSub, v_sub, str + len, opts)
|
||||
i += 1
|
||||
if i == @len(T) break else {
|
||||
*@as(^[u8; 2], @bitcast(str + len)) = *@bitcast(", \0")
|
||||
len += 2
|
||||
}
|
||||
};
|
||||
*@as(^[u8; 1], @bitcast(str + len)) = *@bitcast(")\0")
|
||||
len += 1
|
||||
return len
|
||||
},
|
||||
_ => return 0,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,9 +24,7 @@ panic := fn(message: ?^u8): never {
|
|||
die
|
||||
}
|
||||
|
||||
$pointer := fn($T: type): bool {
|
||||
return T != f64 & T != uint & T != int & @sizeof(T) == @sizeof(uint) & @alignof(T) == @alignof(uint)
|
||||
}
|
||||
Kind := enum {Builtin, Struct, Enum, Union, Pointer, Slice, Opt, Function, Template, Global, Const, Module}
|
||||
|
||||
$unsigned_int := fn($T: type): bool {
|
||||
return T == uint | T == u8 | T == u16 | T == u32
|
||||
|
@ -44,10 +42,6 @@ $float := fn($T: type): bool {
|
|||
return T == f32 | T == f64
|
||||
}
|
||||
|
||||
$primitive := fn($T: type): bool {
|
||||
return integer(T) | float(T) | pointer(T) | T == bool
|
||||
}
|
||||
|
||||
$float_bytes := fn($T: type): type {
|
||||
if T == f64 return uint else if T == f32 return u32
|
||||
}
|
Loading…
Reference in a new issue