mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 22:02:52 +01:00
Instead of building the definition of a thunk immediately when we generate the thunk declaration, wait until we reach the `}` of the outermost class, interface, etc. -- at the same time when we would parse the definition of the thunk if it were defined inline. This fixes issues where we fail to define the thunk because it requires an enclosing class to be complete, or its definition depends on something declared later in the enclosing class. Make the representation of a suspended function scope, and its constituent suspended components, be move-only, and switch to passing it around by rvalue reference instead of by value because it's expensive both to move and especially to copy. --------- Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
28 lines
1.0 KiB
C++
28 lines
1.0 KiB
C++
// 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
|
|
|
|
#ifndef CARBON_TOOLCHAIN_CHECK_THUNK_H_
|
|
#define CARBON_TOOLCHAIN_CHECK_THUNK_H_
|
|
|
|
#include "toolchain/check/context.h"
|
|
#include "toolchain/check/deferred_definition_scope.h"
|
|
#include "toolchain/sem_ir/ids.h"
|
|
|
|
namespace Carbon::Check {
|
|
|
|
// Given a function signature and a callee function, build a thunk that matches
|
|
// the given signature and calls the specified callee. Returns the callee
|
|
// unchanged if it can be used directly.
|
|
auto BuildThunk(Context& context, SemIR::FunctionId signature_id,
|
|
SemIR::SpecificId signature_specific_id,
|
|
SemIR::InstId callee_id) -> SemIR::InstId;
|
|
|
|
// Builds the definition for a thunk whose definition was deferred until the end
|
|
// of the enclosing scope.
|
|
auto BuildThunkDefinition(Context& context, PendingThunk&& thunk) -> void;
|
|
|
|
} // namespace Carbon::Check
|
|
|
|
#endif // CARBON_TOOLCHAIN_CHECK_THUNK_H_
|