@@ -192,8 +192,8 @@ fn prepopulateGlobalNameTable(c: *Context) !void {
192192 const node_types = c .tree .nodes .items (.ty );
193193 const node_data = c .tree .nodes .items (.data );
194194 for (c .tree .root_decls ) | node | {
195- const data = node_data [@enumToInt (node )];
196- const decl_name = switch (node_tags [@enumToInt (node )]) {
195+ const data = node_data [@intFromEnum (node )];
196+ const decl_name = switch (node_tags [@intFromEnum (node )]) {
197197 .typedef = > @panic ("TODO" ),
198198
199199 .static_assert ,
@@ -202,15 +202,15 @@ fn prepopulateGlobalNameTable(c: *Context) !void {
202202 .struct_decl ,
203203 .union_decl ,
204204 = > blk : {
205- const ty = node_types [@enumToInt (node )];
205+ const ty = node_types [@intFromEnum (node )];
206206 const name_id = ty .data .record .name ;
207207 break :blk c .mapper .lookup (name_id );
208208 },
209209
210210 .enum_decl_two ,
211211 .enum_decl ,
212212 = > blk : {
213- const ty = node_types [@enumToInt (node )];
213+ const ty = node_types [@intFromEnum (node )];
214214 const name_id = ty .data .@"enum" .name ;
215215 break :blk c .mapper .lookup (name_id );
216216 },
@@ -240,8 +240,8 @@ fn transTopLevelDecls(c: *Context) !void {
240240 const node_tags = c .tree .nodes .items (.tag );
241241 const node_data = c .tree .nodes .items (.data );
242242 for (c .tree .root_decls ) | node | {
243- const data = node_data [@enumToInt (node )];
244- switch (node_tags [@enumToInt (node )]) {
243+ const data = node_data [@intFromEnum (node )];
244+ switch (node_tags [@intFromEnum (node )]) {
245245 .typedef = > {
246246 try transTypeDef (c , & c .global_scope .base , node );
247247 },
@@ -255,16 +255,14 @@ fn transTopLevelDecls(c: *Context) !void {
255255 try transRecordDecl (c , & c .global_scope .base , node );
256256 },
257257
258- .enum_decl_two ,
259- = > {
258+ .enum_decl_two = > {
260259 var fields = [2 ]NodeIndex { data .bin .lhs , data .bin .rhs };
261260 var field_count : u8 = 0 ;
262261 if (fields [0 ] != .none ) field_count += 1 ;
263262 if (fields [1 ] != .none ) field_count += 1 ;
264263 try transEnumDecl (c , & c .global_scope .base , node , fields [0.. field_count ]);
265264 },
266- .enum_decl ,
267- = > {
265+ .enum_decl = > {
268266 const fields = c .tree .data [data .range .start .. data .range .end ];
269267 try transEnumDecl (c , & c .global_scope .base , node , fields );
270268 },
@@ -309,17 +307,17 @@ fn transVarDecl(_: *Context, _: NodeIndex, _: ?usize) Error!void {
309307}
310308fn transEnumDecl (c : * Context , scope : * Scope , enum_decl : NodeIndex , field_nodes : []const NodeIndex ) Error ! void {
311309 const node_types = c .tree .nodes .items (.ty );
312- const ty = node_types [@enumToInt (enum_decl )];
310+ const ty = node_types [@intFromEnum (enum_decl )];
313311 const node_data = c .tree .nodes .items (.data );
314- if (c .decl_table .get (@ptrToInt (ty .data .@"enum" ))) | _ |
312+ if (c .decl_table .get (@intFromPtr (ty .data .@"enum" ))) | _ |
315313 return ; // Avoid processing this decl twice
316314 const toplevel = scope .id == .root ;
317315 const bs : * Scope.Block = if (! toplevel ) try scope .findBlockScope (c ) else undefined ;
318316
319317 var is_unnamed = false ;
320318 var bare_name : []const u8 = c .mapper .lookup (ty .data .@"enum" .name );
321319 var name = bare_name ;
322- if (c .unnamed_typedefs .get (@ptrToInt (ty .data .@"enum" ))) | typedef_name | {
320+ if (c .unnamed_typedefs .get (@intFromPtr (ty .data .@"enum" ))) | typedef_name | {
323321 bare_name = typedef_name ;
324322 name = typedef_name ;
325323 } else {
@@ -330,7 +328,7 @@ fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: NodeIndex, field_nodes:
330328 name = try std .fmt .allocPrint (c .arena , "enum_{s}" , .{bare_name });
331329 }
332330 if (! toplevel ) name = try bs .makeMangledName (c , name );
333- try c .decl_table .putNoClobber (c .gpa , @ptrToInt (ty .data .@"enum" ), name );
331+ try c .decl_table .putNoClobber (c .gpa , @intFromPtr (ty .data .@"enum" ), name );
334332
335333 const enum_type_node = if (! ty .data .@"enum" .isIncomplete ()) blk : {
336334 for (ty .data .@"enum" .fields , field_nodes ) | field , field_node | {
@@ -348,7 +346,7 @@ fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: NodeIndex, field_nodes:
348346 .name = enum_val_name ,
349347 .is_public = toplevel ,
350348 .type = enum_const_type_node ,
351- .value = transExpr (c , node_data [@enumToInt (field_node )].decl .node , .used ) catch @panic ("TODO" ),
349+ .value = transExpr (c , node_data [@intFromEnum (field_node )].decl .node , .used ) catch @panic ("TODO" ),
352350 });
353351 if (toplevel )
354352 try addTopLevelDecl (c , enum_val_name , enum_const_def )
@@ -365,14 +363,14 @@ fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: NodeIndex, field_nodes:
365363 else = > | e | return e ,
366364 };
367365 } else blk : {
368- try c .opaque_demotes .put (c .gpa , @ptrToInt (ty .data .@"enum" ), {});
366+ try c .opaque_demotes .put (c .gpa , @intFromPtr (ty .data .@"enum" ), {});
369367 break :blk ZigTag .opaque_literal .init ();
370368 };
371369
372370 const is_pub = toplevel and ! is_unnamed ;
373371 const payload = try c .arena .create (ast .Payload .SimpleVarDecl );
374372 payload .* = .{
375- .base = .{ .tag = ([2 ]ZigTag { .var_simple , .pub_var_simple })[@boolToInt (is_pub )] },
373+ .base = .{ .tag = ([2 ]ZigTag { .var_simple , .pub_var_simple })[@intFromBool (is_pub )] },
376374 .data = .{
377375 .init = enum_type_node ,
378376 .name = name ,
@@ -427,7 +425,7 @@ fn transStmt(c: *Context, node: NodeIndex) TransError!void {
427425
428426fn transExpr (c : * Context , node : NodeIndex , result_used : ResultUsed ) TransError ! ZigNode {
429427 std .debug .assert (node != .none );
430- const ty = c .tree .nodes .items (.ty )[@enumToInt (node )];
428+ const ty = c .tree .nodes .items (.ty )[@intFromEnum (node )];
431429 if (c .tree .value_map .get (node )) | val | {
432430 // TODO handle other values
433431 const str = try std .fmt .allocPrint (c .arena , "{d}" , .{val .data .int });
@@ -439,7 +437,7 @@ fn transExpr(c: *Context, node: NodeIndex, result_used: ResultUsed) TransError!Z
439437 return maybeSuppressResult (c , result_used , as_node );
440438 }
441439 const node_tags = c .tree .nodes .items (.tag );
442- switch (node_tags [@enumToInt (node )]) {
440+ switch (node_tags [@intFromEnum (node )]) {
443441 else = > unreachable , // Not an expression.
444442 }
445443 return .none ;
0 commit comments