1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
pub const Value = extern struct {
kind: Kind,
value: extern union {
object: u32,
string: extern struct {
ptr: [*]const u8,
len: usize,
},
int: isize,
uint: usize,
float: f64,
undefined: void,
},
pub const Kind = enum(u8) {
uninit = 0,
object = 1,
string = 2,
int = 3,
uint = 4,
float = 5,
undefined = 6,
pub fn asType(comptime self: Kind) type {
return switch (self) {
.object => return u32,
.string => return []const u8,
.int => return isize,
.uint => return usize,
.float => f64,
.undefined => return void,
.uninit => @compileError("uninit has no associated type."),
};
}
};
};
|