mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 19:40:10 +01:00
Allow more signatures for Main.Run. (#6751)
Allow an argc parameter and an argv parameter to be passed. For now we check that argc is an i32 and argv is a pointer. The rules here are not yet decided -- see #6735 -- but we should at least allow C-style access to argv for now in order to unblock experimentation.
This commit is contained in:
@@ -291,6 +291,97 @@ static auto MaybeAddToNameLookup(
|
||||
modifier_set.GetAccessKind());
|
||||
}
|
||||
|
||||
// Returns whether the given type is `i32`.
|
||||
static auto IsI32(Context& context, Parse::NodeId node_id,
|
||||
SemIR::TypeId type_id) -> bool {
|
||||
return type_id == MakeIntType(context, node_id, SemIR::IntKind::Signed,
|
||||
context.ints().Add(32));
|
||||
}
|
||||
|
||||
// Returns whether the given parameter list is valid for the entry point
|
||||
// function `Main.Run`.
|
||||
static auto IsValidEntryPointParamList(Context& context, Parse::NodeId node_id,
|
||||
SemIR::InstBlockId param_patterns_id)
|
||||
-> bool {
|
||||
if (!param_patterns_id.has_value()) {
|
||||
// Positional parameters for are not supported.
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto [index, param_pattern_id] :
|
||||
llvm::enumerate(context.inst_blocks().Get(param_patterns_id))) {
|
||||
if (param_pattern_id == SemIR::ErrorInst::InstId) {
|
||||
// Ignore erroneous parameters.
|
||||
continue;
|
||||
}
|
||||
|
||||
auto param =
|
||||
context.insts().TryGetAs<SemIR::ValueParamPattern>(param_pattern_id);
|
||||
if (!param) {
|
||||
// Only value parameters are supported for now.
|
||||
return false;
|
||||
}
|
||||
|
||||
if (param->type_id == SemIR::ErrorInst::TypeId) {
|
||||
// Ignore parameters with erroneous types.
|
||||
continue;
|
||||
}
|
||||
|
||||
auto param_type_inst_id = context.types()
|
||||
.GetAs<SemIR::PatternType>(param->type_id)
|
||||
.scrutinee_type_inst_id;
|
||||
switch (index) {
|
||||
case 0: {
|
||||
// `argc` should be a 32-bit integer.
|
||||
if (!IsI32(
|
||||
context, node_id,
|
||||
context.types().GetTypeIdForTypeInstId(param_type_inst_id))) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
// `argv` should be a pointer.
|
||||
// TODO: Consider checking the pointee type also.
|
||||
if (!context.insts().Is<SemIR::PointerType>(param_type_inst_id)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
// TODO: Decide whether to allow a third `envp` parameter.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Returns whether the given return type is valid for the entry point
|
||||
// function `Main.Run`.
|
||||
static auto IsValidEntryPointReturnType(Context& context, Parse::NodeId node_id,
|
||||
SemIR::TypeId return_type_id) -> bool {
|
||||
// An implicit or explicit return type of `()` is OK.
|
||||
// TODO: Translate this to returning an `i32` with value `0` in lowering.
|
||||
if (!return_type_id.has_value()) {
|
||||
return true;
|
||||
}
|
||||
if (return_type_id == GetTupleType(context, {})) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (IsI32(context, node_id, return_type_id)) {
|
||||
// Explicit return type of `i32` or an adapter for it is OK.
|
||||
return true;
|
||||
}
|
||||
|
||||
// For now, disallow anything else.
|
||||
// TODO: Decide on valid return types for `Main.Run`. Perhaps we should
|
||||
// have an interface for this.
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the function is the entry point, do corresponding validation.
|
||||
static auto ValidateForEntryPoint(Context& context,
|
||||
Parse::AnyFunctionDeclId node_id,
|
||||
@@ -301,21 +392,22 @@ static auto ValidateForEntryPoint(Context& context,
|
||||
return;
|
||||
}
|
||||
|
||||
auto return_type_id = function_info.GetDeclaredReturnType(context.sem_ir());
|
||||
// TODO: Update this once valid signatures for the entry point are decided.
|
||||
// See https://github.com/carbon-language/carbon-lang/issues/6735
|
||||
if (function_info.implicit_param_patterns_id.has_value() ||
|
||||
!function_info.param_patterns_id.has_value() ||
|
||||
!context.inst_blocks().Get(function_info.param_patterns_id).empty() ||
|
||||
(return_type_id.has_value() &&
|
||||
return_type_id != GetTupleType(context, {}) &&
|
||||
// TODO: Decide on valid return types for `Main.Run`. Perhaps we should
|
||||
// have an interface for this.
|
||||
return_type_id != MakeIntType(context, node_id, SemIR::IntKind::Signed,
|
||||
context.ints().Add(32)))) {
|
||||
CARBON_DIAGNOSTIC(InvalidMainRunSignature, Error,
|
||||
"invalid signature for `Main.Run` function; expected "
|
||||
"`fn ()` or `fn () -> i32`");
|
||||
context.emitter().Emit(node_id, InvalidMainRunSignature);
|
||||
!IsValidEntryPointParamList(context, node_id,
|
||||
function_info.param_patterns_id)) {
|
||||
CARBON_DIAGNOSTIC(InvalidMainRunParameters, Error,
|
||||
"invalid parameters for `Main.Run` function; expected "
|
||||
"`()` or `(argc: i32, argv: Core.Optional(char*)*)`");
|
||||
context.emitter().Emit(node_id, InvalidMainRunParameters);
|
||||
} else if (!IsValidEntryPointReturnType(
|
||||
context, node_id,
|
||||
function_info.GetDeclaredReturnType(context.sem_ir()))) {
|
||||
CARBON_DIAGNOSTIC(InvalidMainRunReturnType, Error,
|
||||
"invalid return type for `Main.Run` function; expected "
|
||||
"`fn (...)` or `fn (...) -> i32`");
|
||||
context.emitter().Emit(node_id, InvalidMainRunReturnType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,8 +10,32 @@
|
||||
// TIP: To dump output, run:
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/main_run/fail_mismatch_params.carbon
|
||||
|
||||
// CHECK:STDERR: fail_mismatch_params.carbon:[[@LINE+4]]:1: error: invalid signature for `Main.Run` function; expected `fn ()` or `fn () -> i32` [InvalidMainRunSignature]
|
||||
// CHECK:STDERR: fn Run(n: i32) {}
|
||||
// --- fail_bad_argc.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: fail_bad_argc.carbon:[[@LINE+4]]:1: error: invalid parameters for `Main.Run` function; expected `()` or `(argc: i32, argv: Core.Optional(char*)*)` [InvalidMainRunParameters]
|
||||
// CHECK:STDERR: fn Run(n: i64) {}
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
fn Run(n: i32) {}
|
||||
fn Run(n: i64) {}
|
||||
|
||||
// --- fail_bad_argv.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: fail_bad_argv.carbon:[[@LINE+4]]:1: error: invalid parameters for `Main.Run` function; expected `()` or `(argc: i32, argv: Core.Optional(char*)*)` [InvalidMainRunParameters]
|
||||
// CHECK:STDERR: fn Run(n: i32, p: i32) {}
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
fn Run(n: i32, p: i32) {}
|
||||
|
||||
// --- fail_too_many_params.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: fail_too_many_params.carbon:[[@LINE+4]]:1: error: invalid parameters for `Main.Run` function; expected `()` or `(argc: i32, argv: Core.Optional(char*)*)` [InvalidMainRunParameters]
|
||||
// CHECK:STDERR: fn Run(n: i32, p: i32*, q: i32*) {}
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
fn Run(n: i32, p: i32*, q: i32*) {}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
// TIP: To dump output, run:
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/main_run/fail_mismatch_return.carbon
|
||||
|
||||
// CHECK:STDERR: fail_mismatch_return.carbon:[[@LINE+4]]:1: error: invalid signature for `Main.Run` function; expected `fn ()` or `fn () -> i32` [InvalidMainRunSignature]
|
||||
// CHECK:STDERR: fail_mismatch_return.carbon:[[@LINE+4]]:1: error: invalid return type for `Main.Run` function; expected `fn (...)` or `fn (...) -> i32` [InvalidMainRunReturnType]
|
||||
// CHECK:STDERR: fn Run() -> f64 {
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
|
||||
+80
-2
@@ -2,7 +2,7 @@
|
||||
// Exceptions. See /LICENSE for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/none.carbon
|
||||
// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/int.carbon
|
||||
// EXTRA-ARGS: --dump-sem-ir-ranges=if-present
|
||||
//
|
||||
// AUTOUPDATE
|
||||
@@ -11,19 +11,39 @@
|
||||
// TIP: To dump output, run:
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/main_run/no_return.carbon
|
||||
|
||||
// --- no_params.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
fn Run() {}
|
||||
|
||||
// CHECK:STDOUT: --- no_return.carbon
|
||||
// --- with_params.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// TODO: Switch a proper type for argv once we require one.
|
||||
fn Run(argc: i32, argv: i32*) {}
|
||||
|
||||
// CHECK:STDOUT: --- no_params.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: %Run.type: type = fn_type @Run [concrete]
|
||||
// CHECK:STDOUT: %Run: %Run.type = struct_value () [concrete]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: imports {
|
||||
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
|
||||
// CHECK:STDOUT: import Core//prelude
|
||||
// CHECK:STDOUT: import Core//prelude/...
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
|
||||
// CHECK:STDOUT: .Core = imports.%Core
|
||||
// CHECK:STDOUT: .Run = %Run.decl
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Core.import = import Core
|
||||
// CHECK:STDOUT: %Run.decl: %Run.type = fn_decl @Run [concrete = constants.%Run] {} {}
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
@@ -32,3 +52,61 @@ fn Run() {}
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: --- with_params.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
|
||||
// CHECK:STDOUT: %Int.type: type = generic_class_type @Int [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: %ptr: type = ptr_type %i32 [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.fe8: type = pattern_type %ptr [concrete]
|
||||
// CHECK:STDOUT: %Run.type: type = fn_type @Run [concrete]
|
||||
// CHECK:STDOUT: %Run: %Run.type = struct_value () [concrete]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: imports {
|
||||
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
|
||||
// CHECK:STDOUT: .Int = %Core.Int
|
||||
// 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: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
|
||||
// CHECK:STDOUT: .Core = imports.%Core
|
||||
// CHECK:STDOUT: .Run = %Run.decl
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Core.import = import Core
|
||||
// CHECK:STDOUT: %Run.decl: %Run.type = fn_decl @Run [concrete = constants.%Run] {
|
||||
// CHECK:STDOUT: %argc.patt: %pattern_type.7ce = value_binding_pattern argc [concrete]
|
||||
// CHECK:STDOUT: %argc.param_patt: %pattern_type.7ce = value_param_pattern %argc.patt, call_param0 [concrete]
|
||||
// CHECK:STDOUT: %argv.patt: %pattern_type.fe8 = value_binding_pattern argv [concrete]
|
||||
// CHECK:STDOUT: %argv.param_patt: %pattern_type.fe8 = value_param_pattern %argv.patt, call_param1 [concrete]
|
||||
// CHECK:STDOUT: } {
|
||||
// CHECK:STDOUT: %argc.param: %i32 = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc5_14: type = splice_block %i32.loc5_14 [concrete = constants.%i32] {
|
||||
// CHECK:STDOUT: %int_32.loc5_14: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32.loc5_14: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %argc: %i32 = value_binding argc, %argc.param
|
||||
// CHECK:STDOUT: %argv.param: %ptr = value_param call_param1
|
||||
// CHECK:STDOUT: %.loc5_28: type = splice_block %ptr [concrete = constants.%ptr] {
|
||||
// CHECK:STDOUT: %int_32.loc5_25: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32.loc5_25: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %ptr: type = ptr_type %i32.loc5_25 [concrete = constants.%ptr]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %argv: %ptr = value_binding argv, %argv.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: fn @Run(%argc.param: %i32, %argv.param: %ptr) {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
|
||||
+114
-7
@@ -11,9 +11,20 @@
|
||||
// TIP: To dump output, run:
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/main_run/return_i32.carbon
|
||||
|
||||
// --- no_params.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
fn Run() -> i32 { return 0; }
|
||||
|
||||
// CHECK:STDOUT: --- return_i32.carbon
|
||||
// --- with_params.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// TODO: Switch a proper type for argv once we require one.
|
||||
fn Run(argc: i32, argv: i32*) -> i32 { return 0; }
|
||||
|
||||
// CHECK:STDOUT: --- no_params.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
|
||||
@@ -68,7 +79,7 @@ fn Run() -> i32 { return 0; }
|
||||
// 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: %.loc14_13: Core.Form = init_form %i32, call_param0 [concrete = constants.%.437]
|
||||
// CHECK:STDOUT: %.loc4_13: Core.Form = init_form %i32, call_param0 [concrete = constants.%.437]
|
||||
// CHECK:STDOUT: %return.param: ref %i32 = out_param call_param0
|
||||
// CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
|
||||
// CHECK:STDOUT: }
|
||||
@@ -80,11 +91,107 @@ fn Run() -> i32 { return 0; }
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6]
|
||||
// CHECK:STDOUT: %impl.elem0: %.863 = impl_witness_access constants.%ImplicitAs.impl_witness.6bc, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.0b5]
|
||||
// CHECK:STDOUT: %bound_method.loc14_27.1: <bound method> = bound_method %int_0, %impl.elem0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound]
|
||||
// CHECK:STDOUT: %bound_method.loc4_27.1: <bound method> = bound_method %int_0, %impl.elem0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound]
|
||||
// CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn]
|
||||
// CHECK:STDOUT: %bound_method.loc14_27.2: <bound method> = bound_method %int_0, %specific_fn [concrete = constants.%bound_method]
|
||||
// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call: init %i32 = call %bound_method.loc14_27.2(%int_0) [concrete = constants.%int_0.6a9]
|
||||
// CHECK:STDOUT: %.loc14_27: init %i32 = converted %int_0, %Core.IntLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%int_0.6a9]
|
||||
// CHECK:STDOUT: return %.loc14_27
|
||||
// CHECK:STDOUT: %bound_method.loc4_27.2: <bound method> = bound_method %int_0, %specific_fn [concrete = constants.%bound_method]
|
||||
// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call: init %i32 = call %bound_method.loc4_27.2(%int_0) [concrete = constants.%int_0.6a9]
|
||||
// CHECK:STDOUT: %.loc4_27: init %i32 = converted %int_0, %Core.IntLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%int_0.6a9]
|
||||
// CHECK:STDOUT: return %.loc4_27
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: --- with_params.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
|
||||
// CHECK:STDOUT: %Int.type: type = generic_class_type @Int [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: %ptr: type = ptr_type %i32 [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.fe8: type = pattern_type %ptr [concrete]
|
||||
// CHECK:STDOUT: %.8ef: Core.Form = init_form %i32, call_param2 [concrete]
|
||||
// CHECK:STDOUT: %Run.type: type = fn_type @Run [concrete]
|
||||
// CHECK:STDOUT: %Run: %Run.type = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %int_0.5c6: Core.IntLiteral = int_value 0 [concrete]
|
||||
// CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete]
|
||||
// CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %ImplicitAs.type.e8c: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
|
||||
// CHECK:STDOUT: %ImplicitAs.Convert.type.1b6: type = fn_type @ImplicitAs.Convert, @ImplicitAs(%i32) [concrete]
|
||||
// CHECK:STDOUT: %To: Core.IntLiteral = symbolic_binding To, 0 [symbolic]
|
||||
// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.4e6: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%To) [symbolic]
|
||||
// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.3c2: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.4e6 = struct_value () [symbolic]
|
||||
// CHECK:STDOUT: %ImplicitAs.impl_witness.6bc: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.74f, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete]
|
||||
// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.e0d: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete]
|
||||
// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.0b5: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.e0d = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.e8c = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.6bc) [concrete]
|
||||
// CHECK:STDOUT: %.863: type = fn_type_with_self_type %ImplicitAs.Convert.type.1b6, %ImplicitAs.facet [concrete]
|
||||
// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bound: <bound method> = bound_method %int_0.5c6, %Core.IntLiteral.as.ImplicitAs.impl.Convert.0b5 [concrete]
|
||||
// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn: <specific function> = specific_function %Core.IntLiteral.as.ImplicitAs.impl.Convert.0b5, @Core.IntLiteral.as.ImplicitAs.impl.Convert(%int_32) [concrete]
|
||||
// CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_0.5c6, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete]
|
||||
// CHECK:STDOUT: %int_0.6a9: %i32 = int_value 0 [concrete]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: imports {
|
||||
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
|
||||
// CHECK:STDOUT: .Int = %Core.Int
|
||||
// CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
|
||||
// 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.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/parts/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
|
||||
// CHECK:STDOUT: %Core.import_ref.42d: @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.4e6) = import_ref Core//prelude/parts/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.3c2)]
|
||||
// CHECK:STDOUT: %ImplicitAs.impl_witness_table.74f = impl_witness_table (%Core.import_ref.42d), @Core.IntLiteral.as.ImplicitAs.impl [concrete]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
|
||||
// CHECK:STDOUT: .Core = imports.%Core
|
||||
// CHECK:STDOUT: .Run = %Run.decl
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Core.import = import Core
|
||||
// CHECK:STDOUT: %Run.decl: %Run.type = fn_decl @Run [concrete = constants.%Run] {
|
||||
// CHECK:STDOUT: %argc.patt: %pattern_type.7ce = value_binding_pattern argc [concrete]
|
||||
// CHECK:STDOUT: %argc.param_patt: %pattern_type.7ce = value_param_pattern %argc.patt, call_param0 [concrete]
|
||||
// CHECK:STDOUT: %argv.patt: %pattern_type.fe8 = value_binding_pattern argv [concrete]
|
||||
// CHECK:STDOUT: %argv.param_patt: %pattern_type.fe8 = value_param_pattern %argv.patt, call_param1 [concrete]
|
||||
// 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_param2 [concrete]
|
||||
// CHECK:STDOUT: } {
|
||||
// CHECK:STDOUT: %int_32.loc5_34: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32.loc5_34: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %.loc5_34: Core.Form = init_form %i32.loc5_34, call_param2 [concrete = constants.%.8ef]
|
||||
// CHECK:STDOUT: %argc.param: %i32 = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc5_14: type = splice_block %i32.loc5_14 [concrete = constants.%i32] {
|
||||
// CHECK:STDOUT: %int_32.loc5_14: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32.loc5_14: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %argc: %i32 = value_binding argc, %argc.param
|
||||
// CHECK:STDOUT: %argv.param: %ptr = value_param call_param1
|
||||
// CHECK:STDOUT: %.loc5_28: type = splice_block %ptr [concrete = constants.%ptr] {
|
||||
// CHECK:STDOUT: %int_32.loc5_25: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32.loc5_25: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %ptr: type = ptr_type %i32.loc5_25 [concrete = constants.%ptr]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %argv: %ptr = value_binding argv, %argv.param
|
||||
// CHECK:STDOUT: %return.param: ref %i32 = out_param call_param2
|
||||
// CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %int_32.loc5_38.1: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32.loc5_38.1: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %int_32.loc5_38.2: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32.loc5_38.2: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @Run(%argc.param: %i32, %argv.param: %ptr) -> out %return.param: %i32 {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6]
|
||||
// CHECK:STDOUT: %impl.elem0: %.863 = impl_witness_access constants.%ImplicitAs.impl_witness.6bc, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.0b5]
|
||||
// CHECK:STDOUT: %bound_method.loc5_48.1: <bound method> = bound_method %int_0, %impl.elem0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound]
|
||||
// CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn]
|
||||
// CHECK:STDOUT: %bound_method.loc5_48.2: <bound method> = bound_method %int_0, %specific_fn [concrete = constants.%bound_method]
|
||||
// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call: init %i32 = call %bound_method.loc5_48.2(%int_0) [concrete = constants.%int_0.6a9]
|
||||
// CHECK:STDOUT: %.loc5_48: init %i32 = converted %int_0, %Core.IntLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%int_0.6a9]
|
||||
// CHECK:STDOUT: return %.loc5_48
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
|
||||
@@ -276,7 +276,8 @@ CARBON_DIAGNOSTIC_KIND(FunctionRedeclReturnTypePrevious)
|
||||
CARBON_DIAGNOSTIC_KIND(FunctionRedeclReturnTypePreviousNoReturn)
|
||||
CARBON_DIAGNOSTIC_KIND(FunctionRedeclEvaluationModeDiffers)
|
||||
CARBON_DIAGNOSTIC_KIND(FunctionRedeclEvaluationModePrevious)
|
||||
CARBON_DIAGNOSTIC_KIND(InvalidMainRunSignature)
|
||||
CARBON_DIAGNOSTIC_KIND(InvalidMainRunParameters)
|
||||
CARBON_DIAGNOSTIC_KIND(InvalidMainRunReturnType)
|
||||
CARBON_DIAGNOSTIC_KIND(MissingReturnStatement)
|
||||
CARBON_DIAGNOSTIC_KIND(UnknownBuiltinFunctionName)
|
||||
CARBON_DIAGNOSTIC_KIND(InvalidBuiltinSignature)
|
||||
|
||||
Reference in New Issue
Block a user