mostly just zig fmt

Former-commit-id: 6c7eeb2030
This commit is contained in:
Jarred Sumner
2021-05-25 20:01:06 -07:00
parent f96528adde
commit adbbe2963c
2 changed files with 15 additions and 12 deletions

View File

@@ -42,7 +42,7 @@ pub const ExprNodeList = []Expr;
pub const StmtNodeList = []Stmt;
pub const BindingNodeList = []Binding;
pub const ImportItemStatus = packed enum {
pub const ImportItemStatus = enum {
none,
// The linker doesn't report import/export mismatch errors
@@ -1177,13 +1177,13 @@ pub const Stmt = struct {
},
}
}
fn comptime_alloc(allocator: *std.mem.Allocator, comptime tag_name: string, comptime typename: type, origData: anytype, loc: logger.Loc) callconv(.Inline) Stmt {
inline fn comptime_alloc(allocator: *std.mem.Allocator, comptime tag_name: string, comptime typename: type, origData: anytype, loc: logger.Loc) Stmt {
var st = allocator.create(typename) catch unreachable;
st.* = origData;
return Stmt{ .loc = loc, .data = @unionInit(Data, tag_name, st) };
}
fn comptime_init(comptime tag_name: string, comptime typename: type, origData: anytype, loc: logger.Loc) callconv(.Inline) Stmt {
inline fn comptime_init(comptime tag_name: string, comptime typename: type, origData: anytype, loc: logger.Loc) Stmt {
return Stmt{ .loc = loc, .data = @unionInit(Data, tag_name, origData) };
}
@@ -2347,7 +2347,7 @@ pub const Expr = struct {
.right = b,
}, a.loc);
}
pub fn at(expr: *Expr, t: anytype, allocator: *std.mem.Allocator) callconv(.Inline) Expr {
pub inline fn at(expr: *Expr, t: anytype, allocator: *std.mem.Allocator) Expr {
return alloc(allocator, t, expr.loc);
}
@@ -2499,7 +2499,7 @@ pub const Expr = struct {
return false;
}
pub fn isStringValue(self: Data) callconv(.Inline) bool {
pub inline fn isStringValue(self: Data) bool {
return @as(Expr.Tag, self) == .e_string;
}
};
@@ -2508,7 +2508,7 @@ pub const Expr = struct {
pub const EnumValue = struct {
loc: logger.Loc,
ref: Ref,
name: JavascriptString,
name: E.String,
value: ?ExprNodeIndex,
};
@@ -2856,8 +2856,8 @@ pub const Op = struct {
return try std.json.stringify(self.text, opts, o);
}
pub const TableType: std.EnumArray(Op.Code, Op);
pub const Table = comptime {
pub const TableType: std.EnumArray(Op.Code, Op) = undefined;
pub const Table = {
var table = std.EnumArray(Op.Code, Op).initUndefined();
// Prefix

View File

@@ -65,6 +65,7 @@ pub const Lexer = struct {
has_pure_comment_before: bool = false,
preserve_all_comments_before: bool = false,
is_legacy_octal_literal: bool = false,
is_log_disabled: bool = false,
comments_to_preserve_before: std.ArrayList(js_ast.G.Comment),
all_original_comments: ?[]js_ast.G.Comment = null,
code_point: CodePoint = -1,
@@ -89,7 +90,7 @@ pub const Lexer = struct {
return logger.usize2Loc(self.start);
}
fn nextCodepointSlice(it: *LexerType) callconv(.Inline) !?[]const u8 {
inline fn nextCodepointSlice(it: *LexerType) !?[]const u8 {
if (it.current >= it.source.contents.len) {
// without this line, strings cut off one before the last characte
it.end = it.current;
@@ -114,6 +115,7 @@ pub const Lexer = struct {
}
pub fn addError(self: *LexerType, _loc: usize, comptime format: []const u8, args: anytype, panic: bool) void {
if (self.is_log_disabled) return;
var __loc = logger.usize2Loc(_loc);
if (__loc.eql(self.prev_error_loc)) {
return;
@@ -126,6 +128,7 @@ pub const Lexer = struct {
}
pub fn addRangeError(self: *LexerType, r: logger.Range, comptime format: []const u8, args: anytype, panic: bool) !void {
if (self.is_log_disabled) return;
if (self.prev_error_loc.eql(r.loc)) {
return;
}
@@ -151,7 +154,7 @@ pub const Lexer = struct {
return @intCast(CodePoint, a) == self.code_point;
}
fn nextCodepoint(it: *LexerType) callconv(.Inline) !CodePoint {
inline fn nextCodepoint(it: *LexerType) !CodePoint {
const slice = (try it.nextCodepointSlice()) orelse return @as(CodePoint, -1);
switch (slice.len) {
@@ -892,7 +895,7 @@ pub const Lexer = struct {
pub fn next(lexer: *LexerType) !void {
lexer.has_newline_before = lexer.end == 0;
lex: while (true) {
while (true) {
lexer.start = lexer.end;
lexer.token = T.t_end_of_file;
@@ -2714,7 +2717,7 @@ pub fn rangeOfIdentifier(source: *const Source, loc: logger.Loc) logger.Range {
return r;
}
fn float64(num: anytype) callconv(.Inline) f64 {
inline fn float64(num: anytype) f64 {
return @intToFloat(f64, num);
}