mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 07:24:42 +01:00
Improve namespace handling in imports. (#4153)
This implements a few closely related features: - Starts merging namespaces discovered inside imports. - Stores results of cross-package name lookup as an entry inside the scope. - Note this is particularly visible with `i32`. - Moves more of the imported instructions to the import scope. Note this is primarily for executing the namespace TODO in check.cpp, which is removed here. `testdata/namespace/merging_with_indirections.carbon` tests key behavior. --------- Co-authored-by: Richard Smith <richard@metafoo.co.uk>
This commit is contained in:
co-authored by
Richard Smith
parent
55f3f48707
commit
7ded56ef35
@@ -30,15 +30,8 @@ var p: Incomplete* = &a[0];
|
||||
// CHECK:STDOUT: %.4: i32 = int_literal 0 [template]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
||||
// CHECK:STDOUT: .Core = %Core
|
||||
// CHECK:STDOUT: .Incomplete = %Incomplete.decl
|
||||
// CHECK:STDOUT: .a = %a
|
||||
// CHECK:STDOUT: .p = %p
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Core.import = import Core
|
||||
// CHECK:STDOUT: %Core: <namespace> = namespace %Core.import, [template] {
|
||||
// CHECK:STDOUT: imports {
|
||||
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
|
||||
// CHECK:STDOUT: import Core//prelude
|
||||
// CHECK:STDOUT: import Core//prelude/operators
|
||||
// CHECK:STDOUT: import Core//prelude/types
|
||||
@@ -47,6 +40,16 @@ var p: Incomplete* = &a[0];
|
||||
// CHECK:STDOUT: import Core//prelude/operators/comparison
|
||||
// CHECK:STDOUT: import Core//prelude/types/bool
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
||||
// CHECK:STDOUT: .Core = imports.%Core
|
||||
// CHECK:STDOUT: .Incomplete = %Incomplete.decl
|
||||
// CHECK:STDOUT: .a = %a
|
||||
// CHECK:STDOUT: .p = %p
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Core.import = import Core
|
||||
// CHECK:STDOUT: %Incomplete.decl: type = class_decl @Incomplete [template = constants.%Incomplete] {}
|
||||
// CHECK:STDOUT: %Incomplete.ref.loc19: type = name_ref Incomplete, %Incomplete.decl [template = constants.%Incomplete]
|
||||
// CHECK:STDOUT: %.loc19_21: i32 = int_literal 1 [template = constants.%.1]
|
||||
|
||||
Reference in New Issue
Block a user