Commit 731c35f15a
Changed files (6)
src/Compilation.zig
@@ -3563,7 +3563,6 @@ fn buildOutputFromZig(
.handle = special_dir,
},
.root_src_path = src_basename,
- .namespace_hash = Package.root_namespace_hash,
};
const root_name = src_basename[0 .. src_basename.len - std.fs.path.extension(src_basename).len];
const target = comp.getTarget();
src/main.zig
@@ -630,7 +630,6 @@ fn buildOutputType(
var pkg_tree_root: Package = .{
.root_src_directory = .{ .path = null, .handle = fs.cwd() },
.root_src_path = &[0]u8{},
- .namespace_hash = Package.root_namespace_hash,
};
defer freePkgTree(gpa, &pkg_tree_root, false);
var cur_pkg: *Package = &pkg_tree_root;
@@ -1768,7 +1767,6 @@ fn buildOutputType(
if (root_pkg) |pkg| {
pkg.table = pkg_tree_root.table;
pkg_tree_root.table = .{};
- pkg.namespace_hash = pkg_tree_root.namespace_hash;
}
const self_exe_path = try fs.selfExePathAlloc(arena);
@@ -2657,7 +2655,6 @@ pub fn cmdBuild(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v
.handle = try zig_lib_directory.handle.openDir(std_special, .{}),
},
.root_src_path = "build_runner.zig",
- .namespace_hash = Package.root_namespace_hash,
};
defer root_pkg.root_src_directory.handle.close();
@@ -2703,7 +2700,6 @@ pub fn cmdBuild(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v
var build_pkg: Package = .{
.root_src_directory = build_directory,
.root_src_path = build_zig_basename,
- .namespace_hash = undefined,
};
try root_pkg.addAndAdopt(arena, "@build", &build_pkg);
src/Module.zig
@@ -798,8 +798,6 @@ pub const Var = struct {
pub const Scope = struct {
tag: Tag,
- pub const NameHash = [16]u8;
-
pub fn cast(base: *Scope, comptime T: type) ?*T {
if (base.tag != T.base_tag)
return null;
@@ -839,7 +837,6 @@ pub const Scope = struct {
.namespace => return @fieldParentPtr(Namespace, "base", base).file_scope.sub_file_path,
.file => return @fieldParentPtr(File, "base", base).sub_file_path,
.block => unreachable,
- .decl_ref => unreachable,
}
}
@@ -861,10 +858,6 @@ pub const Scope = struct {
/// Namespace owned by structs, enums, unions, and opaques for decls.
namespace,
block,
- /// Used for simple error reporting. Only contains a reference to a
- /// `Decl` for use with `srcDecl` and `ownerDecl`.
- /// Has no parents or children.
- decl_ref,
};
/// The container that structs, enums, unions, and opaques have.
src/Package.zig
@@ -11,22 +11,15 @@ const Module = @import("Module.zig");
pub const Table = std.StringHashMapUnmanaged(*Package);
-pub const root_namespace_hash: Module.Scope.NameHash = .{
- 0, 0, 6, 6, 6, 0, 0, 0,
- 6, 9, 0, 0, 0, 4, 2, 0,
-};
-
root_src_directory: Compilation.Directory,
/// Relative to `root_src_directory`. May contain path separators.
root_src_path: []const u8,
table: Table = .{},
parent: ?*Package = null,
-namespace_hash: Module.Scope.NameHash,
/// Whether to free `root_src_directory` on `destroy`.
root_src_directory_owned: bool = false,
/// Allocate a Package. No references to the slices passed are kept.
-/// Don't forget to set `namespace_hash` later.
pub fn create(
gpa: *Allocator,
/// Null indicates the current working directory
@@ -50,7 +43,6 @@ pub fn create(
},
.root_src_path = owned_src_path,
.root_src_directory_owned = true,
- .namespace_hash = undefined,
};
return ptr;
@@ -82,14 +74,12 @@ pub fn createWithDir(
},
.root_src_directory_owned = true,
.root_src_path = owned_src_path,
- .namespace_hash = undefined,
};
} else {
ptr.* = .{
.root_src_directory = directory,
.root_src_directory_owned = false,
.root_src_path = owned_src_path,
- .namespace_hash = undefined,
};
}
return ptr;
@@ -129,6 +119,5 @@ pub fn add(pkg: *Package, gpa: *Allocator, name: []const u8, package: *Package)
pub fn addAndAdopt(parent: *Package, gpa: *Allocator, name: []const u8, child: *Package) !void {
assert(child.parent == null); // make up your mind, who is the parent??
child.parent = parent;
- child.namespace_hash = std.zig.hashName(parent.namespace_hash, ":", name);
return parent.add(gpa, name, child);
}
src/test.zig
@@ -611,7 +611,6 @@ pub const TestContext = struct {
var root_pkg: Package = .{
.root_src_directory = .{ .path = tmp_dir_path, .handle = tmp.dir },
.root_src_path = tmp_src_path,
- .namespace_hash = Package.root_namespace_hash,
};
defer root_pkg.table.deinit(allocator);
BRANCH_TODO
@@ -3,21 +3,6 @@
their indexes starting at 0 so that we can use an array to store Sema
results rather than a map.
- * get rid of NameHash
- * handle decl collision with usingnamespace
- * the decl doing the looking up needs to create a decl dependency
- on each usingnamespace decl
- * handle usingnamespace cycles
-
- * compile error for return inside defer expression
-
- * when block has noreturn statement
- - avoid emitting defers
- - compile error for unreachable code
-
- * detect `return error.Foo` and emit ZIR that unconditionally generates errdefers
- * `return`: check return operand and generate errdefers if necessary
-
* have failed_trees and just put the file in there
- this way we can emit all the parse errors not just the first one
- but maybe we want just the first one?
@@ -58,13 +43,3 @@
* repl: if you try `run` with -ofmt=c you get an access denied error because it
tries to execute the .c file as a child process instead of executing `zig run`
on it.
-
-=== file issues: ===
-
- * C backend: honor the exported symbol name. Right now if you do `pub fn main`
- it generates bogus C code because the `@export` name is not honored, and it allows
- the `main` which should be not exported, to clobber the exported symbol name.
-
- * get the test runner and `zig test` working
- - get behavior tests passing for stage2
-