char.carbon 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/full.carbon
  6. //
  7. // AUTOUPDATE
  8. // TIP: To test this file alone, run:
  9. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/builtins/read/char.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/builtins/read/char.carbon
  12. // --- char.carbon
  13. import Core library "io";
  14. fn ReadChar() -> i32 = "read.char";
  15. fn Main() {
  16. //@dump-sem-ir-begin
  17. let n: i32 = ReadChar();
  18. let m: i32 = Core.ReadChar();
  19. //@dump-sem-ir-end
  20. }
  21. // CHECK:STDOUT: --- char.carbon
  22. // CHECK:STDOUT:
  23. // CHECK:STDOUT: constants {
  24. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  25. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  26. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  27. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  28. // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
  29. // CHECK:STDOUT: %ReadChar.type.c36: type = fn_type @ReadChar.loc4 [concrete]
  30. // CHECK:STDOUT: %ReadChar.6ad: %ReadChar.type.c36 = struct_value () [concrete]
  31. // CHECK:STDOUT: %ReadChar.type.9f3: type = fn_type @ReadChar.1 [concrete]
  32. // CHECK:STDOUT: %ReadChar.01f: %ReadChar.type.9f3 = struct_value () [concrete]
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT:
  35. // CHECK:STDOUT: imports {
  36. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  37. // CHECK:STDOUT: .Int = %Core.Int
  38. // CHECK:STDOUT: .ReadChar = %Core.ReadChar
  39. // CHECK:STDOUT: import Core//prelude
  40. // CHECK:STDOUT: import Core//io
  41. // CHECK:STDOUT: import Core//prelude/...
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/types/int, Int, loaded [concrete = constants.%Int.generic]
  44. // CHECK:STDOUT: %Core.ReadChar: %ReadChar.type.9f3 = import_ref Core//io, ReadChar, loaded [concrete = constants.%ReadChar.01f]
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT:
  47. // CHECK:STDOUT: fn @Main() {
  48. // CHECK:STDOUT: !entry:
  49. // CHECK:STDOUT: name_binding_decl {
  50. // CHECK:STDOUT: %n.patt: %pattern_type.7ce = value_binding_pattern n [concrete]
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT: %ReadChar.ref.loc8: %ReadChar.type.c36 = name_ref ReadChar, file.%ReadChar.decl [concrete = constants.%ReadChar.6ad]
  53. // CHECK:STDOUT: %ReadChar.call.loc8: init %i32 = call %ReadChar.ref.loc8()
  54. // CHECK:STDOUT: %.loc8_10: type = splice_block %i32.loc8 [concrete = constants.%i32] {
  55. // CHECK:STDOUT: %int_32.loc8: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  56. // CHECK:STDOUT: %i32.loc8: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT: %.loc8_25.1: %i32 = value_of_initializer %ReadChar.call.loc8
  59. // CHECK:STDOUT: %.loc8_25.2: %i32 = converted %ReadChar.call.loc8, %.loc8_25.1
  60. // CHECK:STDOUT: %n: %i32 = value_binding n, %.loc8_25.2
  61. // CHECK:STDOUT: name_binding_decl {
  62. // CHECK:STDOUT: %m.patt: %pattern_type.7ce = value_binding_pattern m [concrete]
  63. // CHECK:STDOUT: }
  64. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, imports.%Core [concrete = imports.%Core]
  65. // CHECK:STDOUT: %ReadChar.ref.loc9: %ReadChar.type.9f3 = name_ref ReadChar, imports.%Core.ReadChar [concrete = constants.%ReadChar.01f]
  66. // CHECK:STDOUT: %ReadChar.call.loc9: init %i32 = call %ReadChar.ref.loc9()
  67. // CHECK:STDOUT: %.loc9_10: type = splice_block %i32.loc9 [concrete = constants.%i32] {
  68. // CHECK:STDOUT: %int_32.loc9: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  69. // CHECK:STDOUT: %i32.loc9: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  70. // CHECK:STDOUT: }
  71. // CHECK:STDOUT: %.loc9_30.1: %i32 = value_of_initializer %ReadChar.call.loc9
  72. // CHECK:STDOUT: %.loc9_30.2: %i32 = converted %ReadChar.call.loc9, %.loc9_30.1
  73. // CHECK:STDOUT: %m: %i32 = value_binding m, %.loc9_30.2
  74. // CHECK:STDOUT: <elided>
  75. // CHECK:STDOUT: }
  76. // CHECK:STDOUT: