| ... | ... | @@ -192,8 +192,8 @@ fn prepopulateGlobalNameTable(c: *Context) !void { |
| 192 | 192 | const node_types = c.tree.nodes.items(.ty); |
| 193 | 193 | const node_data = c.tree.nodes.items(.data); |
| 194 | 194 | 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)]) { |
| 197 | 197 | .typedef => @panic("TODO"), |
| 198 | 198 | |
| 199 | 199 | .static_assert, |
| ... | ... | @@ -202,7 +202,7 @@ fn prepopulateGlobalNameTable(c: *Context) !void { |
| 202 | 202 | .struct_decl, |
| 203 | 203 | .union_decl, |
| 204 | 204 | => blk: { |
| 205 | | const ty = node_types[@enumToInt(node)]; |
| 205 | const ty = node_types[@intFromEnum(node)]; |
| 206 | 206 | const name_id = ty.data.record.name; |
| 207 | 207 | break :blk c.mapper.lookup(name_id); |
| 208 | 208 | }, |
| ... | ... | @@ -210,7 +210,7 @@ fn prepopulateGlobalNameTable(c: *Context) !void { |
| 210 | 210 | .enum_decl_two, |
| 211 | 211 | .enum_decl, |
| 212 | 212 | => blk: { |
| 213 | | const ty = node_types[@enumToInt(node)]; |
| 213 | const ty = node_types[@intFromEnum(node)]; |
| 214 | 214 | const name_id = ty.data.@"enum".name; |
| 215 | 215 | break :blk c.mapper.lookup(name_id); |
| 216 | 216 | }, |
| ... | ... | @@ -240,8 +240,8 @@ fn transTopLevelDecls(c: *Context) !void { |
| 240 | 240 | const node_tags = c.tree.nodes.items(.tag); |
| 241 | 241 | const node_data = c.tree.nodes.items(.data); |
| 242 | 242 | 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)]) { |
| 245 | 245 | .typedef => { |
| 246 | 246 | try transTypeDef(c, &c.global_scope.base, node); |
| 247 | 247 | }, |
| ... | ... | @@ -255,16 +255,14 @@ fn transTopLevelDecls(c: *Context) !void { |
| 255 | 255 | try transRecordDecl(c, &c.global_scope.base, node); |
| 256 | 256 | }, |
| 257 | 257 | |
| 258 | | .enum_decl_two, |
| 259 | | => { |
| 258 | .enum_decl_two => { |
| 260 | 259 | var fields = [2]NodeIndex{ data.bin.lhs, data.bin.rhs }; |
| 261 | 260 | var field_count: u8 = 0; |
| 262 | 261 | if (fields[0] != .none) field_count += 1; |
| 263 | 262 | if (fields[1] != .none) field_count += 1; |
| 264 | 263 | try transEnumDecl(c, &c.global_scope.base, node, fields[0..field_count]); |
| 265 | 264 | }, |
| 266 | | .enum_decl, |
| 267 | | => { |
| 265 | .enum_decl => { |
| 268 | 266 | const fields = c.tree.data[data.range.start..data.range.end]; |
| 269 | 267 | try transEnumDecl(c, &c.global_scope.base, node, fields); |
| 270 | 268 | }, |
| ... | ... | @@ -309,9 +307,9 @@ fn transVarDecl(_: *Context, _: NodeIndex, _: ?usize) Error!void { |
| 309 | 307 | } |
| 310 | 308 | fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: NodeIndex, field_nodes: []const NodeIndex) Error!void { |
| 311 | 309 | const node_types = c.tree.nodes.items(.ty); |
| 312 | | const ty = node_types[@enumToInt(enum_decl)]; |
| 310 | const ty = node_types[@intFromEnum(enum_decl)]; |
| 313 | 311 | 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"))) |_| |
| 315 | 313 | return; // Avoid processing this decl twice |
| 316 | 314 | const toplevel = scope.id == .root; |
| 317 | 315 | const bs: *Scope.Block = if (!toplevel) try scope.findBlockScope(c) else undefined; |
| ... | ... | @@ -319,7 +317,7 @@ fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: NodeIndex, field_nodes: |
| 319 | 317 | var is_unnamed = false; |
| 320 | 318 | var bare_name: []const u8 = c.mapper.lookup(ty.data.@"enum".name); |
| 321 | 319 | 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| { |
| 323 | 321 | bare_name = typedef_name; |
| 324 | 322 | name = typedef_name; |
| 325 | 323 | } else { |
| ... | ... | @@ -330,7 +328,7 @@ fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: NodeIndex, field_nodes: |
| 330 | 328 | name = try std.fmt.allocPrint(c.arena, "enum_{s}", .{bare_name}); |
| 331 | 329 | } |
| 332 | 330 | 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); |
| 334 | 332 | |
| 335 | 333 | const enum_type_node = if (!ty.data.@"enum".isIncomplete()) blk: { |
| 336 | 334 | 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: |
| 348 | 346 | .name = enum_val_name, |
| 349 | 347 | .is_public = toplevel, |
| 350 | 348 | .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"), |
| 352 | 350 | }); |
| 353 | 351 | if (toplevel) |
| 354 | 352 | try addTopLevelDecl(c, enum_val_name, enum_const_def) |
| ... | ... | @@ -365,14 +363,14 @@ fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: NodeIndex, field_nodes: |
| 365 | 363 | else => |e| return e, |
| 366 | 364 | }; |
| 367 | 365 | } 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"), {}); |
| 369 | 367 | break :blk ZigTag.opaque_literal.init(); |
| 370 | 368 | }; |
| 371 | 369 | |
| 372 | 370 | const is_pub = toplevel and !is_unnamed; |
| 373 | 371 | const payload = try c.arena.create(ast.Payload.SimpleVarDecl); |
| 374 | 372 | 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)] }, |
| 376 | 374 | .data = .{ |
| 377 | 375 | .init = enum_type_node, |
| 378 | 376 | .name = name, |
| ... | ... | @@ -427,7 +425,7 @@ fn transStmt(c: *Context, node: NodeIndex) TransError!void { |
| 427 | 425 | |
| 428 | 426 | fn transExpr(c: *Context, node: NodeIndex, result_used: ResultUsed) TransError!ZigNode { |
| 429 | 427 | 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)]; |
| 431 | 429 | if (c.tree.value_map.get(node)) |val| { |
| 432 | 430 | // TODO handle other values |
| 433 | 431 | 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 |
| 439 | 437 | return maybeSuppressResult(c, result_used, as_node); |
| 440 | 438 | } |
| 441 | 439 | const node_tags = c.tree.nodes.items(.tag); |
| 442 | | switch (node_tags[@enumToInt(node)]) { |
| 440 | switch (node_tags[@intFromEnum(node)]) { |
| 443 | 441 | else => unreachable, // Not an expression. |
| 444 | 442 | } |
| 445 | 443 | return .none; |