Skip to content

Commit

Permalink
Merge pull request #756 from ehaas/evalBranchQuota
Browse files Browse the repository at this point in the history
Update setEvalBranchQuota usage
  • Loading branch information
Vexu authored Aug 22, 2024
2 parents fd6b8a3 + da0b756 commit 26324da
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 5 additions & 1 deletion build/GenerateDef.zig
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,10 @@ fn generate(self: *GenerateDef, input: []const u8) ![]const u8 {
\\/// If found, returns the index of the node within the `dafsa` array.
\\/// Otherwise, returns `null`.
\\pub fn findInList(first_child_index: u16, char: u8) ?u16 {
\\
);
try writer.print(" @setEvalBranchQuota({d});\n", .{values.count() * 2});
try writer.writeAll(
\\ var index = first_child_index;
\\ while (true) {
\\ if (dafsa[index].char == char) return index;
Expand Down Expand Up @@ -453,7 +457,7 @@ fn generate(self: *GenerateDef, input: []const u8) ![]const u8 {

fn writeData(writer: anytype, values: []const Value) !void {
try writer.writeAll("pub const data = blk: {\n");
try writer.print(" @setEvalBranchQuota({});\n", .{values.len});
try writer.print(" @setEvalBranchQuota({d});\n", .{values.len * 7});
try writer.writeAll(" break :blk [_]@This(){\n");
for (values, 0..) |value, i| {
try writer.print(" // {s}\n", .{value.name});
Expand Down
2 changes: 0 additions & 2 deletions src/aro/Attribute.zig
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ pub const Formatting = struct {
if (@typeInfo(Unwrapped) != .Enum) unreachable;

const enum_fields = @typeInfo(Unwrapped).Enum.fields;
@setEvalBranchQuota(3000);
const quote = comptime quoteChar(@enumFromInt(@intFromEnum(tag)));
comptime var values: []const u8 = quote ++ enum_fields[0].name ++ quote;
inline for (enum_fields[1..]) |enum_field| {
Expand Down Expand Up @@ -265,7 +264,6 @@ fn diagnoseField(
@field(@field(arguments, decl.name), field.name) = enum_val;
return null;
} else {
@setEvalBranchQuota(3000);
return .{
.tag = .unknown_attr_enum,
.extra = .{ .attr_enum = .{ .tag = std.meta.stringToEnum(Tag, decl.name).? } },
Expand Down
2 changes: 0 additions & 2 deletions src/aro/Parser.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4986,7 +4986,6 @@ const CallExpr = union(enum) {
}

fn checkVarArg(self: CallExpr, p: *Parser, first_after: TokenIndex, param_tok: TokenIndex, arg: *Result, arg_idx: u32) !void {
@setEvalBranchQuota(10_000);
if (self == .standard) return;

const builtin_tok = p.nodes.items(.data)[@intFromEnum(self.builtin.node)].decl.name;
Expand All @@ -5011,7 +5010,6 @@ const CallExpr = union(enum) {
/// of arguments, `paramCountOverride` is used to tell us how many arguments we should actually expect to see for
/// these custom-typechecked functions.
fn paramCountOverride(self: CallExpr) ?u32 {
@setEvalBranchQuota(10_000);
return switch (self) {
.standard => null,
.builtin => |builtin| switch (builtin.tag) {
Expand Down

0 comments on commit 26324da

Please sign in to comment.