basic.carbon 4.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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/impl/no_prelude/basic.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/no_prelude/basic.carbon
  10. interface Simple {
  11. fn F();
  12. }
  13. class C {}
  14. impl C as Simple {
  15. fn F() {}
  16. }
  17. // CHECK:STDOUT: --- basic.carbon
  18. // CHECK:STDOUT:
  19. // CHECK:STDOUT: constants {
  20. // CHECK:STDOUT: %Simple.type: type = facet_type <@Simple> [concrete]
  21. // CHECK:STDOUT: %Self: %Simple.type = bind_symbolic_name Self, 0 [symbolic]
  22. // CHECK:STDOUT: %F.type.e2e: type = fn_type @F.1 [concrete]
  23. // CHECK:STDOUT: %F.df8: %F.type.e2e = struct_value () [concrete]
  24. // CHECK:STDOUT: %Simple.assoc_type: type = assoc_entity_type @Simple [concrete]
  25. // CHECK:STDOUT: %assoc0: %Simple.assoc_type = assoc_entity element0, @Simple.%F.decl [concrete]
  26. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  27. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  28. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  29. // CHECK:STDOUT: %Simple.impl_witness: <witness> = impl_witness file.%Simple.impl_witness_table [concrete]
  30. // CHECK:STDOUT: %F.type.f9e: type = fn_type @F.2 [concrete]
  31. // CHECK:STDOUT: %F.f50: %F.type.f9e = struct_value () [concrete]
  32. // CHECK:STDOUT: %Simple.facet: %Simple.type = facet_value %C, (%Simple.impl_witness) [concrete]
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT:
  35. // CHECK:STDOUT: file {
  36. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  37. // CHECK:STDOUT: .Simple = %Simple.decl
  38. // CHECK:STDOUT: .C = %C.decl
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT: %Simple.decl: type = interface_decl @Simple [concrete = constants.%Simple.type] {} {}
  41. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  42. // CHECK:STDOUT: impl_decl @impl [concrete] {} {
  43. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C]
  44. // CHECK:STDOUT: %Simple.ref: type = name_ref Simple, file.%Simple.decl [concrete = constants.%Simple.type]
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT: %Simple.impl_witness_table = impl_witness_table (@impl.%F.decl), @impl [concrete]
  47. // CHECK:STDOUT: %Simple.impl_witness: <witness> = impl_witness %Simple.impl_witness_table [concrete = constants.%Simple.impl_witness]
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT:
  50. // CHECK:STDOUT: interface @Simple {
  51. // CHECK:STDOUT: %Self: %Simple.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  52. // CHECK:STDOUT: %F.decl: %F.type.e2e = fn_decl @F.1 [concrete = constants.%F.df8] {} {}
  53. // CHECK:STDOUT: %assoc0: %Simple.assoc_type = assoc_entity element0, %F.decl [concrete = constants.%assoc0]
  54. // CHECK:STDOUT:
  55. // CHECK:STDOUT: !members:
  56. // CHECK:STDOUT: .Self = %Self
  57. // CHECK:STDOUT: .F = %assoc0
  58. // CHECK:STDOUT: witness = (%F.decl)
  59. // CHECK:STDOUT: }
  60. // CHECK:STDOUT:
  61. // CHECK:STDOUT: impl @impl: %C.ref as %Simple.ref {
  62. // CHECK:STDOUT: %F.decl: %F.type.f9e = fn_decl @F.2 [concrete = constants.%F.f50] {} {}
  63. // CHECK:STDOUT:
  64. // CHECK:STDOUT: !members:
  65. // CHECK:STDOUT: .F = %F.decl
  66. // CHECK:STDOUT: witness = file.%Simple.impl_witness
  67. // CHECK:STDOUT: }
  68. // CHECK:STDOUT:
  69. // CHECK:STDOUT: class @C {
  70. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
  71. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  72. // CHECK:STDOUT: complete_type_witness = %complete_type
  73. // CHECK:STDOUT:
  74. // CHECK:STDOUT: !members:
  75. // CHECK:STDOUT: .Self = constants.%C
  76. // CHECK:STDOUT: }
  77. // CHECK:STDOUT:
  78. // CHECK:STDOUT: generic fn @F.1(@Simple.%Self: %Simple.type) {
  79. // CHECK:STDOUT: fn();
  80. // CHECK:STDOUT: }
  81. // CHECK:STDOUT:
  82. // CHECK:STDOUT: fn @F.2() {
  83. // CHECK:STDOUT: !entry:
  84. // CHECK:STDOUT: return
  85. // CHECK:STDOUT: }
  86. // CHECK:STDOUT:
  87. // CHECK:STDOUT: specific @F.1(constants.%Self) {}
  88. // CHECK:STDOUT:
  89. // CHECK:STDOUT: specific @F.1(constants.%Simple.facet) {}
  90. // CHECK:STDOUT: