import.carbon 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/var/no_prelude/import.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/var/no_prelude/import.carbon
  10. // --- implicit.carbon
  11. package Implicit;
  12. var a_ref: () = ();
  13. // --- implicit.impl.carbon
  14. impl package Implicit;
  15. var a: () = a_ref;
  16. // CHECK:STDOUT: --- implicit.carbon
  17. // CHECK:STDOUT:
  18. // CHECK:STDOUT: constants {
  19. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  20. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template]
  21. // CHECK:STDOUT: }
  22. // CHECK:STDOUT:
  23. // CHECK:STDOUT: file {
  24. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  25. // CHECK:STDOUT: .a_ref = %a_ref
  26. // CHECK:STDOUT: }
  27. // CHECK:STDOUT: name_binding_decl {
  28. // CHECK:STDOUT: %a_ref.patt: %empty_tuple.type = binding_pattern a_ref
  29. // CHECK:STDOUT: %.loc4_1: %empty_tuple.type = var_pattern %a_ref.patt
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT: %a_ref.var: ref %empty_tuple.type = var a_ref
  32. // CHECK:STDOUT: %.loc4_13.1: type = splice_block %.loc4_13.3 [template = constants.%empty_tuple.type] {
  33. // CHECK:STDOUT: %.loc4_13.2: %empty_tuple.type = tuple_literal ()
  34. // CHECK:STDOUT: %.loc4_13.3: type = converted %.loc4_13.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  35. // CHECK:STDOUT: }
  36. // CHECK:STDOUT: %a_ref: ref %empty_tuple.type = bind_name a_ref, %a_ref.var
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT:
  39. // CHECK:STDOUT: fn @__global_init() {
  40. // CHECK:STDOUT: !entry:
  41. // CHECK:STDOUT: %.loc4_18.1: %empty_tuple.type = tuple_literal ()
  42. // CHECK:STDOUT: %.loc4_18.2: init %empty_tuple.type = tuple_init () to file.%a_ref.var [template = constants.%empty_tuple]
  43. // CHECK:STDOUT: %.loc4_1: init %empty_tuple.type = converted %.loc4_18.1, %.loc4_18.2 [template = constants.%empty_tuple]
  44. // CHECK:STDOUT: assign file.%a_ref.var, %.loc4_1
  45. // CHECK:STDOUT: return
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT:
  48. // CHECK:STDOUT: --- implicit.impl.carbon
  49. // CHECK:STDOUT:
  50. // CHECK:STDOUT: constants {
  51. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  52. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template]
  53. // CHECK:STDOUT: }
  54. // CHECK:STDOUT:
  55. // CHECK:STDOUT: imports {
  56. // CHECK:STDOUT: %Implicit.a_ref: ref %empty_tuple.type = import_ref Implicit//default, a_ref, loaded
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT:
  59. // CHECK:STDOUT: file {
  60. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  61. // CHECK:STDOUT: .a_ref = imports.%Implicit.a_ref
  62. // CHECK:STDOUT: .a = %a
  63. // CHECK:STDOUT: }
  64. // CHECK:STDOUT: %Implicit.import = import Implicit
  65. // CHECK:STDOUT: %default.import = import <none>
  66. // CHECK:STDOUT: name_binding_decl {
  67. // CHECK:STDOUT: %a.patt: %empty_tuple.type = binding_pattern a
  68. // CHECK:STDOUT: %.loc4_1: %empty_tuple.type = var_pattern %a.patt
  69. // CHECK:STDOUT: }
  70. // CHECK:STDOUT: %a.var: ref %empty_tuple.type = var a
  71. // CHECK:STDOUT: %.loc4_9.1: type = splice_block %.loc4_9.3 [template = constants.%empty_tuple.type] {
  72. // CHECK:STDOUT: %.loc4_9.2: %empty_tuple.type = tuple_literal ()
  73. // CHECK:STDOUT: %.loc4_9.3: type = converted %.loc4_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  74. // CHECK:STDOUT: }
  75. // CHECK:STDOUT: %a: ref %empty_tuple.type = bind_name a, %a.var
  76. // CHECK:STDOUT: }
  77. // CHECK:STDOUT:
  78. // CHECK:STDOUT: fn @__global_init() {
  79. // CHECK:STDOUT: !entry:
  80. // CHECK:STDOUT: %a_ref.ref: ref %empty_tuple.type = name_ref a_ref, imports.%Implicit.a_ref
  81. // CHECK:STDOUT: %.loc4_13: init %empty_tuple.type = tuple_init () to file.%a.var [template = constants.%empty_tuple]
  82. // CHECK:STDOUT: %.loc4_1: init %empty_tuple.type = converted %a_ref.ref, %.loc4_13 [template = constants.%empty_tuple]
  83. // CHECK:STDOUT: assign file.%a.var, %.loc4_1
  84. // CHECK:STDOUT: return
  85. // CHECK:STDOUT: }
  86. // CHECK:STDOUT: