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]]
|
[[package]]
|
||||||
name = "hbbytecode"
|
name = "hbbytecode"
|
||||||
version = "0.1.0"
|
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]]
|
[[package]]
|
||||||
name = "hblang"
|
name = "hblang"
|
||||||
version = "0.1.0"
|
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 = [
|
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#945e5c70f6cb20a77fbb654a0ab6bef7d2b25aac"
|
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#95496116b05bf2ee2192a5acfe1bcedbdb23b28f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hbbytecode",
|
"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 {
|
format_int := fn($T: type, v: T, str: ^u8, radix: T): uint {
|
||||||
if integer(T) {
|
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 {
|
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) {
|
if integer(T) {
|
||||||
return @inline(format_int, T, v, str, @intcast(opts.radix))
|
return @inline(format_int, T, v, str, @intcast(opts.radix))
|
||||||
} else {
|
} else {
|
||||||
return @inline(format_int, uint, @bitcast(v), str, 16)
|
|
||||||
}
|
}
|
||||||
} else if T == bool {
|
} else if T == bool {
|
||||||
return @inline(format_bool, v, str)
|
return @inline(format_bool, v, str)
|
||||||
} else if float(T) {
|
} else if float(T) {
|
||||||
return @inline(format_float, T, v, str, opts.decimal_digits, @intcast(opts.radix))
|
return @inline(format_float, T, v, str, opts.decimal_digits, @intcast(opts.radix))
|
||||||
} else if !primitive(T) {
|
}
|
||||||
|
},
|
||||||
|
.Struct => {
|
||||||
i := 0
|
i := 0
|
||||||
// name := @nameof(T)
|
name := @nameof(T);
|
||||||
// len := @inline(string.length, name)
|
*@as(^[u8; @len(name)], @bitcast(str)) = *@bitcast(name)
|
||||||
len := 0;
|
len := @inline(string.length, name);
|
||||||
*@as(^[u8; 2], @bitcast(str + len)) = *@bitcast(".(\0")
|
*@as(^[u8; 2], @bitcast(str + len)) = *@bitcast(".(\0")
|
||||||
len += 2
|
len += 2
|
||||||
$loop {
|
$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")
|
*@as(^[u8; 1], @bitcast(str + len)) = *@bitcast(")\0")
|
||||||
len += 1
|
len += 1
|
||||||
return len
|
return len
|
||||||
} else {
|
},
|
||||||
panic("Unsupported formatter type\0")
|
_ => return 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,9 +24,7 @@ panic := fn(message: ?^u8): never {
|
||||||
die
|
die
|
||||||
}
|
}
|
||||||
|
|
||||||
$pointer := fn($T: type): bool {
|
Kind := enum {Builtin, Struct, Enum, Union, Pointer, Slice, Opt, Function, Template, Global, Const, Module}
|
||||||
return T != f64 & T != uint & T != int & @sizeof(T) == @sizeof(uint) & @alignof(T) == @alignof(uint)
|
|
||||||
}
|
|
||||||
|
|
||||||
$unsigned_int := fn($T: type): bool {
|
$unsigned_int := fn($T: type): bool {
|
||||||
return T == uint | T == u8 | T == u16 | T == u32
|
return T == uint | T == u8 | T == u16 | T == u32
|
||||||
|
@ -44,10 +42,6 @@ $float := fn($T: type): bool {
|
||||||
return T == f32 | T == f64
|
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 {
|
$float_bytes := fn($T: type): type {
|
||||||
if T == f64 return uint else if T == f32 return u32
|
if T == f64 return uint else if T == f32 return u32
|
||||||
}
|
}
|
Loading…
Reference in a new issue