simple_init.carbon 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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/simple_init.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/global/simple_init.carbon
  10. var a: i32 = 0;
  11. // CHECK:STDOUT: --- simple_init.carbon
  12. // CHECK:STDOUT:
  13. // CHECK:STDOUT: constants {
  14. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  15. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  16. // CHECK:STDOUT: %int_0.1: Core.IntLiteral = int_value 0 [template]
  17. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  18. // CHECK:STDOUT: %Convert.type.10: type = fn_type @Convert.2, @impl.1(%int_32) [template]
  19. // CHECK:STDOUT: %Convert.10: %Convert.type.10 = struct_value () [template]
  20. // CHECK:STDOUT: %interface.5: <witness> = interface_witness (%Convert.10) [template]
  21. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_0.1, %Convert.10 [template]
  22. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.2(%int_32) [template]
  23. // CHECK:STDOUT: %int_0.2: %i32 = int_value 0 [template]
  24. // CHECK:STDOUT: }
  25. // CHECK:STDOUT:
  26. // CHECK:STDOUT: imports {
  27. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  28. // CHECK:STDOUT: .Int = %import_ref.1
  29. // CHECK:STDOUT: .ImplicitAs = %import_ref.5
  30. // CHECK:STDOUT: import Core//prelude
  31. // CHECK:STDOUT: import Core//prelude/...
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT:
  35. // CHECK:STDOUT: file {
  36. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  37. // CHECK:STDOUT: .Core = imports.%Core
  38. // CHECK:STDOUT: .a = %a
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT: %Core.import = import Core
  41. // CHECK:STDOUT: %a.var: ref %i32 = var a
  42. // CHECK:STDOUT: %a: ref %i32 = bind_name a, %a.var
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT:
  45. // CHECK:STDOUT: fn @__global_init() {
  46. // CHECK:STDOUT: !entry:
  47. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0.1]
  48. // CHECK:STDOUT: %impl.elem0: %Convert.type.2 = interface_witness_access constants.%interface.5, element0 [template = constants.%Convert.10]
  49. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_0, %impl.elem0 [template = constants.%Convert.bound]
  50. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn]
  51. // CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_0) [template = constants.%int_0.2]
  52. // CHECK:STDOUT: %.loc10: init %i32 = converted %int_0, %int.convert_checked [template = constants.%int_0.2]
  53. // CHECK:STDOUT: assign file.%a.var, %.loc10
  54. // CHECK:STDOUT: return
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT: