// Part of the Carbon Language project, under the Apache License v2.0 with LLVM // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/int.carbon // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only". // EXTRA-ARGS: --dump-sem-ir-ranges=if-present // // AUTOUPDATE // TIP: To test this file alone, run: // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/static_method.carbon // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/static_method.carbon class Class { fn F() -> i32; } fn Run() -> i32 { var c: Class; return c.F(); } // CHECK:STDOUT: --- static_method.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { // CHECK:STDOUT: %Class: type = class_type @Class [concrete] // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete] // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete] // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete] // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete] // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete] // CHECK:STDOUT: %F.type: type = fn_type @F [concrete] // CHECK:STDOUT: %F: %F.type = struct_value () [concrete] // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] // CHECK:STDOUT: %complete_type.357: = complete_type_witness %empty_struct_type [concrete] // CHECK:STDOUT: %Run.type: type = fn_type @Run [concrete] // CHECK:STDOUT: %Run: %Run.type = struct_value () [concrete] // CHECK:STDOUT: %pattern_type.761: type = pattern_type %Class [concrete] // CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete] // CHECK:STDOUT: %Op.type.7de: type = fn_type @Op.2, @Destroy.impl(%Class) [concrete] // CHECK:STDOUT: %Op.d64: %Op.type.7de = struct_value () [concrete] // CHECK:STDOUT: %ptr.e71: type = ptr_type %Class [concrete] // CHECK:STDOUT: %Op.specific_fn: = specific_function %Op.d64, @Op.2(%Class) [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { // CHECK:STDOUT: %Core: = namespace file.%Core.import, [concrete] { // CHECK:STDOUT: .Int = %Core.Int // CHECK:STDOUT: .Destroy = %Core.Destroy // CHECK:STDOUT: import Core//prelude // CHECK:STDOUT: import Core//prelude/... // CHECK:STDOUT: } // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic] // CHECK:STDOUT: %Core.Destroy: type = import_ref Core//prelude/parts/destroy, Destroy, loaded [concrete = constants.%Destroy.type] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [concrete] { // CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: .Run = %Run.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %Class.decl: type = class_decl @Class [concrete = constants.%Class] {} {} // CHECK:STDOUT: %Run.decl: %Run.type = fn_decl @Run [concrete = constants.%Run] { // CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete] // CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param0 [concrete] // CHECK:STDOUT: } { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param0 // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param // CHECK:STDOUT: } // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Class { // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] { // CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete] // CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param0 [concrete] // CHECK:STDOUT: } { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param0 // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param // CHECK:STDOUT: } // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type] // CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete = constants.%complete_type.357] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = constants.%Class // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F() -> %i32; // CHECK:STDOUT: // CHECK:STDOUT: fn @Run() -> %i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: name_binding_decl { // CHECK:STDOUT: %c.patt: %pattern_type.761 = binding_pattern c [concrete] // CHECK:STDOUT: %c.var_patt: %pattern_type.761 = var_pattern %c.patt [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %Class = var %c.var_patt // CHECK:STDOUT: %Class.ref: type = name_ref Class, file.%Class.decl [concrete = constants.%Class] // CHECK:STDOUT: %c: ref %Class = bind_name c, %c.var // CHECK:STDOUT: %c.ref: ref %Class = name_ref c, %c // CHECK:STDOUT: %F.ref: %F.type = name_ref F, @Class.%F.decl [concrete = constants.%F] // CHECK:STDOUT: %F.call: init %i32 = call %F.ref() // CHECK:STDOUT: %.loc21_15.1: %i32 = value_of_initializer %F.call // CHECK:STDOUT: %.loc21_15.2: %i32 = converted %F.call, %.loc21_15.1 // CHECK:STDOUT: %Op.bound: = bound_method %c.var, constants.%Op.d64 // CHECK:STDOUT: %Op.specific_fn: = specific_function constants.%Op.d64, @Op.2(constants.%Class) [concrete = constants.%Op.specific_fn] // CHECK:STDOUT: %bound_method: = bound_method %c.var, %Op.specific_fn // CHECK:STDOUT: %addr: %ptr.e71 = addr_of %c.var // CHECK:STDOUT: %no_op: init %empty_tuple.type = call %bound_method(%addr) // CHECK:STDOUT: return %.loc21_15.2 // CHECK:STDOUT: } // CHECK:STDOUT: