class_obj.carbon 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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/global/class_obj.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/global/class_obj.carbon
  10. class A {}
  11. var a: A = {};
  12. // CHECK:STDOUT: --- class_obj.carbon
  13. // CHECK:STDOUT:
  14. // CHECK:STDOUT: constants {
  15. // CHECK:STDOUT: %A: type = class_type @A [template]
  16. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  17. // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
  18. // CHECK:STDOUT: %.3: type = tuple_type () [template]
  19. // CHECK:STDOUT: %.4: type = ptr_type %.1 [template]
  20. // CHECK:STDOUT: %struct: %A = struct_value () [template]
  21. // CHECK:STDOUT: }
  22. // CHECK:STDOUT:
  23. // CHECK:STDOUT: imports {
  24. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  25. // CHECK:STDOUT: import Core//prelude
  26. // CHECK:STDOUT: import Core//prelude/operators
  27. // CHECK:STDOUT: import Core//prelude/types
  28. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  29. // CHECK:STDOUT: import Core//prelude/operators/as
  30. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  31. // CHECK:STDOUT: import Core//prelude/operators/comparison
  32. // CHECK:STDOUT: import Core//prelude/types/bool
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT:
  36. // CHECK:STDOUT: file {
  37. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  38. // CHECK:STDOUT: .Core = imports.%Core
  39. // CHECK:STDOUT: .A = %A.decl
  40. // CHECK:STDOUT: .a = %a
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT: %Core.import = import Core
  43. // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} {}
  44. // CHECK:STDOUT: %A.ref: type = name_ref A, %A.decl [template = constants.%A]
  45. // CHECK:STDOUT: %a.var: ref %A = var a
  46. // CHECK:STDOUT: %a: ref %A = bind_name a, %a.var
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT:
  49. // CHECK:STDOUT: class @A {
  50. // CHECK:STDOUT: %.loc10: <witness> = complete_type_witness %.1 [template = constants.%.2]
  51. // CHECK:STDOUT:
  52. // CHECK:STDOUT: !members:
  53. // CHECK:STDOUT: .Self = constants.%A
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT:
  56. // CHECK:STDOUT: fn @__global_init() {
  57. // CHECK:STDOUT: !entry:
  58. // CHECK:STDOUT: %.loc12_13.1: %.1 = struct_literal ()
  59. // CHECK:STDOUT: %.loc12_13.2: init %A = class_init (), file.%a.var [template = constants.%struct]
  60. // CHECK:STDOUT: %.loc12_14: init %A = converted %.loc12_13.1, %.loc12_13.2 [template = constants.%struct]
  61. // CHECK:STDOUT: assign file.%a.var, %.loc12_14
  62. // CHECK:STDOUT: return
  63. // CHECK:STDOUT: }
  64. // CHECK:STDOUT: