class_obj.carbon 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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: %empty_struct_type: type = struct_type {} [template]
  17. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  18. // CHECK:STDOUT: %A.val: %A = struct_value () [template]
  19. // CHECK:STDOUT: }
  20. // CHECK:STDOUT:
  21. // CHECK:STDOUT: imports {
  22. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  23. // CHECK:STDOUT: import Core//prelude
  24. // CHECK:STDOUT: import Core//prelude/...
  25. // CHECK:STDOUT: }
  26. // CHECK:STDOUT: }
  27. // CHECK:STDOUT:
  28. // CHECK:STDOUT: file {
  29. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  30. // CHECK:STDOUT: .Core = imports.%Core
  31. // CHECK:STDOUT: .A = %A.decl
  32. // CHECK:STDOUT: .a = %a
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT: %Core.import = import Core
  35. // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} {}
  36. // CHECK:STDOUT: name_binding_decl {
  37. // CHECK:STDOUT: %a.patt: %A = binding_pattern a
  38. // CHECK:STDOUT: %.loc12: %A = var_pattern %a.patt
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT: %a.var: ref %A = var a
  41. // CHECK:STDOUT: %A.ref: type = name_ref A, %A.decl [template = constants.%A]
  42. // CHECK:STDOUT: %a: ref %A = bind_name a, %a.var
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT:
  45. // CHECK:STDOUT: class @A {
  46. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  47. // CHECK:STDOUT: complete_type_witness = %complete_type
  48. // CHECK:STDOUT:
  49. // CHECK:STDOUT: !members:
  50. // CHECK:STDOUT: .Self = constants.%A
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: fn @__global_init() {
  54. // CHECK:STDOUT: !entry:
  55. // CHECK:STDOUT: %.loc12_13.1: %empty_struct_type = struct_literal ()
  56. // CHECK:STDOUT: %.loc12_13.2: init %A = class_init (), file.%a.var [template = constants.%A.val]
  57. // CHECK:STDOUT: %.loc12_1: init %A = converted %.loc12_13.1, %.loc12_13.2 [template = constants.%A.val]
  58. // CHECK:STDOUT: assign file.%a.var, %.loc12_1
  59. // CHECK:STDOUT: return
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT: