forked from AbleOS/ableos
broken for now
This commit is contained in:
parent
8a78faecdf
commit
9e0ed8a5d7
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,21 +126,25 @@ 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) {
|
||||
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 {
|
||||
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) {
|
||||
}
|
||||
},
|
||||
.Struct => {
|
||||
i := 0
|
||||
// name := @nameof(T)
|
||||
// len := @inline(string.length, name)
|
||||
len := 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 {
|
||||
|
@ -156,8 +160,8 @@ format_inner := fn($T: type, v: T, str: ^u8, opts: FormatOptions): uint {
|
|||
*@as(^[u8; 1], @bitcast(str + len)) = *@bitcast(")\0")
|
||||
len += 1
|
||||
return len
|
||||
} else {
|
||||
panic("Unsupported formatter type\0")
|
||||
},
|
||||
_ => 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