inc.carbon 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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/operators/overloaded/inc.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/operators/overloaded/inc.carbon
  10. // This file was generated from unary_stmt.carbon.tmpl. Run make_tests.sh to regenerate.
  11. package User;
  12. class C {};
  13. impl C as Core.Inc {
  14. fn Op[addr self: C*]();
  15. }
  16. fn TestOp() {
  17. var c: C = {};
  18. ++c;
  19. }
  20. // CHECK:STDOUT: --- inc.carbon
  21. // CHECK:STDOUT:
  22. // CHECK:STDOUT: constants {
  23. // CHECK:STDOUT: %C: type = class_type @C [template]
  24. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  25. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  26. // CHECK:STDOUT: %Inc.type: type = facet_type <@Inc> [template]
  27. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  28. // CHECK:STDOUT: %Op.type.e3a: type = fn_type @Op.1 [template]
  29. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness (@impl.1.%Op.decl) [template]
  30. // CHECK:STDOUT: %ptr.019: type = ptr_type %C [template]
  31. // CHECK:STDOUT: %Op.type.73a: type = fn_type @Op.2 [template]
  32. // CHECK:STDOUT: %Op.0c9: %Op.type.73a = struct_value () [template]
  33. // CHECK:STDOUT: %Inc.facet: %Inc.type = facet_value %C, %impl_witness [template]
  34. // CHECK:STDOUT: %TestOp.type: type = fn_type @TestOp [template]
  35. // CHECK:STDOUT: %TestOp: %TestOp.type = struct_value () [template]
  36. // CHECK:STDOUT: %C.val: %C = struct_value () [template]
  37. // CHECK:STDOUT: %.e6d: type = fn_type_with_self_type %Op.type.e3a, %Inc.facet [template]
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT:
  40. // CHECK:STDOUT: imports {
  41. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  42. // CHECK:STDOUT: .Inc = %Core.Inc
  43. // CHECK:STDOUT: import Core//prelude
  44. // CHECK:STDOUT: import Core//prelude/...
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT: %Core.Inc: type = import_ref Core//prelude/operators/arithmetic, Inc, loaded [template = constants.%Inc.type]
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT:
  49. // CHECK:STDOUT: file {
  50. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  51. // CHECK:STDOUT: .Core = imports.%Core
  52. // CHECK:STDOUT: .C = %C.decl
  53. // CHECK:STDOUT: .TestOp = %TestOp.decl
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT: %Core.import = import Core
  56. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  57. // CHECK:STDOUT: impl_decl @impl.1 [template] {} {
  58. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  59. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, imports.%Core [template = imports.%Core]
  60. // CHECK:STDOUT: %Inc.ref: type = name_ref Inc, imports.%Core.Inc [template = constants.%Inc.type]
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness (@impl.1.%Op.decl) [template = constants.%impl_witness]
  63. // CHECK:STDOUT: %TestOp.decl: %TestOp.type = fn_decl @TestOp [template = constants.%TestOp] {} {}
  64. // CHECK:STDOUT: }
  65. // CHECK:STDOUT:
  66. // CHECK:STDOUT: impl @impl.1: %C.ref as %Inc.ref {
  67. // CHECK:STDOUT: %Op.decl: %Op.type.73a = fn_decl @Op.2 [template = constants.%Op.0c9] {
  68. // CHECK:STDOUT: %self.patt: %ptr.019 = binding_pattern self
  69. // CHECK:STDOUT: %self.param_patt: %ptr.019 = value_param_pattern %self.patt, runtime_param0
  70. // CHECK:STDOUT: %.loc18_9: auto = addr_pattern %self.param_patt
  71. // CHECK:STDOUT: } {
  72. // CHECK:STDOUT: %self.param: %ptr.019 = value_param runtime_param0
  73. // CHECK:STDOUT: %.loc18_21: type = splice_block %ptr [template = constants.%ptr.019] {
  74. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  75. // CHECK:STDOUT: %ptr: type = ptr_type %C [template = constants.%ptr.019]
  76. // CHECK:STDOUT: }
  77. // CHECK:STDOUT: %self: %ptr.019 = bind_name self, %self.param
  78. // CHECK:STDOUT: }
  79. // CHECK:STDOUT:
  80. // CHECK:STDOUT: !members:
  81. // CHECK:STDOUT: .Op = %Op.decl
  82. // CHECK:STDOUT: witness = file.%impl_witness
  83. // CHECK:STDOUT: }
  84. // CHECK:STDOUT:
  85. // CHECK:STDOUT: class @C {
  86. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  87. // CHECK:STDOUT: complete_type_witness = %complete_type
  88. // CHECK:STDOUT:
  89. // CHECK:STDOUT: !members:
  90. // CHECK:STDOUT: .Self = constants.%C
  91. // CHECK:STDOUT: }
  92. // CHECK:STDOUT:
  93. // CHECK:STDOUT: fn @Op.2[addr %self.param_patt: %ptr.019]();
  94. // CHECK:STDOUT:
  95. // CHECK:STDOUT: fn @TestOp() {
  96. // CHECK:STDOUT: !entry:
  97. // CHECK:STDOUT: name_binding_decl {
  98. // CHECK:STDOUT: %c.patt: %C = binding_pattern c
  99. // CHECK:STDOUT: %.loc22_3.1: %C = var_pattern %c.patt
  100. // CHECK:STDOUT: }
  101. // CHECK:STDOUT: %c.var: ref %C = var c
  102. // CHECK:STDOUT: %.loc22_15.1: %empty_struct_type = struct_literal ()
  103. // CHECK:STDOUT: %.loc22_15.2: init %C = class_init (), %c.var [template = constants.%C.val]
  104. // CHECK:STDOUT: %.loc22_3.2: init %C = converted %.loc22_15.1, %.loc22_15.2 [template = constants.%C.val]
  105. // CHECK:STDOUT: assign %c.var, %.loc22_3.2
  106. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  107. // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var
  108. // CHECK:STDOUT: %c.ref: ref %C = name_ref c, %c
  109. // CHECK:STDOUT: %impl.elem0: %.e6d = impl_witness_access constants.%impl_witness, element0 [template = constants.%Op.0c9]
  110. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %c.ref, %impl.elem0
  111. // CHECK:STDOUT: %addr: %ptr.019 = addr_of %c.ref
  112. // CHECK:STDOUT: %Op.call: init %empty_tuple.type = call %bound_method(%addr)
  113. // CHECK:STDOUT: return
  114. // CHECK:STDOUT: }
  115. // CHECK:STDOUT: