aboutsummaryrefslogtreecommitdiff
path: root/src/translate_c
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-10-31 20:29:55 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-12-06 12:15:04 -0700
commit28514476ef8c824c3d189d98f23d0f8d23e496ea (patch)
tree537631080e7c99fb582738d3be96ac48c5941bb7 /src/translate_c
parentbf316e550671cc71eb498b3cf799493627bb0fdc (diff)
downloadzig-28514476ef8c824c3d189d98f23d0f8d23e496ea.tar.gz
zig-28514476ef8c824c3d189d98f23d0f8d23e496ea.zip
remove `-fstage1` option
After this commit, the self-hosted compiler does not offer the option to use stage1 as a backend anymore.
Diffstat (limited to 'src/translate_c')
-rw-r--r--src/translate_c/ast.zig48
1 files changed, 17 insertions, 31 deletions
diff --git a/src/translate_c/ast.zig b/src/translate_c/ast.zig
index bc0f002c21..00f5481b98 100644
--- a/src/translate_c/ast.zig
+++ b/src/translate_c/ast.zig
@@ -732,11 +732,10 @@ pub const Payload = struct {
/// Converts the nodes into a Zig Ast.
/// Caller must free the source slice.
-pub fn render(gpa: Allocator, zig_is_stage1: bool, nodes: []const Node) !std.zig.Ast {
+pub fn render(gpa: Allocator, nodes: []const Node) !std.zig.Ast {
var ctx = Context{
.gpa = gpa,
.buf = std.ArrayList(u8).init(gpa),
- .zig_is_stage1 = zig_is_stage1,
};
defer ctx.buf.deinit();
defer ctx.nodes.deinit(gpa);
@@ -805,11 +804,6 @@ const Context = struct {
extra_data: std.ArrayListUnmanaged(std.zig.Ast.Node.Index) = .{},
tokens: std.zig.Ast.TokenList = .{},
- /// This is used to emit different code depending on whether
- /// the output zig source code is intended to be compiled with stage1 or stage2.
- /// Refer to the Context in translate_c.zig.
- zig_is_stage1: bool,
-
fn addTokenFmt(c: *Context, tag: TokenTag, comptime format: []const u8, args: anytype) Allocator.Error!TokenIndex {
const start_index = c.buf.items.len;
try c.buf.writer().print(format ++ " ", args);
@@ -932,7 +926,7 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {
.call => {
const payload = node.castTag(.call).?.data;
// Cosmetic: avoids an unnecesary address_of on most function calls.
- const lhs = if (!c.zig_is_stage1 and payload.lhs.tag() == .fn_identifier)
+ const lhs = if (payload.lhs.tag() == .fn_identifier)
try c.addNode(.{
.tag = .identifier,
.main_token = try c.addIdentifier(payload.lhs.castTag(.fn_identifier).?.data),
@@ -1097,28 +1091,20 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {
// value (implicit in stage1, explicit in stage2), except in
// the context of an address_of, which is handled there.
const payload = node.castTag(.fn_identifier).?.data;
- if (c.zig_is_stage1) {
- return try c.addNode(.{
- .tag = .identifier,
- .main_token = try c.addIdentifier(payload),
- .data = undefined,
- });
- } else {
- const tok = try c.addToken(.ampersand, "&");
- const arg = try c.addNode(.{
- .tag = .identifier,
- .main_token = try c.addIdentifier(payload),
- .data = undefined,
- });
- return c.addNode(.{
- .tag = .address_of,
- .main_token = tok,
- .data = .{
- .lhs = arg,
- .rhs = undefined,
- },
- });
- }
+ const tok = try c.addToken(.ampersand, "&");
+ const arg = try c.addNode(.{
+ .tag = .identifier,
+ .main_token = try c.addIdentifier(payload),
+ .data = undefined,
+ });
+ return c.addNode(.{
+ .tag = .address_of,
+ .main_token = tok,
+ .data = .{
+ .lhs = arg,
+ .rhs = undefined,
+ },
+ });
},
.float_literal => {
const payload = node.castTag(.float_literal).?.data;
@@ -1448,7 +1434,7 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {
.optional_type => return renderPrefixOp(c, node, .optional_type, .question_mark, "?"),
.address_of => {
const payload = node.castTag(.address_of).?.data;
- if (c.zig_is_stage1 and payload.tag() == .fn_identifier)
+ if (payload.tag() == .fn_identifier)
return try c.addNode(.{
.tag = .identifier,
.main_token = try c.addIdentifier(payload.castTag(.fn_identifier).?.data),