aboutsummaryrefslogtreecommitdiff
path: root/src-self-hosted/decl.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2020-05-17 13:53:27 -0400
committerGitHub <noreply@github.com>2020-05-17 13:53:27 -0400
commit16f100b82e4075a047f008c0de6c44fc418eb58e (patch)
tree93555fbcba29bcd1120349a03ae6904321cb7718 /src-self-hosted/decl.zig
parent9a22c8b6ca98fd01795f8cd4f3e9d92311175f13 (diff)
parentb0968abccbfb4072528c3b5e039bc03b27af89a1 (diff)
downloadzig-16f100b82e4075a047f008c0de6c44fc418eb58e.tar.gz
zig-16f100b82e4075a047f008c0de6c44fc418eb58e.zip
Merge pull request #5307 from ziglang/self-hosted-incremental-compilation
rework self-hosted compiler for incremental builds
Diffstat (limited to 'src-self-hosted/decl.zig')
-rw-r--r--src-self-hosted/decl.zig102
1 files changed, 0 insertions, 102 deletions
diff --git a/src-self-hosted/decl.zig b/src-self-hosted/decl.zig
deleted file mode 100644
index e68a1458d6..0000000000
--- a/src-self-hosted/decl.zig
+++ /dev/null
@@ -1,102 +0,0 @@
-const std = @import("std");
-const Allocator = mem.Allocator;
-const mem = std.mem;
-const ast = std.zig.ast;
-const Visib = @import("visib.zig").Visib;
-const event = std.event;
-const Value = @import("value.zig").Value;
-const Token = std.zig.Token;
-const errmsg = @import("errmsg.zig");
-const Scope = @import("scope.zig").Scope;
-const Compilation = @import("compilation.zig").Compilation;
-
-pub const Decl = struct {
- id: Id,
- name: []const u8,
- visib: Visib,
- resolution: event.Future(Compilation.BuildError!void),
- parent_scope: *Scope,
-
- // TODO when we destroy the decl, deref the tree scope
- tree_scope: *Scope.AstTree,
-
- pub const Table = std.StringHashMap(*Decl);
-
- pub fn cast(base: *Decl, comptime T: type) ?*T {
- if (base.id != @field(Id, @typeName(T))) return null;
- return @fieldParentPtr(T, "base", base);
- }
-
- pub fn isExported(base: *const Decl, tree: *ast.Tree) bool {
- switch (base.id) {
- .Fn => {
- const fn_decl = @fieldParentPtr(Fn, "base", base);
- return fn_decl.isExported(tree);
- },
- else => return false,
- }
- }
-
- pub fn getSpan(base: *const Decl) errmsg.Span {
- switch (base.id) {
- .Fn => {
- const fn_decl = @fieldParentPtr(Fn, "base", base);
- const fn_proto = fn_decl.fn_proto;
- const start = fn_proto.fn_token;
- const end = fn_proto.name_token orelse start;
- return errmsg.Span{
- .first = start,
- .last = end + 1,
- };
- },
- else => @panic("TODO"),
- }
- }
-
- pub fn findRootScope(base: *const Decl) *Scope.Root {
- return base.parent_scope.findRoot();
- }
-
- pub const Id = enum {
- Var,
- Fn,
- CompTime,
- };
-
- pub const Var = struct {
- base: Decl,
- };
-
- pub const Fn = struct {
- base: Decl,
- value: union(enum) {
- Unresolved,
- Fn: *Value.Fn,
- FnProto: *Value.FnProto,
- },
- fn_proto: *ast.Node.FnProto,
-
- pub fn externLibName(self: Fn, tree: *ast.Tree) ?[]const u8 {
- return if (self.fn_proto.extern_export_inline_token) |tok_index| x: {
- const token = tree.tokens.at(tok_index);
- break :x switch (token.id) {
- .Extern => tree.tokenSlicePtr(token),
- else => null,
- };
- } else null;
- }
-
- pub fn isExported(self: Fn, tree: *ast.Tree) bool {
- if (self.fn_proto.extern_export_inline_token) |tok_index| {
- const token = tree.tokens.at(tok_index);
- return token.id == .Keyword_export;
- } else {
- return false;
- }
- }
- };
-
- pub const CompTime = struct {
- base: Decl,
- };
-};