authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-05-17 15:29:59-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-05-17 16:09:20-07:00
log3d99fb3352eca9da68b6033ad22a166ed68ed36a
tree3d9a3be8f28f178ea43416d611c1604c0f8cfdb9
parentd5e894a9a7c63ebbfaa3c4eb6d173e15745ad39c

stage2: get rid of DeclRef


2 files changed, 0 insertions(+), 17 deletions(-)

BRANCH_TODO-1
...@@ -3,7 +3,6 @@...@@ -3,7 +3,6 @@
3 their indexes starting at 0 so that we can use an array to store Sema3 their indexes starting at 0 so that we can use an array to store Sema
4 results rather than a map.4 results rather than a map.
55
6 * get rid of Scope.DeclRef
7 * get rid of NameHash6 * get rid of NameHash
8 * handle decl collision with usingnamespace7 * handle decl collision with usingnamespace
9 * the decl doing the looking up needs to create a decl dependency8 * the decl doing the looking up needs to create a decl dependency
src/Module.zig-16
...@@ -812,7 +812,6 @@ pub const Scope = struct {...@@ -812,7 +812,6 @@ pub const Scope = struct {
812 .block => scope.cast(Block).?.sema.owner_decl,812 .block => scope.cast(Block).?.sema.owner_decl,
813 .file => null,813 .file => null,
814 .namespace => null,814 .namespace => null,
815 .decl_ref => scope.cast(DeclRef).?.decl,
816 };815 };
817 }816 }
818817
...@@ -821,7 +820,6 @@ pub const Scope = struct {...@@ -821,7 +820,6 @@ pub const Scope = struct {
821 .block => scope.cast(Block).?.src_decl,820 .block => scope.cast(Block).?.src_decl,
822 .file => null,821 .file => null,
823 .namespace => scope.cast(Namespace).?.getDecl(),822 .namespace => scope.cast(Namespace).?.getDecl(),
824 .decl_ref => scope.cast(DeclRef).?.decl,
825 };823 };
826 }824 }
827825
...@@ -831,7 +829,6 @@ pub const Scope = struct {...@@ -831,7 +829,6 @@ pub const Scope = struct {
831 .block => return scope.cast(Block).?.sema.owner_decl.namespace,829 .block => return scope.cast(Block).?.sema.owner_decl.namespace,
832 .file => return scope.cast(File).?.root_decl.?.namespace,830 .file => return scope.cast(File).?.root_decl.?.namespace,
833 .namespace => return scope.cast(Namespace).?,831 .namespace => return scope.cast(Namespace).?,
834 .decl_ref => return scope.cast(DeclRef).?.decl.namespace,
835 }832 }
836 }833 }
837834
...@@ -854,7 +851,6 @@ pub const Scope = struct {...@@ -854,7 +851,6 @@ pub const Scope = struct {
854 .namespace => return @fieldParentPtr(Namespace, "base", cur).file_scope,851 .namespace => return @fieldParentPtr(Namespace, "base", cur).file_scope,
855 .file => return @fieldParentPtr(File, "base", cur),852 .file => return @fieldParentPtr(File, "base", cur),
856 .block => return @fieldParentPtr(Block, "base", cur).src_decl.namespace.file_scope,853 .block => return @fieldParentPtr(Block, "base", cur).src_decl.namespace.file_scope,
857 .decl_ref => return @fieldParentPtr(DeclRef, "base", cur).decl.namespace.file_scope,
858 };854 };
859 }855 }
860 }856 }
...@@ -1403,12 +1399,6 @@ pub const Scope = struct {...@@ -1403,12 +1399,6 @@ pub const Scope = struct {
1403 return &inst.base;1399 return &inst.base;
1404 }1400 }
1405 };1401 };
1406
1407 pub const DeclRef = struct {
1408 pub const base_tag: Tag = .decl_ref;
1409 base: Scope = Scope{ .tag = base_tag },
1410 decl: *Decl,
1411 };
1412};1402};
14131403
1414/// This struct holds data necessary to construct API-facing `AllErrors.Message`.1404/// This struct holds data necessary to construct API-facing `AllErrors.Message`.
...@@ -4012,12 +4002,6 @@ pub fn failWithOwnedErrorMsg(mod: *Module, scope: *Scope, err_msg: *ErrorMsg) In...@@ -4012,12 +4002,6 @@ pub fn failWithOwnedErrorMsg(mod: *Module, scope: *Scope, err_msg: *ErrorMsg) In
4012 },4002 },
4013 .file => unreachable,4003 .file => unreachable,
4014 .namespace => unreachable,4004 .namespace => unreachable,
4015 .decl_ref => {
4016 const decl_ref = scope.cast(Scope.DeclRef).?;
4017 decl_ref.decl.analysis = .sema_failure;
4018 decl_ref.decl.generation = mod.generation;
4019 mod.failed_decls.putAssumeCapacityNoClobber(decl_ref.decl, err_msg);
4020 },
4021 }4005 }
4022 return error.AnalysisFail;4006 return error.AnalysisFail;
4023}4007}