Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: zig 0.13.0-dev.46+3648d7df1 #276

Merged
merged 5 commits into from
May 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ A small/lightweight statically typed scripting language written in Zig

## How to build and install

_Latest zig version supported: 0.12.0-dev.3666+a2b834e8c_
_Latest zig version supported: 0.13.0-dev.46+3648d7df1_

### Requirements
- Since this is built with Zig, you should be able to build buzz on a wide variety of architectures even though this has only been tested on x86/M1.
Expand Down
2 changes: 1 addition & 1 deletion build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ fn getBuzzPrefix(b: *Build) []const u8 {
pub fn build(b: *Build) !void {
// Check minimum zig version
const current_zig = builtin.zig_version;
const min_zig = std.SemanticVersion.parse("0.12.0-dev.3666+a2b834e8c") catch return;
const min_zig = std.SemanticVersion.parse("0.13.0-dev.46+3648d7df1") catch return;
if (current_zig.order(min_zig).compare(.lt)) {
@panic(b.fmt("Your Zig version v{} does not meet the minimum build requirement of v{}", .{ current_zig, min_zig }));
}
Expand Down
6 changes: 2 additions & 4 deletions src/FFI.zig
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ const Reporter = @import("Reporter.zig");

const Self = @This();

const basic_types = std.ComptimeStringMap(
o.ObjTypeDef,
const basic_types = std.StaticStringMap(o.ObjTypeDef).initComptime(
.{
.{ "u8", .{ .def_type = .Integer } },
.{ "i8", .{ .def_type = .Integer } },
Expand All @@ -40,8 +39,7 @@ const basic_types = std.ComptimeStringMap(
},
);

const zig_basic_types = std.ComptimeStringMap(
ZigType,
const zig_basic_types = std.StaticStringMap(ZigType).initComptime(
.{
.{
"anyopaque",
Expand Down
21 changes: 7 additions & 14 deletions src/Parser.zig
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ const buzz_api = @import("lib/buzz_api.zig");

// In the wasm build, libraries are statically linked
const std_lib = if (is_wasm) @import("lib/buzz_std.zig") else void;
const std_api = if (is_wasm) std.ComptimeStringMap(
buzz_api.NativeFn,
const std_api = if (is_wasm) std.StaticStringMap(buzz_api.NativeFn).initComptime(
.{
.{ "assert", &std_lib.assert },
.{ "buzzPanic", &std_lib.buzzPanic },
Expand All @@ -37,17 +36,15 @@ const std_api = if (is_wasm) std.ComptimeStringMap(
) else void;

const gc_lib = if (is_wasm) @import("lib/buzz_gc.zig") else void;
const gc_api = if (is_wasm) std.ComptimeStringMap(
buzz_api.NativeFn,
const gc_api = if (is_wasm) std.StaticStringMap(buzz_api.NativeFn).initComptime(
.{
.{ "allocated", &gc_lib.allocated },
.{ "collect", &gc_lib.collect },
},
) else void;

const math_lib = if (is_wasm) @import("lib/buzz_math.zig") else void;
const math_api = if (is_wasm) std.ComptimeStringMap(
buzz_api.NativeFn,
const math_api = if (is_wasm) std.StaticStringMap(buzz_api.NativeFn).initComptime(
.{
.{ "abs", &math_lib.abs },
.{ "acos", &math_lib.acos },
Expand All @@ -70,8 +67,7 @@ const math_api = if (is_wasm) std.ComptimeStringMap(
) else void;

const buffer_lib = if (is_wasm) @import("lib/buzz_buffer.zig") else void;
const buffer_api = if (is_wasm) std.ComptimeStringMap(
buzz_api.NativeFn,
const buffer_api = if (is_wasm) std.StaticStringMap(buzz_api.NativeFn).initComptime(
.{
.{ "BufferNew", &buffer_lib.BufferNew },
.{ "BufferDeinit", &buffer_lib.BufferDeinit },
Expand Down Expand Up @@ -104,24 +100,21 @@ const buffer_api = if (is_wasm) std.ComptimeStringMap(
) else void;

const debug_lib = if (is_wasm) @import("lib/buzz_debug.zig") else void;
const debug_api = if (is_wasm) std.ComptimeStringMap(
buzz_api.NativeFn,
const debug_api = if (is_wasm) std.StaticStringMap(buzz_api.NativeFn).initComptime(
.{
.{ "dump", &debug_lib.dump },
},
) else void;

const serialize_lib = if (is_wasm) @import("lib/buzz_serialize.zig") else void;
const serialize_api = if (is_wasm) std.ComptimeStringMap(
buzz_api.NativeFn,
const serialize_api = if (is_wasm) std.StaticStringMap(buzz_api.NativeFn).initComptime(
.{
.{ "serialize", &serialize_lib.serialize },
},
) else void;

const crypto_lib = if (is_wasm) @import("lib/buzz_crypto.zig") else void;
const crypto_api = if (is_wasm) std.ComptimeStringMap(
buzz_api.NativeFn,
const crypto_api = if (is_wasm) std.StaticStringMap(buzz_api.NativeFn).initComptime(
.{
.{ "hash", &crypto_lib.hash },
},
Expand Down
3 changes: 1 addition & 2 deletions src/Token.zig
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,7 @@ pub const Type = enum {
Range, // range
};

pub const keywords = std.ComptimeStringMap(
Type,
pub const keywords = std.StaticStringMap(Type).initComptime(
.{
.{ "and", .And },
.{ "any", .Any },
Expand Down
2 changes: 1 addition & 1 deletion src/ext/clap
Submodule clap updated 1 files
+0 −5 zig.mod
1 change: 1 addition & 0 deletions src/lib/buzz_os.zig
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ fn handleSpawnError(ctx: *api.NativeCtx, err: anytype) void {
error.NameTooLong,
error.NoDevice,
error.NotDir,
error.InvalidBatchScriptArg,
error.ProcessFdQuotaExceeded,
error.SymLinkLoop,
error.SystemFdQuotaExceeded,
Expand Down
1 change: 1 addition & 0 deletions src/lib/errors.buzz
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export enum FileSystemError {
FileLocksNotSupported,
FileNotFound,
FileSystem,
InvalidBatchScriptArg,
FileTooBig,
InputOutput,
InvalidHandle,
Expand Down
40 changes: 17 additions & 23 deletions src/obj.zig
Original file line number Diff line number Diff line change
Expand Up @@ -542,23 +542,21 @@ pub const ObjFiber = struct {
return obj.cast(Self, .Fiber);
}

const members = std.ComptimeStringMap(
NativeFn,
const members = std.StaticStringMap(NativeFn).initComptime(
.{
.{ "over", buzz_builtin.fiber.over },
.{ "cancel", buzz_builtin.fiber.cancel },
.{ "isMain", buzz_builtin.fiber.isMain },
},
);

const members_typedef = std.ComptimeStringMap(
const members_typedef = std.StaticStringMap(
[]const u8,
.{
.{ "over", "extern Function over() > bool" },
.{ "cancel", "extern Function cancel() > void" },
.{ "isMain", "extern Function isMain() > bool" },
},
);
).initComptime(.{
.{ "over", "extern Function over() > bool" },
.{ "cancel", "extern Function cancel() > void" },
.{ "isMain", "extern Function isMain() > bool" },
});

pub fn member(vm: *VM, method: *ObjString) !?*ObjNative {
if (vm.gc.objfiber_members.get(method)) |umethod| {
Expand Down Expand Up @@ -642,8 +640,7 @@ pub const ObjPattern = struct {
return obj.cast(Self, .Pattern);
}

const members = std.ComptimeStringMap(
NativeFn,
const members = std.StaticStringMap(NativeFn).initComptime(
if (!is_wasm)
.{
.{ "match", buzz_builtin.pattern.match },
Expand All @@ -658,8 +655,7 @@ pub const ObjPattern = struct {
},
);

const members_typedef = std.ComptimeStringMap(
[]const u8,
const members_typedef = std.StaticStringMap([]const u8).initComptime(
if (!is_wasm)
.{
.{ "match", "extern Function match(str subject) > [str]?" },
Expand Down Expand Up @@ -786,8 +782,7 @@ pub const ObjString = struct {
}
}

pub const members = std.ComptimeStringMap(
NativeFn,
pub const members = std.StaticStringMap(NativeFn).initComptime(
.{
.{ "len", buzz_builtin.str.len },
.{ "utf8Len", buzz_builtin.str.utf8Len },
Expand All @@ -811,8 +806,9 @@ pub const ObjString = struct {
},
);

pub const members_typedef = std.ComptimeStringMap(
pub const members_typedef = std.StaticStringMap(
[]const u8,
).initComptime(
.{
.{ "len", "extern Function len() > int" },
.{ "utf8Len", "extern Function utf8Len() > int" },
Expand Down Expand Up @@ -1605,8 +1601,9 @@ pub const ObjList = struct {
return obj.cast(Self, .List);
}

const members = std.ComptimeStringMap(
const members = std.StaticStringMap(
NativeFn,
).initComptime(
.{
.{ "append", buzz_builtin.list.append },
.{ "clone", buzz_builtin.list.clone },
Expand Down Expand Up @@ -2489,17 +2486,15 @@ pub const ObjRange = struct {
return obj.cast(Self, .Range);
}

const members = std.ComptimeStringMap(
NativeFn,
const members = std.StaticStringMap(NativeFn).initComptime(
.{
.{ "toList", buzz_builtin.range.toList },
.{ "len", buzz_builtin.range.len },
.{ "invert", buzz_builtin.range.invert },
},
);

const members_typedef = std.ComptimeStringMap(
[]const u8,
const members_typedef = std.StaticStringMap([]const u8).initComptime(
.{
.{ "toList", "extern Function toList() > [int]" },
.{ "len", "extern Function len() > int" },
Expand Down Expand Up @@ -2574,8 +2569,7 @@ pub const ObjMap = struct {
try gc.markObjDirty(&self.obj);
}

const members = std.ComptimeStringMap(
NativeFn,
const members = std.StaticStringMap(NativeFn).initComptime(
.{
.{ "clone", buzz_builtin.map.clone },
.{ "diff", buzz_builtin.map.diff },
Expand Down
Loading