class_obj.carbon 2.9 KB

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