added object type

This commit is contained in:
Moritz Gmeiner 2025-03-30 15:38:22 +02:00
commit f9b5f62e65

View file

@ -1,13 +1,23 @@
//! By convention, root.zig is the root source file when making a library. If
//! you are making an executable, the convention is to delete this file and
//! start with main.zig instead.
const std = @import("std");
const testing = std.testing;
pub export fn add(a: i32, b: i32) i32 {
return a + b;
}
const Raw = union(enum) {
string: []u8,
binary: []u8,
};
test "basic add functionality" {
try testing.expect(add(3, 7) == 10);
const Object = union(enum) {
nil,
bool: bool,
integer: i64,
float: f64,
raw: Raw,
array: []Object,
map: []struct { key: Object, value: Object },
extension: struct { type: u8, bytes: []u8 },
};
test {
const o: Object = .nil;
_ = o;
}